diff --git a/src/gadgets/MarkAsResolved-restricted/MediaWiki:Gadget-MarkAsResolved-restricted.js b/src/gadgets/MarkAsResolved-restricted/MediaWiki:Gadget-MarkAsResolved-restricted.js index d6db1d33..95c0fcfb 100644 --- a/src/gadgets/MarkAsResolved-restricted/MediaWiki:Gadget-MarkAsResolved-restricted.js +++ b/src/gadgets/MarkAsResolved-restricted/MediaWiki:Gadget-MarkAsResolved-restricted.js @@ -174,6 +174,7 @@ $(() => { } const toclist = Object.fromEntries((await api.post({ action: "parse", + assertuser: mw.config.get("wgUserName"), format: "json", pageid: mw.config.get("wgArticleId"), prop: "sections", @@ -204,6 +205,7 @@ $(() => { async markAsResolved({ section }) { const d = await api.postWithToken("csrf", { action: "edit", + assertuser: mw.config.get("wgUserName"), pageid: mw.config.get("wgArticleId"), section, summary: `标记讨论串「/* ${this.sectionTitle} */」状态为【${this.statusLabel}】`, diff --git a/src/gadgets/MarkAsResolved/MediaWiki:Gadget-MarkAsResolved.js b/src/gadgets/MarkAsResolved/MediaWiki:Gadget-MarkAsResolved.js index a80adbec..d3e60a70 100644 --- a/src/gadgets/MarkAsResolved/MediaWiki:Gadget-MarkAsResolved.js +++ b/src/gadgets/MarkAsResolved/MediaWiki:Gadget-MarkAsResolved.js @@ -183,6 +183,7 @@ $(() => { } const toclist = Object.fromEntries((await api.post({ action: "parse", + assertuser: mw.config.get("wgUserName"), format: "json", pageid: mw.config.get("wgArticleId"), prop: "sections", @@ -213,6 +214,7 @@ $(() => { async markAsResolved({ section }) { const d = await api.postWithToken("csrf", { action: "edit", + assertuser: mw.config.get("wgUserName"), pageid: mw.config.get("wgArticleId"), section, summary: `标记讨论串「/* ${this.sectionTitle} */」状态为【${this.statusLabel}】`, diff --git a/src/gadgets/Purgecache/MediaWiki:Gadget-Purgecache.js b/src/gadgets/Purgecache/MediaWiki:Gadget-Purgecache.js index b92011cd..4431c7ec 100644 --- a/src/gadgets/Purgecache/MediaWiki:Gadget-Purgecache.js +++ b/src/gadgets/Purgecache/MediaWiki:Gadget-Purgecache.js @@ -32,6 +32,7 @@ $(() => { const api = new mw.Api(), opt = { action: "purge", + assertuser: mw.config.get("wgUserName"), format: "json", forcelinkupdate: true, titles: mw.config.get("wgPageName"), diff --git a/src/gadgets/SpecialWikitext/MediaWiki:Gadget-SpecialWikitext.js b/src/gadgets/SpecialWikitext/MediaWiki:Gadget-SpecialWikitext.js index 3d8c3826..25ab1ae5 100644 --- a/src/gadgets/SpecialWikitext/MediaWiki:Gadget-SpecialWikitext.js +++ b/src/gadgets/SpecialWikitext/MediaWiki:Gadget-SpecialWikitext.js @@ -148,6 +148,7 @@ const api = new mw.Api(); const wgPageName = mw.config.get("wgPageName"); const wgRevisionId = mw.config.get("wgRevisionId"); + const wgUserName = mw.config.get("wgUserName"); const noticeHTML = { loading: `
${wgULS("预览加载中...", "預覽載入中...")}
`, fail: `${wgULS("预览加载失败", "預覽載入失敗")}`, @@ -193,6 +194,7 @@ } const params = { action: "parse", + assertuser: wgUserName, uselang: getLanguage(), useskin: mw.config.get("skin"), title: pagename, @@ -235,6 +237,7 @@ } const params = { action: "parse", + assertuser: wgUserName, uselang: getLanguage(), useskin: mw.config.get("skin"), format: "json", @@ -280,6 +283,7 @@ try { const data = await api.post({ action: "parse", + assertuser: wgUserName, oldid: wgRevisionId, prop: "wikitext", }); @@ -303,6 +307,7 @@ try { const data = await api.post({ action: "parse", //get the original wikitext content of a page + assertuser: wgUserName, uselang: getLanguage(), useskin: mw.config.get("skin"), title: `${pagename}${subPagename}`, @@ -425,6 +430,7 @@ const wikitext = `
${wikitextPackage}
`; const params = { action: "parse", + assertuser: wgUserName, text: wikitext, contentmodel: "wikitext", prop: "text", diff --git a/src/gadgets/UserMessages/MediaWiki:Gadget-UserMessages.js b/src/gadgets/UserMessages/MediaWiki:Gadget-UserMessages.js index 6a024d45..bc82c84f 100644 --- a/src/gadgets/UserMessages/MediaWiki:Gadget-UserMessages.js +++ b/src/gadgets/UserMessages/MediaWiki:Gadget-UserMessages.js @@ -81,6 +81,7 @@ const User = this.oldValue = this.callingObject.umCleanFileAndUser(val); const query = { action: "query", + assertuser: mw.config.get("wgUserName"), list: "allusers", aufrom: User, auto: User, @@ -411,6 +412,7 @@ umSeekUsers: (request, pCallback) => { const query = { action: "query", + assertuser: mw.config.get("wgUserName"), list: "allusers", auprefix: request.term.replace(/^(?:User):/, ""), }; @@ -431,6 +433,7 @@ umSeekFiles: (request, pCallback) => { const query = { action: "query", + assertuser: mw.config.get("wgUserName"), list: "allimages", aiprefix: request.term.replace(/^(?:File|Image):/, ""), }; @@ -558,6 +561,7 @@ umsg.umPendingParser++; const action = { action: "parse", + assertuser: mw.config.get("wgUserName"), uselang: mw.config.get("wgUserLanguage"), redirects: true, prop: "text", @@ -595,6 +599,7 @@ } const query = { action: "query", + assertuser: mw.config.get("wgUserName"), prop: "info", intoken: "edit", titles: "FAQ", // Random title @@ -634,6 +639,7 @@ savePage: (page, summary, callback) => { const edit = { action: "edit", + assertuser: mw.config.get("wgUserName"), summary: summary, tags: "UserMessages", watchlist: page.watchlist || "preferences", diff --git a/src/gadgets/interfaceVariantConverter/MediaWiki:Gadget-interfaceVariantConverter.js b/src/gadgets/interfaceVariantConverter/MediaWiki:Gadget-interfaceVariantConverter.js index 787625ab..0c41587b 100644 --- a/src/gadgets/interfaceVariantConverter/MediaWiki:Gadget-interfaceVariantConverter.js +++ b/src/gadgets/interfaceVariantConverter/MediaWiki:Gadget-interfaceVariantConverter.js @@ -12,6 +12,7 @@ // }; $(() => (async () => { const pagename = mw.config.get("wgPageName"); + const username = mw.config.get("wgUserName"); if (mw.config.get("wgNamespaceNumber") !== 8 || pagename.includes(".js") || pagename.includes(".css")) { return; } @@ -44,6 +45,7 @@ $(() => (async () => { try { prepopContent = lr_aivc.autoPopulate ? (await api.get({ action: "parse", + assertuser: username, pageid, prop: "wikitext", })).parse.wikitext["*"] : ""; @@ -355,6 +357,7 @@ $(() => (async () => { const text = `{{NoteTA|${this.config.noteTAStr}}}
-{}-${replaced}
`; const parsed = $($.parseHTML((await zhAPI.post({ action: "parse", + assertuser: username, text, contentmodel: "wikitext", prop: "text", @@ -384,6 +387,7 @@ $(() => (async () => { const text = this.textInputs[variant].getValue(); return api.postWithToken("csrf", { action: "edit", + assertuser: username, title: variantPage(variant), text, summary: `自动转换自[[${pagename}]]`, @@ -394,6 +398,7 @@ $(() => (async () => { const text = this.textInputs[parent/* as string*/].getValue(); return api.postWithToken("csrf", { action: "edit", + assertuser: username, title: variantPage(variant), text, summary: `自动转换自[[${pagename}]](同步${parent})`, diff --git a/src/gadgets/noteTA/MediaWiki:Gadget-noteTA.js b/src/gadgets/noteTA/MediaWiki:Gadget-noteTA.js index 94284a9c..78afb163 100644 --- a/src/gadgets/noteTA/MediaWiki:Gadget-noteTA.js +++ b/src/gadgets/noteTA/MediaWiki:Gadget-noteTA.js @@ -55,6 +55,7 @@ mw.hook("wikipage.content").add(() => { try { const results = await api.post({ action: "parse", + assertuser: mw.config.get("wgUserName"), title: "Template:CGroup/____SAND_BOX____", text: wikitext_1, prop: "text", @@ -95,6 +96,7 @@ mw.hook("wikipage.content").add(() => { try { const results = await api.post({ action: "parse", + assertuser: mw.config.get("wgUserName"), title: actualTitle_1, text: `{{noteTA/multititle|${actualTitle_1}}}`, prop: "text", @@ -189,7 +191,6 @@ mw.hook("wikipage.content").add(() => { if (typeof wgUserId === "number" && wgUserId > 0 && mw.config.get("wgAction") === "view" && localStorage.getItem("AnnTools-noteTA-alert") !== "true" && !document.querySelector("#noteTA-lang") && !/^\/zh-[a-z]+\//.test(location.pathname)) { const url = new mw.Uri(); const wgUserVariant = mw.config.get("wgUserVariant"); - const wgUserName = mw.config.get("wgUserName"); if (!(Reflect.has(url.query, "variant") || Reflect.has(url.query, "uselang")) && !url.path.startsWith("/index.php") && name.includes(wgUserVariant)) { $("body").append(`

检测到您当前使用的内容语言变体 ${wgUserVariant}${map[wgUserVariant]}会导致繁简转换无法正常工作,我们建议您切换到以下三种内容语言变体之一:

zh-cn(中国大陆) zh-hk(中国香港) zh-tw(台湾地区) | 了解更多 不再提示

`); const container = $("#noteTA-lang"); @@ -201,7 +202,7 @@ mw.hook("wikipage.content").add(() => { try { const result = await api.postWithToken("csrf", { action: "options", - assertuser: wgUserName, + assertuser: mw.config.get("wgUserName"), optionname: "variant", optionvalue: lang, }); diff --git a/src/gadgets/registerToDelete/MediaWiki:Gadget-registerToDelete.js b/src/gadgets/registerToDelete/MediaWiki:Gadget-registerToDelete.js index c4d24635..e90a0a78 100644 --- a/src/gadgets/registerToDelete/MediaWiki:Gadget-registerToDelete.js +++ b/src/gadgets/registerToDelete/MediaWiki:Gadget-registerToDelete.js @@ -171,6 +171,7 @@ $(() => { const template = /^en/.test(location.hostname) ? "Awaiting_deletion" : "即将删除"; const d = await api.postWithToken("csrf", { action: "edit", + assertuser: mw.config.get("wgUserName"), format: "json", title: mw.config.get("wgPageName"), text: `{{${template}|1=${this.reason}|user=${mw.config.get("wgUserName")}}}`, @@ -204,6 +205,7 @@ $(() => { loadReason = true; const { parse: { text: { ["*"]: html } } } = await new mw.Api().post({ action: "parse", + assertuser: mw.config.get("wgUserName"), page: mw.config.get("wgNamespaceNumber") === mw.config.get("wgNamespaceIds").file ? "MediaWiki:Filedelete-reason-dropdown" : "MediaWiki:Deletereason-dropdown", prop: "text", }); diff --git a/src/gadgets/report/MediaWiki:Gadget-report.js b/src/gadgets/report/MediaWiki:Gadget-report.js index ef7ad14d..d7951013 100644 --- a/src/gadgets/report/MediaWiki:Gadget-report.js +++ b/src/gadgets/report/MediaWiki:Gadget-report.js @@ -365,6 +365,7 @@ $(() => { const sectiontitle = `【页面反馈】${this.primaryType}${this.secondaryType !== "none" ? ` - ${this.secondaryType}` : ""} @ ${this.wgPageName}`; await api.postWithToken("csrf", { action: "edit", + assertuser: mw.config.get("wgUserName"), title: "萌娘百科_talk:讨论版/提问求助", section: "new", sectiontitle, diff --git a/src/gadgets/rollback-summary/MediaWiki:Gadget-rollback-summary.js b/src/gadgets/rollback-summary/MediaWiki:Gadget-rollback-summary.js index 2eeca1ac..70f4b77b 100644 --- a/src/gadgets/rollback-summary/MediaWiki:Gadget-rollback-summary.js +++ b/src/gadgets/rollback-summary/MediaWiki:Gadget-rollback-summary.js @@ -74,11 +74,12 @@ $(() => { if (uri.query.from) { try { await api.post({ + action: "rollback", + assertuser: mw.config.get("wgUserName"), title: uri.query.title, user: uri.query.from, summary, token: uri.query.token, - action: "rollback", format: "json", }); rbing.css("color", "green").html(`成功!${wgULS("将在", "將在")}3秒${wgULS("内刷新", "內重新整理")}`); diff --git a/src/gadgets/temp-editcheck/MediaWiki:Gadget-temp-editcheck.js b/src/gadgets/temp-editcheck/MediaWiki:Gadget-temp-editcheck.js index 7350d0e4..1e03d66d 100644 --- a/src/gadgets/temp-editcheck/MediaWiki:Gadget-temp-editcheck.js +++ b/src/gadgets/temp-editcheck/MediaWiki:Gadget-temp-editcheck.js @@ -10,6 +10,7 @@ $(() => { const wgCurRevisionId = mw.config.get("wgCurRevisionId"); const wgArticleId = mw.config.get("wgArticleId"); const wgPageName = mw.config.get("wgPageName"); + const wgUserName = mw.config.get("wgUserName"); const UNDEFINED = Symbol("UNDEFINED"); const sleep = (ms) => new Promise((res) => setTimeout(res, ms)); let unloading = false; @@ -101,6 +102,7 @@ $(() => { try { _apiResult = await api.post({ action: "query", + assertuser: wgUserName, format: "json", prop: "revisions", titles: wgPageName, diff --git a/src/gadgets/userpageDelete/MediaWiki:Gadget-userpageDelete.js b/src/gadgets/userpageDelete/MediaWiki:Gadget-userpageDelete.js index 2d0b0113..13109d59 100644 --- a/src/gadgets/userpageDelete/MediaWiki:Gadget-userpageDelete.js +++ b/src/gadgets/userpageDelete/MediaWiki:Gadget-userpageDelete.js @@ -72,6 +72,7 @@ $(() => { const api = new mw.Api(); const d = await api.postWithToken("csrf", { action: "edit", + assertuser: mw.config.get("wgUserName"), format: "json", title: mw.config.get("wgPageName"), text: "{{ns2d}}",