打开/关闭搜索
搜索
打开/关闭菜单
12.2K
18.1K
94
80.2K
导航
首页
最近更改
特殊页面
上传文件
随机页面
随机页面
随机歌曲
随机P主
编辑相关
帮助
讨论版
公共沙盒
待修改页面
批量上传文件
友情链接
VCPedia
打开/关闭外观设置菜单
通知
打开/关闭个人菜单
未登录
登录后可编辑和发表评论。
user-interface-preferences
个人工具
创建账号
登录
欢迎加入
本站官方QQ群
!
查看“︁MediaWiki:Gadget-moesync.js”︁的源代码
MediaWiki界面页面
查看
阅读
查看源代码
查看历史
associated-pages
系统消息
讨论
更多操作
←
MediaWiki:Gadget-moesync.js
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
此页面为本wiki上的软件提供界面文本,并受到保护以防止滥用。 如欲修改所有wiki的翻译,请访问
translatewiki.net
上的MediaWiki本地化项目。
您无权编辑此JavaScript页面,因为编辑此页面可能会影响所有访问者。
您可以查看和复制此页面的源代码。
//<pre> var _addText = '{{NotMGP}}'; /** * ------------------------------------------------------------------------- * 开发者:User:实验性:无用论废人 OOUI实现:User:屠麟傲血 * ------------------------------------------------------------------------- */ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function (t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; $(function () { /*函数执行体*/ if (mw.config.get("wgAction") === 'edit' || mw.config.get("wgIsArticle")) { $(mw.util.addPortletLink("p-cactions", "javascript:;", "同步萌百", "ca-sync", "同步萌百同名" + wgULS("页面", "頁面")) ).on("click", function () { mw.notify(wgULS("请求中...", "請求中...")); // remove old window manager, which causes API error. $('#moe-background').remove(); var diffWindow = new syncDialog({ id: "moe-background", size: 'larger' }); // Create and append a window manager, which opens and closes the window. var windowManager = new OO.ui.WindowManager(); $("body").append(windowManager.$element); windowManager.addWindows([diffWindow]); // Open the window! windowManager.openWindow(diffWindow); setTimeout(() => moesync_jsonp(), 200); }); } /*預備變量*/ var moe_data = ""; var api = new mw.Api(); //点名批评 mediawiki.ForeignApi 不能直接用! var zhmoeapi = new mw.ForeignApi("https://mzh.moegirl.org.cn/api.php", { anonymous: true }); var neterr = wgULS('网络连接出错', "網路連接出錯", null, null, "網絡連接出錯"); // 预备函数(请求) function moesync_jsonp() { zhmoeapi.get({ action: "query", format: "json", formatversion: 2, titles: mw.config.get("wgPageName"), prop: "revisions", rvprop: "content" }).then(function (result) { var page = result.query.pages[0]; if (page.missing) { moesync_dont(); mw.notify('萌百' + wgULS('无对应页面', "無對應頁面"), { type: "warn" }); return; } moe_data = page.revisions[0].content; moesync_compare(); }, function (e) { moesync_dont(); mw.notify(neterr, { type: "error" }); console.error("网络/API错误:", e); }); } function moesync_compare() { api.post({ 'action': 'compare', 'format': 'json', 'fromtitle': mw.config.get("wgPageName"), 'toslots': 'main', 'totext-main': moe_data, 'prop': 'diff' }).then(function (data) { if (data.compare['*']) { $('#moesync-diff').append(data.compare['*']); mw.notify(wgULS("请求", "請求") + '完成', { type: "success" }); } else { moesync_dont(); mw.notify('萌百' + wgULS('与本站内容一致', "與本站內容一致"), { type: "warn" }); } }, function (e) { if (e == "missingtitle") { moesync_compare_create(); } else { moesync_dont(); mw.notify(neterr, { type: "error" }); } }); } function moesync_compare_create() { api.post({ 'action': 'compare', 'format': 'json', 'fromslots': 'main', 'fromtext-main': '', 'toslots': 'main', 'totext-main': moe_data, 'prop': 'diff' }).then(function (data) { $('#moesync-diff').append(data.compare['*']); mw.notify(wgULS("请求", "請求") + '完成', { type: "success" }); }, function (e) { moesync_dont(); mw.notify(neterr, { type: "error" }); }); } function moesync_edit(summary, watchpage, minoredit) { var params = { action: 'edit', format: 'json', title: mw.config.get('wgPageName'), text: moe_data, summary: summary, tags: 'Automation tool|moesync', watchlist: watchpage, bot: mw.config.get("wgUserGroups").includes("flood"), }; if (minoredit) { params.minor = true; } else { params.notminor = true; } api.postWithToken('csrf', params).done(function (data) { mw.notify(wgULS("即将刷新……", "即將刷新……"), { title: "提交完成", type: "success", tag: "moesync" }); $('#moe-background').hide(200); setTimeout(() => location.reload(), 730); }); } // 报错时关闭提交按钮 function moesync_dont() { $("#moe-background .oo-ui-processDialog-actions-primary").remove(); $("#moe-background input").attr("disabled", "disabled"); $('.oo-ui-fieldLayout').css("color", "#72777d"); } // 预备函数(DOM构造) var syncDialog = /** @class */ (function (_super) { __extends(syncDialog, _super); function syncDialog(config) { // Parent constructor return _super.call(this, config) || this; } syncDialog.prototype.initialize = function () { // Parent method _super.prototype.initialize.call(this); this.panelLayout = new OO.ui.PanelLayout({ scrollable: false, expanded: false, padded: true }); this.summaryBox = new OO.ui.TextInputWidget({ value: "来源于萌娘百科,依CC BY-NC-SA 3.0 CN导入,原贡献者请参见来源页面历史", }); var summaryField = new OO.ui.FieldLayout(this.summaryBox, { label: wgULS("编辑摘要", "編輯摘要"), align: "top", id: "diff-summary", }); this.watchlistBox = new OO.ui.CheckboxInputWidget({ selected: false, }); var watchlistField = new OO.ui.FieldLayout(this.watchlistBox, { label: wgULS("监视本页", "監視此頁面"), align: "inline", id: "watchlist", }); this.minorBox = new OO.ui.CheckboxInputWidget({ selected: false, }); var minorField = new OO.ui.FieldLayout(this.minorBox, { label: wgULS("这是一次小编辑", "這是次要編輯"), align: "inline", id: "minor", }); this.panelLayout.$element.append(summaryField.$element, minorField.$element, watchlistField.$element); //按钮合成 this.content = new OO.ui.BookletLayout({ padded: true, expanded: false, id: "moe-diff-div" }); this.content.$element.append('<table class="diff moe-diff">' + '<colgroup>' + '<col class="diff-marker">' + '<col class="diff-content">' + '<col class="diff-marker">' + '<col class="diff-content">' + '</colgroup>' + '<tbody id="moesync-diff">' + '<tr>' + '<td colspan="2" class="diff-lineno" id="mw-diff-left-l1">' + wgULS("本站(编辑前内容):", "本站(編輯前內容):") + '</td>' + '<td colspan="2" class="diff-lineno">' + '萌百' + wgULS("(编辑后内容):", "(編輯後內容):") + '</td>' + '</tr> ' + '</tbody>' + '</table>'); this.$body.append(this.content.$element, this.panelLayout.$element); }; syncDialog.prototype.getActionProcess = function (action) { var _this = this, trcount = $("tbody#moesync-diff > tr").eq(1).length; if (action === "cancel") { return new OO.ui.Process(function () { _this.close({ action: action }); }, this); } else if (trcount == 0 && action === "submit") { return new OO.ui.Process(function () { mw.notify(wgULS("API未加载完成,请您坐和放宽", "API未加載完成,請您坐和放寬"), { type: "error", title: wgULS("本站提醒您", "本站提醒您"), tag: "unloaded" }); }, this); } else if (action === "submit" && trcount == 1) { return new OO.ui.Process(function () { var summary = _this.summaryBox.getValue(); var watchpage = _this.watchlistBox.isSelected() ? "watch" : "nochange"; var minoredit = _this.minorBox.isSelected(); moesync_edit(summary, watchpage, minoredit); }, this); } // Fallback to parent handler return _super.prototype.getActionProcess.call(this, action); }; syncDialog.prototype.getBodyHeight = function () { return Math.round($(window).height() * 0.9); }; syncDialog.static = __assign(__assign({}, _super.static), { name: "moesync", title: "同步萌百同名" + wgULS("页面", "頁面"), actions: [ { action: "cancel", label: "取消", flags: ["safe", "close", "destructive"], }, { action: "submit", label: "提交" + wgULS("编辑", "編輯"), flags: ["primary", "progressive"], }, ] }); return syncDialog; }(OO.ui.ProcessDialog)); }); //</pre>
返回
MediaWiki:Gadget-moesync.js
。
查看“︁MediaWiki:Gadget-moesync.js”︁的源代码
MediaWiki界面页面