User:镜音铃/Wikiplus/Main.js

"use strict";function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function MoeNotification{var a=this;this.display=function{var b=arguments.length<=0||void 0===arguments[0]?"喵~":arguments[0],c=arguments.length<=1||void 0===arguments[1]?"success":arguments[1],d=arguments.length<=2||void 0===arguments[2]?function{}:arguments[2];$("#MoeNotification").append($(" ").addClass("MoeNotification-notice").addClass("MoeNotification-notice-"+c).append(" "+b+" ")),$("#MoeNotification").find(".MoeNotification-notice").last.fadeIn(300),a.bind,a.clear,d($("#MoeNotification").find(".MoeNotification-notice").last)},this.create={success:function(b,c){var d=c||function{};a.display(b,"success",d)},warning:function(b,c){var d=c||function{};a.display(b,"warning",d)},error:function(b,c){var d=c||function{};a.display(b,"error",d)}},this.clear=function{return $(".MoeNotification-notice").length>=10?($("#MoeNotification").children.first.fadeOut(150,function{$(this).remove}),void setTimeout(a.clear,300)):!1},this.empty=function(a){$(".MoeNotification-notice").each(function(b){var c=function(a){if("function"==typeof a)return!0;var b=Object.prototype.toString(a);return"[object Function]"===b||"[object GeneratorFunction]"===b};if(c(a)){var d=this;setTimeout(function{a($(d))},200*b)}else $(this).delay(200*b).fadeOut("fast",function{$(this).remove})})},this.bind=function{$(".MoeNotification-notice").mouseover(function{a.slideLeft($(this))})},this.slideLeft=function(a,b){a.css("position","relative"),a.animate({left:"-200%"},b||150,function{$(this).fadeOut("fast",function{$(this).remove})})},this.init=function{$("body").append(' ')},$("#MoeNotification").length>0||this.init}var _createClass=function{function a(a,b){for(var c=0;c=e[a.__language].__version&&(e[a.__language]=a,console.log("更新语言版本"+a.___language+"至"+a.___version)):e[a.__language]=a,localStorage.Wikiplus_i18nCache=JSON.stringify(e))},error:function(b){console.log("无法加载语言"+a)}})}function b(a){var b;try{b=JSON.parse(localStorage.Wikiplus_Settings).language||window.navigator.language.toLowerCase}catch(c){b=window.navigator.language.toLowerCase}return e[b]&&e[b][a]?e[b][a]:e["en-us"][a]?e["en-us"][a]:void 0}function c(a){var c={unknown_error_name:{number:1001,message:b("unknown_error_name")},api_unaccessiable:{number:1002},api_unwriteable:{number:1003},fail_to_get_timestamp:{number:1004},fail_to_get_edittoken:{number:1005},fail_to_get_pageinfo:{number:1006},not_autoconfirmed_user:{number:1007},hit_abusefilter:{number:1008},unknown_edit_error:{number:1009},unknown_edit_error_message:{number:1010},notitle:{number:1011},notext:{number:1012},notoken:{number:1013},invalidsection:{number:1014},protectedtitle:{number:1015},cantcreate:{number:1016},cantcreate_anon:{number:1017},articleexists:{number:1018},noimageredirect_anon:{number:1019},noimageredirect:{number:1020},spamdetected:{number:1021},filtered:{number:1022},contenttoobig:{number:1023},noedit_anon:{number:1025},noedit:{number:1026},pagedeleted:{number:1027},emptypage:{number:1028},emptynewsection:{number:1029},editconflict:{number:1030},revwrongpage:{number:1031},undofailure:{number:1032},missingtitle:{number:1033},mustbeposted:{number:1034},readapidenied:{number:1035},writeapidenied:{number:1036},noapiwrite:{number:1037},badtoken:{number:1038},missingparam:{number:1039},invalidparammix:{number:1040},invalidtitle:{number:1041},nosuchpageid:{number:1042},pagecannotexist:{number:1043},nosuchrevid:{number:1044},badmd5:{number:1045},hookaborted:{number:1046},parseerror:{number:1047},summaryrequired:{number:1048},blocked:{number:1049},ratelimited:{number:1050},unknownerror:{number:1051},nosuchsection:{number:1052},sectionsnotsupported:{number:1053},editnotsupported:{number:1054},appendnotsupported:{number:1055},redirect_appendonly:{number:1056},badformat:{number:1057},customcssprotected:{number:1058},customjsprotected:{number:1059},cascadeprotected:{number:1060},network_edit_error:{number:1061},need_init:{number:1062},fail_to_get_wikitext:{number:1063},fail_to_init_quickedit:{number:1064},fail_to_get_wikitext_when_edit:{number:1065},cant_parse_wikitext:{number:1066},empty_page_confirm:{number:1067},uninited:{number:1068},cant_parse_i18ncache:{number:1069},cant_load_language:{number:1070}};return c[a]?c[a].message?{number:c[a].number,message:c[a].message}:"undefined"!==b(a)?{number:c[a].number,message:b(a)}:{number:c[a].number,message:b("unknownerror")}:{number:c.unknown_error_name.number,message:c.unknown_error_name.message}}function d(a,b){var d=c(a),e=new Error;return e.number=d.number,e.message=b||d.message,console.log("%c致命错误["+e.number+"]:"+e.message,"color:red"),console.log(e),e}var e={},f=location.protocol+"//wikiplus-app.com";e["zh-cn"]={__language:"zh-cn",__author:["Eridanus Sora"],__version:"212",unknown_error_name:"未知的错误名",api_unaccessiable:"无可用的API",api_unwriteable:"无可用的写入API",fail_to_get_timestamp:"无法获得页面编辑起始时间戳",fail_to_get_edittoken:"无法获得页面编辑权标",fail_to_get_pageinfo:"无法获得页面信息",not_autoconfirmed_user:"非自动确认用户",hit_abusefilter:"被防滥用过滤器拦截",unknown_edit_error:"未知编辑错误",unknown_edit_error_message:"未知编辑错误($1)",notitle:"无法编辑空标题页面",notext:"缺少页面内容",notoken:"空编辑权标",invalidsection:"段落编号非法",protectedtitle:"该标题被保护，无法创建",cantcreate:"无新建页面权限",cantcreate_anon:"匿名用户无新建页面权限",articleexists:"无法创建已经存在的页面",noimageredirect_anon:"匿名用户无新建文件重定向权限",noimageredirect:"无新建文件重定向权限",spamdetected:"文本含有敏感内容，被SPAM过滤器拦截",filtered:"编辑被过滤器拦截",contenttoobig:"文本超过最大长度限制",noedit_anon:"匿名用户无编辑页面权限",noedit:"无编辑页面权限",pagedeleted:"编辑时，此页面被删除",emptypage:"无法新建空内容页面",emptynewsection:"无法新建空内容段落",editconflict:"编辑冲突，请手工检查页面当前内容与提交内容差异并修正后，刷新页面提交",revwrongpage:"编辑的修订版本与编辑的页面不匹配",undofailure:"由于存在冲突的中间版本，无法撤销编辑",missingtitle:"无法创建或编辑空标题页面",mustbeposted:"必须使用POST方式提交编辑",readapidenied:"无读取API使用权限",writeapidenied:"无通过API编辑页面权限",noapiwrite:"本Wiki未开启可用的写入API",badtoken:"非法的编辑权标",missingparam:"缺少必要参数，页面名和页面ID不能均为空",invalidparammix:"参数重复，页面名和页面ID不能同时给定",invalidtitle:"非法的标题",nosuchpageid:"不存在的页面ID",pagecannotexist:"该名称空间不允许新建一般页面",nosuchrevid:"不存在的修订版本",badmd5:"非法的MD5值",hookaborted:"编辑被扩展Hook拦截",parseerror:"无法解析页面文本",summaryrequired:"编辑摘要不能为空",blocked:"已被封禁",ratelimited:"达到操作速率上限，请稍后重试",unknownerror:"未知错误",nosuchsection:"无法编辑不存在的段落",sectionsnotsupported:"该页面不支持段落编辑",editnotsupported:"该页面不支持通过API编辑",appendnotsupported:"该页面无法在前后插入文本",redirect_appendonly:"在遵循重定向的情况下，只能进行前后插入或创建新段落",badformat:"文本格式错误",customcssprotected:"无法编辑用户CSS页",customjsprotected:"无法编辑用户JS页",cascadeprotected:"该页面被级联保护",network_edit_error:"由于网络原因编辑失败",redirect_to_summary:"重定向页面至$1 // Wikiplus",redirect_from_summary:"将$1重定向至$2 // Wikiplus",need_init:"页面类未加载完成",fail_to_get_wikitext:"无法获得页面文本",quickedit_topbtn:"快速编辑",quickedit_sectionbtn:"快速编辑",fail_to_init_quickedit:"无法加载快速编辑",back:"返回",goto_editbox:"到编辑框",summary_placehold:"请输入编辑摘要",submit:"提交",publish_page:"发布页面",publish_change:"发布更改",preview:"预览",cancel:"取消",mark_minoredit:"标记为小编辑",onclose_confirm:"[Wikiplus] 您确认要关闭/刷新页面吗？这会导致您的编辑数据丢失",fail_to_get_wikitext_when_edit:"无法获得页面文本以编辑",cant_parse_wikitext:"无法解析维基文本",loading_preview:"正在读取预览",submitting_edit:"正在提交编辑",edit_success:"编辑成功 用时$1ms",empty_page_confirm:"您向编辑函数传入了空内容参数 这将清空页面\r\n由于该行为危险 请将config参数的empty键值设定为true来确认",cross_page_edit:"编辑目标位于其他页面 正在获取基础信息",cross_page_edit_submit:"基础信息获取成功 正在提交编辑",cross_page_edit_error:"无法获得基础信息>.<",install_tip:"您是否允许Wikiplus采集非敏感数据用于改进Wikiplus及为当前Wiki：$1提供改进建议？",accept:"接受",decline:"拒绝",install_finish:"Wikiplus安装完毕",loading:"正在载入",cant_add_funcbtn:"无法增加功能按钮",wikiplus_settings:"Wikiplus设置",wikiplus_settings_desc:"请在下方按规范修改Wikiplus设置",wikiplus_settings_placeholder:"当前设置为空 请在此处按规范修改Wikiplus设置",wikiplus_settings_grammar_error:"设置存在语法错误 请检查后重试",wikiplus_settings_saved:"设置已保存",redirect_from:"将页面重定向至此",redirect_desc:"请输入要重定向至此的页面名",empty_input:"输入不能为空",redirect_saved:"重定向完成",uninited:"Wikiplus未加载完毕 请刷新重试",cant_parse_i18ncache:"无法解析多语言定义文件缓存",cant_load_language:"无法获取多语言定义文件",history_edit_warning:" // 正试图编辑历史版本 这将会应用到本页面的最新版本 请慎重提交",create_page_tip:"","continue":"仍然继续",default_summary_suffix:"// Edit via Wikiplus",cross_page_history_revision_edit_warning:"暂不支持历史版本跨页面编辑"},e["en-us"]={__language:"en-us",__author:["Eridanus Sora","AnnAngela","YinYan"],__version:"212",unknown_error_name:"Unknown error",api_unaccessiable:"API of this wiki is not available",api_unwriteable:"Write API of this wiki is not available",fail_to_get_timestamp:"Failed to get the timestamp of this page.",fail_to_get_edittoken:"Failed to get the EditToken of this page.",fail_to_get_pageinfo:"Failed to load infomation of this page",not_autoconfirmed_user:"You are not an autoconfiremd user",hit_abusefilter:"Your edit hit the abusefilter(s)",unknown_edit_error:"Unknown edit error",unknown_edit_error_message:"Unknown edit error($1)",notitle:"The title parameter must be set",notext:"The text parameter must be set",notoken:"The token parameter must be set",invalidsection:"The section parameter must be set to an integer or 'new'",protectedtitle:"This title has been protected from creation",cantcreate:"You don't have permission to create new pages",cantcreate_anon:"Anonymous users can't create new pages",articleexists:"The article you tried to create has already existed",noimageredirect_anon:"Anonymous users can't create image redirects",noimageredirect:"You don't have the permission to create image redirects",spamdetected:"Your edit was rejected because it contained a spam fragment",filtered:"The filter callback function rejected your edit",contenttoobig:"The content you submitted exceeds the article size limit",noedit_anon:"Anonymous users can't edit pages",noedit:"You don't have the permission to edit pages",pagedeleted:"The page was deleted during your edit",emptypage:"Creating new, empty pages is not allowed",emptynewsection:"Creating empty new sections is not possible.",editconflict:"Edit Conflict! Don't panic. Please check the difference between your content below and the existing revision, then refresh the page to make another submit",revwrongpage:"The revision you are editing now is not one a valid reversions of this page",undofailure:"Undo failed due to conflicts.",missingtitle:"Missing title in your edit/creation",mustbeposted:"The edit must be submited by POST method",readapidenied:"Read API Denied",writeapidenied:"Write API Denied",noapiwrite:"No available write API in this wiki",badtoken:"Invalid EditToken",missingparam:"One of the parameters title, pageid is required",invalidparammix:"The parameters title, pageid can not be used together",invalidtitle:"Invalid page title",nosuchpageid:"Inexistent page ID",pagecannotexist:"No access to create a new page in this namespace",nosuchrevid:"Inexisting reversion ID",badmd5:"Invalid MD5",hookaborted:"Your edit was rejected by the hook(s)",parseerror:"Failed to parse the wikitext of this page",summaryrequired:"No summary in your edit",blocked:"You have been already BLOCKED",ratelimited:"You've exceeded your rate limit. Please have a tea and try again later",unknownerror:"Unknown error",nosuchsection:"There is no such section",sectionsnotsupported:"Can't edit in this section",editnotsupported:"Can't edit in this section by writing section",appendnotsupported:"Can't append/prepend wikitext to this page",redirect_appendonly:"Only append/prepend can be made to this page because of the rules of the redirect page",badformat:"The requested serialization format can not be applied to the page's content model",customcssprotected:"You're not allowed to edit custom CSS pages",customjsprotected:"You're not allowed to edit custom JavaScript pages",cascadeprotected:"This page is under a cascading protection",network_edit_error:"Failed to edit this page because of network errors",redirect_to_summary:"Redirect to $1 // Wikiplus",redirect_from_summary:"Redirect $1 to $2 // Wikiplus",need_init:"Wikiplus haven't been loaded completely. It's a rare occasion so you can try to refresh and try again.",fail_to_get_wikitext:"Failed to load the wikitext of this page",quickedit_topbtn:"QuickEdit",quickedit_sectionbtn:"QuickEdit",fail_to_init_quickedit:"Failed to initialize Wikiplus",back:"Back",goto_editbox:"Jump to editbox",summary_placehold:"Edit summary",submit:"Submit",publish_page:"Publish Page",publish_change:"Publish Changes",preview:"Preview",cancel:"Cancel",mark_minoredit:"Mark this edit as a minor edit",onclose_confirm:"[Wikiplus] Do you really want to close this page when you are still editing it, as you will lose all your unsaved work?",fail_to_get_wikitext_when_edit:"Failed to load wikitext for your edit",cant_parse_wikitext:"Failed to parse the wikitext",loading_preview:"Loading the preview",submitting_edit:"Submitting your edit",edit_success:"Your edit is submitted within $1ms",empty_page_confirm:'The wikitext in your edit is empty, which will empty this page.\r\nPlease set the value of key "empty" true to allow this kind of edits. (This is a tip for developers)',cross_page_edit:"The content you are editing belongs to another page, please wait...",cross_page_edit_submit:"Submitting your edit...",cross_page_edit_error:"Failed to load the infomation",install_tip:"Do you allow Wikiplus to collect insensitive data to help us develop Wikiplus and provide feedback to current site: $1 ?",accept:"Yes",decline:"No",install_finish:"Wikiplus is installed, enjoy it",loading:"Loading",cant_add_funcbtn:"Failed to add buttons for Wikiplus",wikiplus_settings:"Wikiplus Setting",wikiplus_settings_desc:"Please modify your setting according to the standards below",wikiplus_settings_placeholder:"Your setting is empty, please modify your setting according to the documentation.",wikiplus_settings_grammar_error:"Syntax error in your setting",wikiplus_settings_saved:"Your settings have been saved",redirect_from:"Redirect from",redirect_desc:"Which page do you want to redirect here?",empty_input:"Empty input",redirect_saved:"Redirection is finished",uninited:"Wikiplus is not completely initialized, please refeash this page",cant_parse_i18ncache:"Failed to parse the cache of i18n file",cant_load_language:"Failed to load i18n file",history_edit_warning:" // You are trying to edit a history revision of this page. This will apply to the latest revision. Please be careful.",create_page_tip:"","continue":"Continue anyway",default_summary_suffix:"// Edit via Wikiplus",cross_page_history_revision_edit_warning:"Cross-page edit in history revision is not supported yet."};var g=function{function a{var b=arguments.length<=0||void 0===arguments[0]?window.mw.config.get("wgPageName"):arguments[0];return _classCallCheck(this,a),console.log("页面类构建中"),window.mw?window.mw.config.get("wgUserGroups").includes("autoconfirmed")||window.mw.config.get("wgUserGroups").includes("confirmed")?(this.pageName=b.replace(/ /gi,"_"),this.revisionId=window.mw.config.get("wgRevisionId"),this.articleId=window.mw.config.get("wgArticleId"),this.API=location.protocol+"//"+location.host+window.mw.config.get("wgScriptPath")+"/api.php",this.editToken={},this.timeStamp={},void this.init(this.pageName,{success:function{console.log("Wikiplus加载完毕")},fail:function(a){console.log("Wikiplus未能正确加载("+a.message+")")}})):void d("not_autoconfirmed_user"):void console.log("页面JavaScript载入不完全或这不是一个MediaWiki站点")}return _createClass(a,[{key:"reConstruct",value:function(a){var b=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];this.init(a,b)}},{key:"init",value:function(a,b,c){void 0===a&&(a=this.pageName),void 0===b&&(b={});var e=this;b.success=b.success||new Function,b.fail=b.success||new Function,$.ajax({type:"GET",dataType:"json",url:this.API,data:{action:"query",prop:"revisions|info",titles:a,rvprop:"timestamp",format:"json"},beforeSend:function(a){a.setRequestHeader("Api-User-Agent","Wikiplus/2 ("+mw.config.get("wgWikiID")+")"),console.time("获得页面基础信息时间耗时")},success:function(c){if(c&&c.query&&c.query.pages){var f=c.query.pages;for(var g in f)"-1"!==g?(f[g].revisions&&f[g].revisions.length>0?e.timeStamp[a]=f[g].revisions[0].timestamp:b.fail(d("fail_to_get_timestamp")),mw.user.tokens.get("csrfToken")&&"+\\"!==mw.user.tokens.get("csrfToken")?(e.editToken[a]=mw.user.tokens.get("csrfToken"),console.log("成功获得编辑令牌 来自前端API")):($.ajax({url:e.API,type:"GET",dataType:"json",data:{action:"query",meta:"tokens",format:"json"},beforeSend:function(a){a.setRequestHeader("Api-User-Agent","Wikiplus/2 ("+mw.config.get("wgWikiID")+")")},success:function(c){c.query&&c.query.tokens&&c.query.tokens.csrftoken&&"+\\"!==c.query.tokens.csrftoken?(e.editToken[a]=c.query.tokens.csrftoken,console.log("成功获得编辑令牌 通过后端API")):b.fail(d("fail_to_get_edittoken"))},error:function(a){b.fail(d("fail_to_get_edittoken"))}}),b.fail(d("fail_to_get_edittoken")))):0===mw.config.get("wgArticleId")?mw.user.tokens.get("csrfToken")&&"+\\"!==mw.user.tokens.get("csrfToken")?(e.editToken[a]=mw.user.tokens.get("csrfToken"),console.log("成功获得编辑令牌 来自前端API"),e.inited=!0):(e.inited=!1,b.fail(d("fail_to_get_edittoken"))):(e.inited=!1,b.fail(d("fail_to_get_pageinfo")))}}}).done(function{console.timeEnd("获得页面基础信息时间耗时"),e.inited=e.inited===!1?!1:!0,b.success})}},{key:"edit",value:function(a){var c=arguments.length<=1||void 0===arguments[1]?this.pageName:arguments[1],e=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],f=arguments.length<=3||void 0===arguments[3]?{}:arguments[3],g=this;return e.success=e.success||new Function,e.fail=e.fail||new Function,void 0===a&&!f.empty==!0?(e.fail(d("empty_page_confirm")),!1):void(g.inited?$.ajax({type:"POST",url:g.API,data:$.extend({action:"edit",format:"json",text:a,title:c,token:g.editToken[c]||g.editToken[g.pageName],basetimestamp:g.timeStamp[c]},f),beforeSend:function(a){a.setRequestHeader("Api-User-Agent","Wikiplus/2 ("+mw.config.get("wgWikiID")+")")},success:function(a){a&&a.edit?a.edit.result&&"Success"===a.edit.result?e.success:a.edit.code?e.fail(d("hit_abusefilter",b("hit_abusefilter")+":"+a.edit.info.replace("/Hit AbuseFilter: /ig","")+" "+a.edit.warning+" ")):e.fail(d("unknown_edit_error")):a&&a.error&&a.error.code?e.fail(d(a.error.code.replace(/-/gi,"_")),b("unknown_edit_error_message").replace(/\$1/gi,a.error.code)):a.code?e.fail(d("unknown_edit_error"),b("unknown_edit_error_message").replace(/\$1/gi,a.code)):e.fail(d("unknown_edit_error"))},error:function(a){e.fail(d("network_edit_error"))}}):e.fail(d("uninited")))}},{key:"editSection",value:function(a,b){var c=arguments.length<=2||void 0===arguments[2]?this.pageName:arguments[2],d=arguments.length<=3||void 0===arguments[3]?{}:arguments[3],e=arguments.length<=4||void 0===arguments[4]?{}:arguments[4];e.success=e.success||new Function,e.fail=e.fail||new Function,this.edit(b,c,e,$.extend({section:a},d))}},{key:"redirectTo",value:function(a){var c=arguments.length<=1||void 0===arguments[1]?this.pageName:arguments[1],d=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];d.success=d.success||new Function,d.fail=d.fail||new Function,this.edit("#REDIRECT "+a+"",c,d,{summary:b("redirect_to_summary").replace(/\$1/gi,a)})}},{key:"redirectFrom",value:function(a){var c=arguments.length<=1||void 0===arguments[1]?this.pageName:arguments[1],d=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],e=arguments.length<=3||void 0===arguments[3]?!1:arguments[3];d.success=d.success||new Function,d.fail=d.fail||new Function;var f={summary:b("redirect_from_summary").replace(/\$1/gi,a).replace(/\$2/gi,c)};e||(f.createonly="true"),this.edit("#REDIRECT "+c+"",a,d,f)}},{key:"getWikiText",value:function{var a=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],b=arguments.length<=1||void 0===arguments[1]?this.pageName:arguments[1],c=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];a.success=a.success||new Function,a.fail=a.fail||new Function,$.ajax({url:location.protocol+"//"+location.host+mw.config.get("wgScriptPath")+"/index.php",type:"GET",dataType:"text",cache:!1,data:$.extend({title:b,action:"raw"},c),beforeSend:function(a){a.setRequestHeader("Api-User-Agent","Wikiplus/2 ("+mw.config.get("wgWikiID")+")"),console.time("获得页面文本耗时")},success:function(b){console.timeEnd("获得页面文本耗时"),a.success(b)},error:function(b){a.fail(d("fail_to_get_wikitext"))}})}},{key:"parseWikiText",value:function(a,b,c){void 0===a&&(a=""),void 0===b&&(b={}),b.success=b.success||new Function,b.fail=b.fail||new Function,$.ajax({type:"POST",dataType:"json",data:$.extend({format:"json",action:"parse",text:a,title:this.pageName,pst:"true"},c),beforeSend:function(a){a.setRequestHeader("Api-User-Agent","Wikiplus/2 ("+mw.config.get("wgWikiID")+")")},url:this.API,success:function(a){a&&a.parse&&a.parse.text?b.success(a.parse.text["*"]):b.fail(d("cant_parse_wikitext"))}})}}]),a};$(document).ready(function{var h=function{function h{_classCallCheck(this,h),this.version="2.3.10",this.langVersion="212",this.releaseNote="修正一些问题",this.notice=new MoeNotification,this.inValidNameSpaces=[-1,8964],this.defaultSettings={key:"value",documatation:"https://zh.moegirl.org.cn/User:%E5%A6%B9%E7%A9%BA%E9%85%B1/Wikiplus/%E8%AE%BE%E7%BD%AE%E8%AF%B4%E6%98%8E"},console.log("正在加载Wikiplus "+this.version),$("head").append(" "),$("head").children(":last").attr({rel:"stylesheet",type:"text/css",href:f+"/wikiplus.css"}),this.preloadData={},this.checkInstall;var b=this.getSetting("language")&&this.getSetting("language").toLowerCase||window.navigator.language.toLowerCase;this.version!==localStorage.Wikiplus_Version&&(localStorage.Wikiplus_Version=this.version,this.notice.create.success("Wikiplus "+this.version),this.notice.create.success("zh-cn"===b?this.releaseNote:"Minor bug fixes")),void 0===e[b]&&a(b),!this.inValidNameSpaces.includes(mw.config.get("wgNamespaceNumber"))&&mw.config.get("wgIsArticle")&&"view"===mw.config.get("wgAction")?(this.kotori=new g,this.checki18nCache,this.initBasicFunctions):console.log("不符合加载条件 Wikiplus终止")}return _createClass(h,[{key:"initQuickEdit",value:function{var a=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=this,f=function{mw.config.get("wgUserGroups").includes("autoconfirmed")||mw.config.get("wgUserGroups").includes("confirmed")||((new MoeNotification).create.error(c("not_autoconfirmed_user").message),d("not_autoconfirmed_user"))};if(a.success=a.success||new Function,a.fail=a.fail||new Function,!mw.config.get("wgIsArticle")||"view"!==mw.config.get("wgAction")||!mw.config.get("wgIsProbablyEditable"))return void console.log("该页面无法编辑 快速编辑界面加载终止");var g=$("").attr("id","Wikiplus-Edit-TopBtn").append($(" ").append($("").attr("href","javascript:void(0)").text(""+b("quickedit_topbtn")))).data({number:-1,target:e.kotori.pageName});if("minerva"===mw.config.get("skin")&&($(g).css({"align-items":"center",display:"flex"}),$(g).find("span").addClass("page-actions-menu__list-item"),$(g).find("a").addClass("mw-ui-icon mw-ui-icon-element mw-ui-icon-wikimedia-edit-base20 mw-ui-icon-with-label-desktop").css("vertical-align","middle")),$("#ca-edit").length>0&&0===$("#Wikiplus-Edit-TopBtn").length?("minerva"===mw.config.get("skin")?$("#ca-edit").parent.after(g):$("#ca-edit").after(g),$("#Wikiplus-Edit-TopBtn").click(function{f,e.initQuickEditInterface($(this))})):0===$("#ca-edit").length&&d("fail_to_init_quickedit"),$(".mw-editsection").length>0){e.sectionMap={};var h="minerva"===mw.config.get("skin")?$(" ").append($("").addClass("Wikiplus-Edit-SectionBtn mw-ui-icon mw-ui-icon-element mw-ui-icon-wikimedia-edit-base20 edit-page mw-ui-icon-flush-right").css("margin-left","0.75em").attr("href","javascript:void(0)").attr("title",b("quickedit_sectionbtn"))):$(" ").append($(" ").addClass("mw-editsection-divider").text(" | ")).append($("").addClass("Wikiplus-Edit-SectionBtn").attr("href","javascript:void(0)").text(b("quickedit_sectionbtn")));$(".mw-editsection").each(function(a){try{var b,c=$(this).find("a").first.attr("href"),f=c.match(/&[ve]*section\=([^&]+)/)[1].replace(/T-/gi,"");if(c.match(/title=(.+?)&/))b=decodeURIComponent(c.match(/title=(.+?)&/)[1]);else{var g=new RegExp(mw.config.get("wgArticlePath").replace("$1","")+"(.+?)\\?");c.match(g)?b=decodeURIComponent(c.match(g)[1]):d("fail_to_init_quickedit")}var i=$(this).prev.clone;i.find(".mw-headline-number").remove;var j=i.text.trim;e.sectionMap[f]={name:j,target:b};var k=h.clone;k.find(".Wikiplus-Edit-SectionBtn").data({number:f,name:j,target:b}),"minerva"===mw.config.get("skin")?$(this).append(k):$(this).find(".mw-editsection-bracket").last.before(k)}catch(l){d("fail_to_init_quickedit")}}),$(".Wikiplus-Edit-SectionBtn").click(function{f,e.initQuickEditInterface($(this))})}}},{key:"initQuickEditInterface",value:function(a){var c=this,e=a.data("number"),f=a.data("target");if(this.kotori.inited){if(f!==c.kotori.pageName&&mw.config.get("wgCurRevisionId")!==mw.config.get("wgRevisionId"))return void this.notice.create.error(b("cross_page_history_revision_edit_warning"));if($(".noarticletext").length>0&&(this.preloadData[f+".-1"]=b("create_page_tip")),mw.config.get("wgCurRevisionId")===mw.config.get("wgRevisionId")){var g={};void 0===this.preloadData[f+"."+e]?(f===this.kotori.pageName&&(g.oldid=mw.config.get("wgRevisionId")),this.notice.create.success(b("loading")),this.preload(e,f,{success:function(b){a.data("content",b),c.notice.empty,c.displayQuickEditInterface(a)},fail:function(a){d("fail_to_get_wikitext_when_edit")}},g)):(a.data("content",c.preloadData[f+"."+e]),c.displayQuickEditInterface(a))}else this.notice.create.warning(b("history_edit_warning")),this.notice.create.success(b("loading")),this.preload(e,f,{success:function(d){a.data("content",d),c.notice.empty,c.displayQuickEditInterface(a,""+b("history_edit_warning"))},fail:function(a){d("fail_to_get_wikitext_when_edit")}},{oldid:mw.config.get("wgRevisionId")})}}},{key:"displayQuickEditInterface",value:function(a){var c=arguments.length<=1||void 0===arguments[1]?"":arguments[1],d=this,e=$(".noarticletext").length>0,f=a.data("number"),g=a.data("name"),h=a.data("target"),i=a.data("content"),j=d.getSetting("defaultSummary",{sectionName:g,sectionNumber:f,sectionTargetName:h});void 0===j&&(j=void 0===g?b("default_summary_suffix"):"/* "+g+" */ "+b("default_summary_suffix"));var k=$(document).scrollTop,l=$(" ").attr("id","Wikiplus-Quickedit-Back").addClass("Wikiplus-Btn").text(""+b("back")),m=$(" ").attr("id","Wikiplus-Quickedit-Jump").addClass("Wikiplus-Btn").append($("").attr("href","#Wikiplus-Quickedit").text(""+b("goto_editbox"))),n=$(" ").attr("id","Wikiplus-Quickedit"),o=$(" ").attr("id","Wikiplus-Quickedit-Preview-Output"),p=$(" ").attr("id","Wikiplus-Quickedit-Summary-Input").attr("placeholder",""+b("summary_placehold")),q=$(" ").attr("id","Wikiplus-Quickedit-Submit").text(b(e?"publish_page":"publish_change")+"(Ctrl+S)"),r=$(" ").attr("id","Wikiplus-Quickedit-Preview-Submit").text(""+b("preview")),s=$(" ").append($(" ").attr({type:"checkbox",id:"Wikiplus-Quickedit-MinorEdit"})).append($(" ").attr("for","Wikiplus-Quickedit-MinorEdit").text(b("mark_minoredit")+"(Ctrl+Shift+S)")).css({margin:"5px 5px 5px -3px",display:"inline"}),t=$(" ").append(l,m,o,n,p,$(" "),s,q,r);this.createDialogBox(""+b("quickedit_topbtn")+c,t,1e3,function{$("#Wikiplus-Quickedit").val(i),$("#Wikiplus-Quickedit-Summary-Input").val(j),$("#Wikiplus-Quickedit-Back").click(function{$(".Wikiplus-InterBox").fadeOut("fast",function{window.onclose=window.onbeforeunload=void 0,$(this).remove})});var a=$(" ").addClass("Wikiplus-Banner").text(""+b("loading_preview"));$("#Wikiplus-Quickedit-Preview-Submit").click(function{var b=$("#Wikiplus-Quickedit").val;$(this).attr("disabled","disabled"),$("#Wikiplus-Quickedit-Preview-Output").fadeOut(100,function{$("#Wikiplus-Quickedit-Preview-Output").html("").append(a),$("#Wikiplus-Quickedit-Preview-Output").fadeIn(100)}),$("html, body").animate({scrollTop:k},200),d.kotori.parseWikiText(b,{success:function(a){$("#Wikiplus-Quickedit-Preview-Output").fadeOut("100",function{$("#Wikiplus-Quickedit-Preview-Output").html(' '+a+" "),$("#Wikiplus-Quickedit-Preview-Output").fadeIn("100"),$("#Wikiplus-Quickedit-Preview-Submit").prop("disabled",!1)})}})}),$("#Wikiplus-Quickedit-Submit").click(function{var a=$("#Wikiplus-Quickedit").val,c=$("#Wikiplus-Quickedit-Summary-Input").val,e=(new Date).valueOf,g=$(" ").addClass("Wikiplus-Banner").text(""+b("submitting_edit")),i={summary:c};-1!==f&&(i.section=f),$("#Wikiplus-Quickedit-MinorEdit").is(":checked")?i.minor="true":i.notminor="true",$("#Wikiplus-Quickedit-Submit,#Wikiplus-Quickedit,#Wikiplus-Quickedit-Preview-Submit").attr("disabled","disabled"),$("html, body").animate({scrollTop:k},200),h===d.kotori.pageName?($("#Wikiplus-Quickedit-Preview-Output").fadeOut(100,function{$("#Wikiplus-Quickedit-Preview-Output").html("").append(g),$("#Wikiplus-Quickedit-Preview-Output").fadeIn(100)}),d.kotori.edit(a,h,{success:function{var a=(new Date).valueOf-e;$("#Wikiplus-Quickedit-Preview-Output").find(".Wikiplus-Banner").css("background","rgba(6, 239, 92, 0.44)"),$("#Wikiplus-Quickedit-Preview-Output").find(".Wikiplus-Banner").text((""+b("edit_success")).replace(/\$1/gi,a.toString)),d.sendStatistic(h,a),window.onclose=window.onbeforeunload=void 0,setTimeout(function{location.reload},500)},fail:function(a){console.log(a),$("#Wikiplus-Quickedit-Submit,#Wikiplus-Quickedit,#Wikiplus-Quickedit-Preview-Submit").prop("disabled",!1),$(".Wikiplus-Banner").css("background","rgba(218, 142, 167, 0.65)"),$(".Wikiplus-Banner").html(a.message)}},i)):($("#Wikiplus-Quickedit-Preview-Output").fadeOut(100,function{$("#Wikiplus-Quickedit-Preview-Output").html("").append(g.text(b("cross_page_edit"))),$("#Wikiplus-Quickedit-Preview-Output").fadeIn(100)}),d.kotori.reConstruct(h,{success:function{$(".Wikiplus-Banner").text(b("cross_page_edit_submit")),d.kotori.edit(a,h,{success:function{var a=(new Date).valueOf-e;$("#Wikiplus-Quickedit-Preview-Output").find(".Wikiplus-Banner").css("background","rgba(6, 239, 92, 0.44)"),$("#Wikiplus-Quickedit-Preview-Output").find(".Wikiplus-Banner").text((""+b("edit_success")).replace(/\$1/gi,""+a)),d.sendStatistic(h,a),window.onclose=window.onbeforeunload=void 0,setTimeout(function{location.reload},500)},fail:function(a){$("#Wikiplus-Quickedit-Submit,#Wikiplus-Quickedit,#Wikiplus-Quickedit-Preview-Submit").prop("disabled",!1),$(".Wikiplus-Banner").css("background","rgba(218, 142, 167, 0.65)"),$(".Wikiplus-Banner").text(a.message)}},i)},fail:function(a){$(".Wikiplus-Banner").css("background","rgba(218, 142, 167, 0.65)"),$(".Wikiplus-Banner").text(b("cross_page_edit_error"))}}))}),$("#Wikiplus-Quickedit,#Wikiplus-Quickedit-Summary-Input,#Wikiplus-Quickedit-MinorEdit").keydown(function(a){a.ctrlKey&&83===a.which&&(a.shiftKey&&$("#Wikiplus-Quickedit-MinorEdit").click,$("#Wikiplus-Quickedit-Submit").click,a.preventDefault,a.stopPropagation)}),$("#Wikiplus-Quickedit").keydown(function{window.onclose=window.onbeforeunload=function{return""+b("onclose_confirm")}}),"true"===d.getSetting("esc_to_exit_quickedit")&&$(document).keydown(function(a){27===a.which&&$("#Wikiplus-Quickedit-Back").click})})}},{key:"editSettings",value:function{var a=this;a.addFunctionButton(b("wikiplus_settings"),"Wikiplus-Settings-Intro",function{var c=$(" ").attr("id","Wikiplus-Setting-Input").attr("rows","10"),d=$(" ").addClass("Wikiplus-InterBox-Btn").attr("id","Wikiplus-Setting-Apply").text(b("submit")),e=$(" ").addClass("Wikiplus-InterBox-Btn").attr("id","Wikiplus-Setting-Cancel").text(b("cancel")),f=$(" ").append(c).append($(" ")).append(d).append(e); a.createDialogBox(b("wikiplus_settings_desc"),f,600,function{localStorage.Wikiplus_Settings?$("#Wikiplus-Setting-Input").val(localStorage.Wikiplus_Settings):$("#Wikiplus-Setting-Input").attr("placeholder",b("wikiplus_settings_placeholder")),$("#Wikiplus-Setting-Apply").click(function{var c=$("#Wikiplus-Setting-Input").val;try{c=JSON.parse(c)}catch(d){return void a.notice.create.error(b("wikiplus_settings_grammar_error"))}localStorage.Wikiplus_Settings=JSON.stringify(c),$(".Wikiplus-InterBox-Content").html("").append($(" ").addClass("Wikiplus-Banner").text(b("wikiplus_settings_saved"))),$(".Wikiplus-InterBox").fadeOut(300,function{$(this).remove})}),$("#Wikiplus-Setting-Cancel").click(function{$(".Wikiplus-InterBox").fadeOut(300,function{$(this).remove})})})})}},{key:"simpleRedirector",value:function{var a=this;a.addFunctionButton(b("redirect_from"),"Wikiplus-SR-Intro",function{var c=$(" ").addClass("Wikiplus-InterBox-Input"),d=$(" ").addClass("Wikiplus-InterBox-Btn").attr("id","Wikiplus-SR-Apply").text(b("submit")),e=$(" ").addClass("Wikiplus-InterBox-Btn").attr("id","Wikiplus-SR-Cancel").text(b("cancel")),f=$(" ").addClass("Wikiplus-InterBox-Btn").attr("id","Wikiplus-SR-Continue").text(b("continue")),g=$(" ").append(c).append($(" ")).append(d).append(e);a.createDialogBox(b("redirect_desc"),g,600,function{d.click(function{if(""!=$(".Wikiplus-InterBox-Input").val){var c=$(".Wikiplus-InterBox-Input").val;$(".Wikiplus-InterBox-Content").html(' '+b("submitting_edit")+" "),a.kotori.redirectFrom(c,a.kotori.pageName,{success:function{$(".Wikiplus-Banner").text(b("redirect_saved")),$(".Wikiplus-InterBox").fadeOut(300),location.href=mw.config.get("wgArticlePath").replace(/\$1/gi,c)},fail:function(d){$(".Wikiplus-Banner").css("background","rgba(218, 142, 167, 0.65)"),$(".Wikiplus-Banner").text(d.message),1018===d.number&&($(".Wikiplus-InterBox-Content").append($(" ")).append(f).append(e),f.click(function{$(".Wikiplus-InterBox-Content").html(' '+b("submitting_edit")+" "),a.kotori.redirectFrom(c,a.kotori.pageName,{success:function{$(".Wikiplus-Banner").text(b("redirect_saved")),$(".Wikiplus-InterBox").fadeOut(300),location.href=mw.config.get("wgArticlePath").replace(/\$1/gi,c)},fail:function(a){$(".Wikiplus-Banner").css("background","rgba(218, 142, 167, 0.65)"),$(".Wikiplus-Banner").text(a.message)}},!0)}),e.click(function{$(".Wikiplus-InterBox-Close").click}))}})}else a.showNotice.create.warning(b("empty_input"))}),$("#Wikiplus-SR-Cancel").click(function{$(".Wikiplus-InterBox").fadeOut(300,function{$(this).remove})})})})}},{key:"preloadEventBinding",value:function{var a=this;$("#toc").children("ul").find("a").each(function(b){$(this).mouseover(function{$(this).unbind("mouseover"),a.preload(b+1)})})}},{key:"checki18nCache",value:function{if(localStorage.Wikiplus_i18nCache)try{var b=JSON.parse(localStorage.Wikiplus_i18nCache);for(var c in b)b[c].__version===this.langVersion?e[b[c].__language]=b[c]:(console.log("多语言文件["+c+"]已经过期"),a(b[c].__language))}catch(f){d("cant_parse_i18ncache")}else localStorage.Wikiplus_i18nCache=JSON.stringify(e)}},{key:"editEveryWhere",value:function{var a=this;$("#mw-content-text a.external").each(function(a){for(var c,d=$(this).attr("href"),e=/(([^?&=]+)(?:=([^?&=]*))*)/g,f={};c=e.exec(d);)try{f[c[2]]=decodeURIComponent(c[3])}catch(g){f[c[2]]=c[3]}"edit"===f.action&&void 0!==f.title&&"new"!==f.section&&$(this).after($("").attr({href:"javascript:void(0)","class":"Wikiplus-Edit-EveryWhereBtn"}).text("("+b("quickedit_sectionbtn")+")").data({target:decodeURIComponent(f.title),number:f.section||-1}))}),$(".Wikiplus-Edit-EveryWhereBtn").click(function{a.initQuickEditInterface($(this))})}},{key:"createDialogBox",value:function{var a=arguments.length<=0||void 0===arguments[0]?"Dialog Box":arguments[0],b=arguments.length<=1||void 0===arguments[1]?$(" "):arguments[1],c=arguments.length<=2||void 0===arguments[2]?600:arguments[2],d=arguments.length<=3||void 0===arguments[3]?new Function:arguments[3];$(".Wikiplus-InterBox").length>0&&$(".Wikiplus-InterBox").each(function{$(this).remove});var e=window.innerWidth,f=window.innerHeight,g=Math.min(e,c),h=$(" ").addClass("Wikiplus-InterBox").css({"margin-left":e/2-g/2,top:$(document).scrollTop+.2*f,display:"none"}).append($(" ").addClass("Wikiplus-InterBox-Header").html(a)).append($(" ").addClass("Wikiplus-InterBox-Content").append(b)).append($(" ").text("×").addClass("Wikiplus-InterBox-Close"));$("body").append(h),$(".Wikiplus-InterBox").width(g),$(".Wikiplus-InterBox-Close").click(function{$(this).parent.fadeOut("fast",function{window.onclose=window.onbeforeunload=void 0,$(this).remove})});var i=function j(a){a.mousedown(function(b){var c=b.clientX,d=b.clientY,e=a.parent.offset.left,f=a.parent.offset.top;$(document).mousemove(function(b){a.parent.css({"margin-left":e+b.clientX-c,top:f+b.clientY-d})}),$(document).mouseup(function{a.unbind("mousedown"),$(document).unbind("mousemove"),$(document).unbind("mouseup"),j(a)})})};i($(".Wikiplus-InterBox-Header")),$(".Wikiplus-InterBox").fadeIn(500),d}},{key:"addFunctionButton",value:function(a,b,c){var e=$("").addClass("mw-list-item mw-list-item-js").attr("id",b),f=$("").attr("href","javascript:void(0);");e="minerva"===mw.config.get("skin")?e.addClass("toggle-list-item").append(f.addClass("toggle-list-item__anchor").append($(" ").addClass("mw-ui-icon mw-ui-icon-portletlink-"+b.toLowerCase)).append($(" ").addClass("toggle-list-item__label").text(a))):"vector"===mw.config.get("skin")?e.append(f.append($(" ").text(a))):e.append(f.text(a)),"minerva"===mw.config.get("skin")?$("#p-tb").length>0&&($("#p-tb").append(e),$("#"+b).click(c)):$("#p-cactions").length>0?($("#p-cactions ul").append(e),$("#"+b).find("a").click(c)):d("cant_add_funcbtn")}},{key:"preload",value:function{var a=arguments.length<=0||void 0===arguments[0]?-1:arguments[0],b=arguments.length<=1||void 0===arguments[1]?this.kotori.pageName:arguments[1],c=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],d=arguments.length<=3||void 0===arguments[3]?{}:arguments[3];c.success=c.success||new Function,c.fail=c.fail||new Function;var e=this;if(void 0!==d.oldid){if(this.preloadData[d.oldid+"."+a])return console.log("[修订版本"+d.oldid+"."+a+"]已经预读取 跳过本次预读取"),void c.success(this.preloadData[d.oldid+"."+a])}else if(this.preloadData[b+"."+a])return console.log("["+b+"."+a+"]已经预读取 跳过本次预读取"),void c.success(this.preloadData[b+"."+a]);this.kotori.getWikiText({success:function(f){void 0!==d.oldid?(e.preloadData[d.oldid+"."+a]=f,console.log("预读取[修订版本"+d.oldid+"."+a+"]成功")):(e.preloadData[b+"."+a]=f,console.log("预读取["+b+"."+a+"]成功")),c.success(f)},fail:function(e){void 0!==d.oldid?console.log("预读取[修订版本"+d.oldid+"."+a+"]失败"):console.log("预读取["+b+"."+a+"]失败:"+e.message),c.fail(e)}},b,$.extend({section:-1===a?"":a},d))}},{key:"sendStatistic",value:function(a,b){void 0===a&&(a=mw.config.get("wgPageName")),"True"===localStorage.Wikiplus_SendStatistics&&$.ajax({url:f+"/statistics/api/submit",type:"POST",dataType:"json",data:{wikiname:mw.config.get("wgSiteName"),usetime:b,username:mw.config.get("wgUserName"),pagename:a},success:function(a){}})}},{key:"checkInstall",value:function(a){var c=this;if(!localStorage.Wikiplus_Installed||"False"==localStorage.Wikiplus_Installed){var d=function{localStorage.Wikiplus_Installed="True",localStorage.Wikiplus_Version=c.version,localStorage.Wikiplus_StartUseAt=(new Date).valueOf,localStorage.Wikiplus_SrartEditCount=mw.config.get("wgUserEditCount"),localStorage.Wikiplus_Settings=JSON.stringify(c.defaultSettings),$(".Wikiplus-InterBox").fadeOut("fast",function{c.notice.create.success(b("install_finish")),$(this).remove})},e=$(" ").text(b("install_tip").replace(/\$1/gi,mw.config.get("wgSiteName"))).attr("id","Wikiplus-InterBox-Content"),f=$(" ").addClass("Wikiplus-InterBox-Btn").attr("id","Wikiplus-Setting-Apply").text(b("accept")),g=$(" ").addClass("Wikiplus-InterBox-Btn").attr("id","Wikiplus-Setting-Cancel").text(b("decline")),h=$(" ").append(e).append($(" ")).append(f).append(g);c.createDialogBox("安装Wikiplus",h,600,function{$("#Wikiplus-InterBox-Content").css("text-align","left"),$("#Wikiplus-Setting-Apply").click(function{localStorage.Wikiplus_SendStatistics="True",d}),$("#Wikiplus-Setting-Cancel").click(function{localStorage.Wikiplus_SendStatistics="False",d})})}}},{key:"getSetting",value:function(a,b){var c=b;try{var d=JSON.parse(localStorage.Wikiplus_Settings)}catch(e){return localStorage.Wikiplus_Settings||""}try{var f=new Function("return "+d[a]);if("function"!=typeof f)return d[a];try{return f(c)===!0?void 0:f(c)||d[a]}catch(e){return d[a]}}catch(e){try{return d[a]}catch(e){return void 0}}}},{key:"initBasicFunctions",value:function{var a=this;mw.hook("wikipage.content").add(function(b){"mw-content-text"===b.attr("id")&&(a.initQuickEdit,!a.getSetting("disableEditEveryWhere")&&a.editEveryWhere)}),this.editSettings,this.simpleRedirector,this.preloadEventBinding}},{key:"initRecentChangesPageFunctions",value:function{}},{key:"initAdvancedFunctions",value:function{}}]),h};window.Wikiplus=new h})});