User:Sai10ukazuki/me.js

/*************************************************************************************************** * This script is partially forked from 利用者:Semi-Brace/ .js ***************************************************************************************************/ ( => {	"use strict";	if (mw.config.values.wgPageName !== "特別:Message" || mw.user.getId !== 928697) return;	$(function{ console.log(this, document); $("#mw-content-text").append([			$(" ").text("送る人の名前 (改行区切り)"),			$(" ").attr({type: "textbox", id: "bulkmes-send"}),			$(" ").text("送る内容 (ウィキテキスト、署名なし)"),			$(" ").attr({type: "textbox", id: "bulkmes-content"}),			$(" ").text("セクション名"),			$(" ").attr({type: "textbox", id: "bulkmes-section"}),			$(" ").text("要約欄"),			$(" ").attr({type: "textbox", id: "bulkmes-editsummary"}),			$(" "),			$(" ").attr({type: "button", id: "bulkmes-submit", value: "送信"}).click(function{ console.debug("sending process started."); console.debug(`signature: ${mw.user.options.values.nickname}`); const userSpec = $("#bulkmes-send").val; console.debug(`users: ${userSpec}`); const text = $("#bulkmes-content").val; console.debug(`text: ${text}`); if (userSpec === "") { $("#bulkmes-error").text("ユーザーがいません"); return; }				if (text === "") { $("#bulkmes-error").text("内容がありません"); return; }				let users = userSpec.split("\n"); const mwapi = new mw.Api; const editSummary = $("#bulkmes-edit").val; mwapi.get({						action: 'query',						list: 'users',						ususers: users.join("|"),						usprop: '',						format: 'json'				}).done(ll => {					console.debug("data", ll);					users = ll.query.users.filter(x => x.invalid === undefined && x.missing === undefined);					console.debug("users", users);					const d = new Date;					const weekday = "日月火水木金土"[d.getDay];					const hours = d.getUTCHours.toString.padStart(2, "0");					const minutes = d.getUTCMinutes.toString.padStart(2, "0");					const sign = `${mw.user.options.values.nickname} ${d.getUTCFullYear}年${d.getUTCMonth + 1}月${d.getUTCDate}日 (${weekday}) ${hours}:${minutes} (UTC)`;					const section = $("#bulkmes-section").val || editSummary;					users.map(x => x.name).map(x => "User talk:" + x).forEach(page => { mwapi.postWithEditToken({							action: "edit",							section: "new",							// 署名							text: text + "--" + sign,							summary: editSummary,							title: page,							sectiontitle: section,						}).then(x => {							x.warning && console.error(x.warning);							return x;						}, (...e) => console.error(e)); });				});				console.debug("END -"); }),			$(" ").attr({display: "none", id: "bulkmes-error"}).addClass("error"),		]); }); });