User:Bluedeck/common.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
//警告:这些代码的质量非常不高,并且采用大量暗黑时期的JS特性,除非您是想图一乐,否则不要引用
if((window.wgUserName || mw.config.values.wgUserName) !== "Bluedeck") {
const message = "您启用的脚本包含了bluedeck的个人脚本,这个脚本不是为了让大家都能用而设计的,因此如果你要使用的话,会遇到各种各样的问题,包括可能会编辑掉Bluedeck的用户页面。因为这个原因,脚本已经被停用。如果你希望测试脚本中的一些功能,请您联系bluedeck,让他帮你port一些功能出来。但是其实可能性不大,因为目前这些脚本都是经过认证的屎山代码(TM),除非有特殊原因,不会再去动它。";
const message_2 = "如果您下定决心使用这个脚本,您可以通过复制粘贴脚本到自己的common.js,然后删掉检查Bluedeck用户名的if分支。请注意不要编辑掉了我的用户页面及子页面!!谢谢。";
console.log(message + message_2);
throw new Error(message + message_2);
}
(function(){
var load_special_edition = 0x000
if(load_special_edition)
importScript("User:Bluedeck/serve/blib-link-special-edition.js");
})();
window.lib_overdrive = 0;
window.lib_overdrive += 120000;
// Bluedeck 白色面板小工具 0.0.1
// 请勿在未咨询 Bluedeck 的情况下引用该脚本。
// 该脚本是一个未设计为可以公开引用的私人脚本,您的引用可能导致意外操作以及同您现有脚本的冲突。
// 请确保先咨询 Bluedeck 后引用脚本~
// 当您喜欢某项功能,您可以告知 Bluedeck 开发一个可引用的插件。Bluedeck 乐意开发有人愿意使用的插件。
importScript("User:Bluedeck/serve/ar-admin-2.js");
//importScript("User:Bluedeck/serve/confirm-logout.js"); // from tools
importScript("User:Bluedeck/serve/edit-conflict.js");
//importScript("User:Bluedeck/serve/edit-count.js"); // from tools
//importScript("User:Bluedeck/serve/easy-archive.js"); // from tools
importScript("User:Bluedeck/serve/return-from-library.js");
importScript("User:Bluedeck/serve/blib.js");
importScript("User:Bluedeck/serve/blib-link.js");
importScript("User:Bluedeck/serve/ar-auto-j.js");
importScript("User:Bluedeck/serve/super-blib.js");
//importScript("User:Bluedeck/haystack/sandbox.js");
importScript("User:Bluedeck/serve/blib-inverse.js");
importScript("User:Bluedeck/serve/blib-config-confirm-archive.js");
document.querySelector("#footer-info").insertAdjacentHTML("afterbegin", "<li>この版の版番:" + mw.config.values.wgRevisionId + "</li>")
var glb={};
glb.url = mw.config.values.wgServer;
glb.blrt = Math.round(60000/87); // blink rate
// 1000 = 60 rpm
// 682 = 88 rpm
// 690 = 87 rpm for kokoronashi utakotoba
// 667 = 90 rpm
// 429 = 140 rpm
// 858 = 70 rpm
// (piano versm:870)
var db={
u1:"<div id='bcontainer'></div>",// container
u2:"<div id='bscreen' onclick='closeWindow()'></div>",// screen
u3:"<div id='bwindow'></div>",// window
u4:"<span id='btrigger' onclick='lunchWindow()'>Alive</span>",// trigger
u5:{"position":"fixed","height":"100%","width":"100%","background":"#fff","opacity":"0.6","z-index":"10000","display":"none",},// style of screen
u6:{"position":"absolute","height":"auto","width":"65%","min-width":"200px","max-width":"1000px","min-height":"10px","left":"0","right":"0","margin":"auto","word-wrap":"break-word","background":"#fff","box-shadow":"0px 3px 11px #d7d7d7","z-index":"10001","display":"none",},// style of window
u7:{"position":"fixed","top":"3px","left":"3px","padding":"1px 6px","border-radius":"3px","background":"#39f","box-shadow":"0px 0px 11px #ace","opacity":"0.3","color":"#fff","font-size":"smaller","z-index":"9999",},// style of trigger
u8:{"max-height":"85px","width":"500px","overflow-y":"auto","overflow-x":"auto","white-space":"nowrap","background":"#f7f7f7","padding":"10px","font-size":"60%",},
u9:{"font-size":"80%","background":"#666","border-radius":"99px","color":"#fff","padding":"0px 3px",},
s0:"artres_record",
s1:"counter",
s2:"page_tag",
s3:"general_record",
s4:"index",
};
function StartUp()
{
document.getElementsByTagName("body")[0].insertAdjacentHTML("afterbegin",db.u1+db.u2+db.u3+db.u4);
for(var x in db.u5){document.getElementById("bscreen").style[x]=db.u5[x];};
for(var x in db.u6){document.getElementById("bwindow").style[x]=db.u6[x];};
for(var x in db.u7){document.getElementById("btrigger").style[x]=db.u7[x];};
blinkTrigger(1);
app_articleRescue_toggle_initializer();
app_articleRescue_archiver_initializer();
}
function blinkTrigger(a)
{
if(a){document.getElementById("btrigger").style.color="#39f";setTimeout("blinkTrigger(0)",glb.blrt);}
else {document.getElementById("btrigger").style.color="#fff";setTimeout("blinkTrigger(1)",glb.blrt);}
}
function showWindow(content)
{
closeWindow();
document.getElementById("bscreen").style.display="block";
document.getElementById("bwindow").style.display="block";
document.getElementById("bwindow").style.top=(50+document.body.scrollTop)+"px";
document.getElementById("bwindow").innerHTML=content;
ding("today's token: " + randomPasswordGen("0x0").join("-"));
}
function closeWindow()
{
document.getElementById("bwindow").style.display="none";
document.getElementById("bscreen").style.display="none";
}
StartUp();
//-----------------------------------------standardized-ui-code-until-this-line-----------------------------------------
//-----------------------------------------specified-ui-code-and-soreni-tsuiteno-action-----------------------------------------
function getValue(a)
{
if(a==0){return el("topinput").value;}
if(a==1){return el("maininput").value;}
if(a==2){return el("bottominput").value;}
}
function outputValue(a,b)
{
if(a==0){el("topinput").value=b;}
if(a==1){el("maininput").value=b;}
if(a==2){el("bottominput").value=b;}
}
function replyDashpanelContent()
{
return ['<div style="padding:35px"><table style="width:100%">',
'<tr><td>arc</td><td><button onclick="DS(301)">normal</button><button onclick="DS(302)">artres-</button><button onclick="DS(303)">himitsu</button></td></tr>',
'<tr><td>title</td><td><button onclick="DS(401)">thispage</button><button onclick="DS(405)">bldklib</button><input id="topinput" style="width:300px"></input><button onclick="DS(402)">go</button><button onclick="DS(403)">go hist</button></td></tr>',
'<tr><td>csd gx</td><td><button onclick="DS(101)">g1</button><button onclick="DS(102)">g2</button><button onclick="DS(103)">g3</button><button onclick="DS(105)">g5</button><button onclick="DS(108)">g8</button><button onclick="DS(110)">g10</button><button onclick="DS(111)">g11</button><button onclick="DS(113)">g13</button><button onclick="DS(115)">g15</button></td></tr>',
'<tr><td>csd xx</td><td><button onclick="DS(122)">r2</button><button onclick="DS(123)">r3</button><button onclick="DS(131)">o1</button><button onclick="DS(134)">o4</button><button onclick="DS(141)">a1</button><button onclick="DS(145)">a5</button><button onclick="DS(201)">use summary</button><button onclick="DS(202)">del from area</button></td></tr>',
'<tr><td>go</td><td><button onclick="DS(701)">new box</button><button onclick="DS(702)">vfd</button><button onclick="DS(703)"> / </button><button onclick="DS(704)">utalk</button><button onclick="DS(705)">vpp</button><button onclick="DS(706)">pref</button><button onclick="DS(707)">707</button><button onclick="DS(708)">708</button><button onclick="DS(709)">709</button><button onclick="DS(710)">710</button><button onclick="DS(711)">711</button></td></tr>',
'<tr><td onclick="DS(801)">area</td><td><textarea id="maininput" style="width:100%" rows="5"></textarea></td></tr>',
'<tr><td>summary</td><td><input id="bottominput" style="width:300px"></input></td></tr>',
'<tr><td>edit</td><td><button onclick="DS(501)">reload</button><button onclick="DS(502)">perform edit</button><button onclick="DS(503)">regu for lib</button><button onclick="DS(504)">put to lib</button></td></tr>',
'<tr><td>other</td><td><button onclick="DS(601)">ar perform list</button><button onclick="DS(602)">dis-display-for-me</button><button onclick="DS(603)">flood+</button><button onclick="DS(604)">flood-</button></td></tr>',
'<tr><td>log <span id="logcount">0</span></td><td><div id="ding"></div></td></tr>',
'</table></div>'].join("");
}
function lunchWindow()
{
showWindow(replyDashpanelContent());
for(var x in db.u8){el("ding").style[x]=db.u8[x];};
for(var x in db.u9){el("logcount").style[x]=db.u9[x];};
loadTokenSilently();
outputValue(0,glb.p);
DS(501);
}
function DS(a) // Dashpanel Socket direct calling name
{
switch(Math.floor(a/100))
{
case 1: // CSD
{
var deletereasons={101:"[[WP:CSD#G1|G1]]: 无实际内容",102:"[[WP:CSD#G2|G2]]: 测试页面",103:"[[WP:CSD#G3|G3]]: 破坏",105:"[[WP:CSD#G5|G5]]: 历史存废",108:"[[WP:CSD#G8|G8]]: 技术原因",110:"[[WP:CSD#G10|G10]]: 作者请求",111:"[[WP:CSD#G11|G11]]: 广告",113:"[[WP:CSD#G13|G13]]: 机器翻译",115:"[[WP:CSD#G15|G15]]: 孤立页面",122:"[[WP:CSD#R2|R2]]: 跨NS重定向",123:"[[WP:CSD#R3|R3]]: 错误重定向",131:"[[WP:CSD#O1|O1]]: 用户请求",134:"[[WP:CSD#O4|O4]]: 空的分类",141:"[[WP:CSD#A1|A1]]: 无实际内容",145:"[[WP:CSD#A5|A5]]: 重复"};
deletePage(getValue(0),deletereasons[a],takeToken());
break;
}
case 2: // arbit-reason deletion & mass deletion
{
if(a===201){deletePage(getValue(0),getValue(2),takeToken());}
if(a===202){app_massDelete(buildList(getValue(1)),getValue(2));}
break;
}
case 3: // talk archive
{
if(a===301){app_talkArchive();appendDb("general_record",[Date.now().toString(),"talk archived"]);}
if(a===302){editPro(glb.ut,"1","","Artres-",takeToken());appendDb("general_record",[Date.now().toString(),"talk archived (ar)"]);}
if(a===303){editPro(glb.ut,"1","","Message Deleted Upon Request",takeToken());appendDb("general_record",[Date.now().toString(),"talk archived (del)"]);}
break;
}
case 4: // ui-ni-tsuite-actions
{
if(a===401){outputValue(0,glb.p);}
if(a===402){window.open(glb.url+"/wiki/"+getValue(0));}
if(a===403){window.open(glb.url+"/w/index.php?action=history&title="+getValue(0));}
if(a===405){outputValue(0,"user:bluedecklibrary/"+getValue(0))}
break;
}
case 5: // edit
{
if(a===501){loadPageIntoBox();}
if(a===502){edit(getValue(0),getValue(1),getValue(2),takeToken());}
if(a===503){outputValue(1, regulate_for_library(getValue(1)))}
if(a===504){DS(503);DS(405);DS(502);}
break;
}
case 6: // article rescue
{
if(a===601){app_massArticleRescue();}
if(a===602){dont_show_for_me();}
if(a===603){addRights(glb.un, "flood", "flood", glb.userrightstoken);}
if(a===604){removeRights(glb.un, "flood", "flood", glb.userrightstoken);}
break;
}
case 7: // let's go places ~
{
if(a===701){outputValue(0,glb.u+"/etc/sandbox/box"+Math.floor(Date.now()/1000));}
else if(a===706){outputValue(0,"user:bluedeck/common.js");DS(501);}
else if(a===707){outputValue(0,"user:bluedeck/etc/sandbox/box1525301626707");DS(501);}
else if(a===708){outputValue(0,"user:bluedeck/etc/sandbox/box1525301626708");DS(501);}
else if(a===709){outputValue(0,"user:bluedeck/etc/sandbox/box1525301626709");DS(501);}
else if(a===710){outputValue(0,"user:bluedeck/etc/sandbox/box1525301626710");DS(501);}
else if(a===711){outputValue(0,"user:bluedeck/etc/sandbox/box1525301626711");DS(501);}
else
{
var places={702:"Wikipedia:頁面存廢討論/積壓投票",703:"user:bluedeck/",704:"user talk:bluedeck",705:"Wikipedia:互助客栈"};
outputValue(0,places[a]);
}
break;
}
case 8: // get line number
{
if(a===801){alert(buildList(getValue(1)).length+","+(buildList(getValue(1)).length)*2+","+(buildList(getValue(1)).length)*3);}
}
}
}
function loadPageIntoBox()
{
var a=getValue(0);
el("maininput").rows="15";
outputValue(2,Date.now());
var f=function(){if(this.readyState===4){outputValue(1,pickPageContent(this.responseText));ding("Following page loaded into area: "+a);}}
getPage(a,f)
}
function preparePageData()
{
if(mw)
{
glb.p=mw.config.values.wgPageName;
glb.un=mw.config.values.wgUserName;
glb.u="User:"+mw.config.values.wgUserName;
glb.ut="User_talk:"+mw.config.values.wgUserName;
}
glb.t=undefined;
glb.a=glb.url+"/w/api.php";
loadTokenSilently();
}
//-----------------------------------------specified-ui-code-and-soreni-tsuiteno-actions-until-this-line----------------------------------------
//-----------------------------------------miscellaneous----------------------------------------
function buildList(a)
{
if(a==""){return [];}
return a.split("\n");
}
function el(a)
{
return document.getElementById(a);
}
function replaceString(a,b,c)
{
return a.split(b).join(c);
}
function replaceString_regulateHTML(a)
{
return replaceString(replaceString(replaceString(replaceString(replaceString(a,"&","&"),"<","<"),"'","'"),'"',"""),">",">");
}
function replaceString_regulateWikitext(a)
{
return replaceString(replaceString(replaceString(replaceString(replaceString(a,"<","<"),"{{","<nowiki>{{</nowiki>"),"~~","~<!---->~"),"[[","[[:"),"[[::","[[:");
}
function reverseArray(a)
{
var b=[];
for(var i=0;i<a.length;i++)
{
b[a.length-i-1]=a[i];
}
return b;
}
function ding(a,b) // ding(a) : display a normal message (a)
{
if(!el("ding")){console.log(a);return;}
var c="",d="",e="";
if(b===0){el("ding").innerHTML="";} // ding(a,0) : clear the ding console and post (a)
if(b===1){c="<span style='color:#999'>";d="</span>"} // ding(a,1) : display a gray message (a)
if(b===4294967296){e=a;} // ding(a,4294967296) : display a real HTML message (RIIIISKYYYYY)
el("ding").innerHTML=c+replaceString_regulateHTML(a)+d+e+"<br />"+el("ding").innerHTML;
el("logcount").innerHTML++;
}
function tellTag(a)
{
var b = a.split("");
for(var i=0;i<b.length;i++)
{
b[i] = b[i].charCodeAt(0);
b[i] = b[i]%256;
}
var c = SHA256(b);
for(i=0;i<c.length;i++)
{
c[i]=c[i].toString(16);
if(c[i].length<2)
{
c[i]="0"+c[i];
}
}
return c.join("");
}
function tellTag_sdsName(a)
{
return "user:bluedeck/sds/"+tellTag(a)+".sds";
}
function tellTag_tempJsonName(a)
{
return "user:bluedeck/etc/temp/"+tellTag(a)+".js";
}
function tellTag_gadgetName(a)
{
return "user:bluedeck/serve/"+tellTag(a)+".js";
}
var eur=encodeURIComponent;
var requests=new Array();
preparePageData();
//-----------------------------------------miscellaneous-until-this-line---------------------------------------
//-----------------------------------------http-requests---------------------------------------
function asyncGet(url,fn)
{
var a=new XMLHttpRequest();
requests=requests.concat(a);
a.onreadystatechange=fn;
a.open("GET",url,true);
a.send(null);
return (requests.length-1);
}
function asyncPost(url,body,fn)
{
var z1="Content-Type";
var z2="application/x-www-form-urlencoded";
var a=new XMLHttpRequest();
requests=requests.concat(a);
a.onreadystatechange=fn;
a.open("POST",url,true);
a.setRequestHeader(z1,z2);
a.send(body);
return (requests.length-1);
}
//-----------------------------------------http-requests-until-this-line---------------------------------------
//-----------------------------------------basics---------------------------------------
function loadTokenSilently()
{
var f=function(){
if(this.readyState===4){
glb.t=JSON.parse(this.responseText).query.tokens.csrftoken;
glb.userrightstoken=JSON.parse(this.responseText).query.tokens.userrightstoken;
}
};
var z="action=query&meta=tokens&format=json&type=csrf|userrights";
asyncPost(glb.a,z,f);
setTimeout("loadTokenSilently()",1800000);
}
function takeToken()
{
if(glb.t)
{
return glb.t;
}
else
{
loadTokenSilently();
return false;
}
}
function getPage(a,fn) // a: pagename / fn: function for execution
{
ding("Requesting page: "+a,1);
var z="action=query&prop=revisions&rvprop=ids|flags|timestamp|user|userid|size|comment|tags|content&format=json&titles=";
asyncPost(glb.a,z+eur(a),fn);
}
function getPageSection(a,b,fn) // a: pagename / b: section id numeric / fn: function for execution
{
ding("Requesting page: "+a+" in section: "+b,1);
var z="action=query&prop=revisions&rvprop=content&format=json&titles=";
asyncPost(glb.a,z+eur(a)+"&rvsection="+eur(b),fn);
}
function getDeletedRevs(a,fn) // a: pagename / fn: function for execution
{
ding("Requesting deleted revisions for page: "+a,1);
var z="action=query&prop=deletedrevisions&format=json&drvprop=content|comment|user|userid|timestamp|size&drvlimit=500&titles=";
asyncPost(glb.a,z+eur(a),fn);
}
function pickPageContent(a)
{
if(typeof a==="string")
{
var b=JSON.parse(a);
if(typeof b==="object")
{
for(var x in b.query.pages)
{
var c=b.query.pages[x];
return c.revisions[0]["*"];
}
}
else
{
return false;
}
}
else // from now on pick functions will only work with string inputs. DO NOT parse pages before passing them into pick functions.
{
return false;
}
}
function tellPageExist(a)
{
if(typeof a==="string")
{
var b=JSON.parse(a);
if(typeof b==="object")
{
if(b.query.pages["-1"])
{
return true;
}
else
{
return false;
}
}
}
else // from now on tellPage functions will only work with string inputs. DO NOT parse pages before passing them into tellPage functions.
{
return false;
}
}
function edit(a,b,c,d,f)
{
ding("Requesting page edit for: "+a+" Summary: "+c,1);
if(!f){var f=function(){if(this.readyState===4){ding("Following page edited: "+a+" Detail: "+this.responseText)}};} // from now on, f is definable.
if(!d){var d=takeToken();}
var z="action=edit&minor=1&bot=1&format=json&title=";
asyncPost(glb.a,z+eur(a)+"&text="+eur(b)+"&summary="+eur(c)+"&token="+eur(d),f);
}
function editPro(a,b,c,d,e)
{
ding("Requesting page edit for: "+a+" in section: "+b+" Summary: "+d,1);
var f=function(){if(this.readyState===4){ding("Following page edited: "+a+" Section: "+b+" Detail: "+this.responseText)}};
var z="action=edit&minor=1&bot=1&format=json&title=";
asyncPost(glb.a,z+eur(a)+"§ion="+eur(b)+"&text="+eur(c)+"&summary="+eur(d)+"&token="+eur(e),f);
}
function editAppend(a,b,c,d,callback)
{
var f=function(){if(this.readyState===4){edit(a,pickPageContent(this.responseText)+""+b,c,d,callback)}};
getPage(a,f);
}
function movePage(a,b,c,d) // from, to, reason, token
{
ding("Requesting page move from: "+a+" to: "+b+" Summary: "+c,1);
var f=function(){if(this.readyState===4){ding("Following page moved: "+a+" Section: "+b+" Detail: "+this.responseText)}};
var z="action=move&minor=1&bot=1&format=json&watchlist=watch&noredirect=&from=";
asyncPost(glb.a,z+eur(a)+"&to="+eur(b)+"&summary="+eur(c)+"&token="+eur(d),f);
}
function deletePage(a,b,c)
{
ding("Requesting deletion: "+a,1);
var f=function(){if(this.readyState===4){ding("Following page deleted: "+a+" Detail: "+this.responseText)}};
var z="action=delete&format=json&title=";
asyncPost(glb.a,z+eur(a)+"&reason="+eur(b)+"&token="+eur(c),f);
}
function createFlowMessage(a,b,c,d)
{
var f=function(){if(this.readyState===4){ding("Following page attached a flow: "+a+" Detail: "+this.responseText)}};
var z="action=flow&format=json&submodule=new-topic&page=";
asyncPost(glb.a,z+eur(a)+"&nttopic="+eur(b)+"&ntcontent="+eur(c)+"&ntformat=html&token="+eur(d),f);
}
function createDbByName(name,phase2)
{
var to = tellTag_sdsName(name);
if(!phase2)
{
getPage(to,function(){if(this.readyState===4){if(tellPageExist(this.responseText)){createDbByName(name,true)}else{ding("The DB you're attempting to create exists.")}}})
}
else
{
var from = tellTag_tempJsonName(name);
var content = "@meta\tname:"+name;
var f = function(){if(this.readyState===4){movePage(from,to,"SDS update",takeToken());}}
edit(from,content,"SDS update",takeToken(),f);
}
}
function appendDb(name,row) // row in the format of an array will be fine.
{
for(var i in row)
{
row[i]=cellify(row[i]);
}
editAppend(tellTag_sdsName(name),"\n"+row.join("\t"),"SDS update",takeToken());
}
function addRights(user, rights, sum, tok)
{
ding("Adding right", 1);
asyncPost(
glb.a,
"action=userrights&format=json&user="+eur(user)+"&add="+eur(rights)+"&reason="+eur(sum)+"&token="+eur(tok),
function () {
if (this.readyState === 4) ding("Right " + rights + " added to user " + user + ": " + this.responseText)
}
);
}
function removeRights(user, rights, sum, tok)
{
ding("Removing right", 1);
asyncPost(
glb.a,
"action=userrights&format=json&user="+eur(user)+"&remove="+eur(rights)+"&reason="+eur(sum)+"&token="+eur(tok),
function(){if(this.readyState === 4)ding("Right " + rights + " added to user " + user + ": " + this.responseText)}
);
}
//-----------------------------------------basics-until-this-line---------------------------------------
//-----------------------------------------apps---------------------------------------
function app_massDelete(s,r) // intakes an array (s) and a string (r) for reason.
{
for(var i=0;i<s.length;i++)
{
deletePage(s[i],r,takeToken());
}
}
function app_talkArchive(a)
{
if(a===undefined) // if this function is called as app_talkArchive(), execute the first step of the process.
{
var f=function(){if(this.readyState===4){app_talkArchive(this.responseText);}}
getPageSection(glb.ut,1,f); // call the function with a parameter (this.responseText);
}
else // if this function is called with a parameter, execute this second step.
{
editAppend(glb.u+"/bibliotek/usertalk/"+(new Date()).getFullYear().toString(),"\n\n"+pickPageContent(a),"ARC+",takeToken());
editPro(glb.ut,"1","","ARC-",takeToken());
}
}
function app_searchAndReplace(a,b,c,d)
{
getPage(a,function(){if(this.readyState===4){edit(a,replaceString(pickPageContent(this.responseText),b,c),d,takeToken())}});
}
function app_massSearchAndReplace(a,b,c,d) // a is an array this time.
{
for(var i=0;i<a.length;i++)
{
app_searchAndReplace(a[i],b,c,d);
}
}
function app_massSearchAndReplaceFromArea(b,c,d) // gets the list from the area, other things stay the same. b:change from, c: change to, d: summary
{
app_massSearchAndReplace(buildList(getValue(1)),b,c,d);
}
function app_articleRescue(a,data_array,data_array2,data_array3) // a: name of page to recover / data_array: please do not define it.
{
if((!data_array)&&(!data_array2)&&(!data_array3)) // this means that the function is called externally as app_articleRescue(a); start the initialization
{
var f=function()
{
var b=JSON.parse(this.responseText).query.pages;
for(var x in b){}
b=b[x].deletedrevisions;
b=reverseArray(b);
app_articleRescue(a,b,b,[]); // (a) carries pagename, data_array carries drv list and can be sliced, data_array2 carries complete drv list throughout, data_array3 carries updated revisions.
}
getDeletedRevs(a,f);
}
else if(data_array&&data_array2) // this means that the app is in the second phase till nth phase, called as app_articleRescue(a,b,b,x);
{
if(data_array.length>0) // this means that the app is between neither in the first phase nor the last phase.
{
var restargetname=glb.u+"/etc/articlerescue/2";
var f=function()
{
}
edit(restargetname,data_array[0]["*"],"drv query service: [[:"+a+"]]",takeToken());
data_array=data_array.slice(1);
app_articleRescue(a,data_array,data_array2);
}
else // last phase
{
var indexpagerecordlist=[];
for(var i=0;i<data_array2.length;i++)
{
}
}
}
}
function app_sync_old_articlerescue_list_only(pagename) // shikata nai~
{
var HISTORY_STORAGE_PAGE = "Wikipedia:已删除内容查询/查询/" + pagename;
var INDEX_STORAGE_PAGE = "Wikipedia:已删除内容查询/查询/" + pagename;
var PLACEHOLDER = "{" + "{CSD placeholder}}";
var FINAL_PLACEHOLDER = false;
var log_line = function(){console.log("------------------------------");};
console.log("starting sync artres procedure on " + pagename);
log_line();
var z="action=query&prop=deletedrevisions&format=json&drvprop=comment|user|userid|timestamp|size|ids&drvlimit=5000&titles=";
var prerevlist=JSON.parse(syncpost(glb.a,z+eur(pagename)));
var revlist=[];
var pre2revlist=[];
while(prerevlist["continue"])
{
pre2revlist=prerevlist.query.pages;
for(var x in pre2revlist){}
revlist=reverseArray(pre2revlist[x].deletedrevisions).concat(revlist);
prerevlist=JSON.parse(syncpost(glb.a,z+eur(pagename)+"&drvcontinue="+eur(prerevlist["continue"].drvcontinue)));
}
pre2revlist=prerevlist.query.pages;
for(var x in pre2revlist){}
revlist=reverseArray(pre2revlist[x].deletedrevisions).concat(revlist);
console.log(revlist.length+" DRVs fetched.");
log_line();
var indexpagecontentlist=[];
log_line();
syncedit(HISTORY_STORAGE_PAGE,PLACEHOLDER,"-");
console.log("Please wait while the index page is being created...");
syncedit(INDEX_STORAGE_PAGE,PLACEHOLDER,"-");
log_line();
for(var i=0;i<revlist.length;i++)
{
indexpagecontentlist[i]="\n<tr><td> "+revlist[i].timestamp.split("T").join(" ").split("Z").join("")+" </td><td> [[user talk:"+revlist[i].user+"|]] </td><td> "+revlist[i].size+" </td><td> "+revlist[i].revid+" </td><td> "+replaceString_regulateWikitext(revlist[i].comment)+"</td></tr>"
}
var finalrev=syncedit(INDEX_STORAGE_PAGE,"页面[[:"+pagename+"]]共有"+revlist.length+"个已删除版本,存档如下:\n----\n<table style='white-space:nowrap'><tr><td></td><td>'''编辑时分'''</td><td>'''用户'''</td><td>'''页面大小'''</td><td>'''版本号'''</td><td>'''编辑摘要'''</td></tr>"+reverseArray(indexpagecontentlist).join("")+"\n</table>\n----\n{"+"{subst:User:Bluedeck/infr/ar.thankyou.js}}","DRV lookup: [[:"+pagename+"]]");
FINAL_PLACEHOLDER ? syncedit(INDEX_STORAGE_PAGE,PLACEHOLDER,"-") : void null;
console.log("All done: "+JSON.parse(finalrev).edit.newrevid);
log_line();
return JSON.parse(finalrev).edit.newrevid;
}
function app_articleRescue_toggle_initializer()
{
var arr=document.getElementsByClassName("bluedeck-artres-artname");
for(var i=0;i<arr.length;i++)
{
arr[i].innerHTML = "<span style='padding:0 10px;' onclick='if(confirm(\"本当にこれを実行しますか?\")){this.innerHTML=app_sync_old_articlerescue(this.innerHTML);}'>"+arr[i].innerHTML+"</span>";
arr[i].style.display="inline";
}
}
function app_articleRescue_archiver_initializer()
{
return 0;
}
function app_old_article_rescue_shell(pagename)
{
var syncpost=function(url,body){var z1="Content-Type";var z2="application/x-www-form-urlencoded";var a=new XMLHttpRequest();a.open("POST",url,false);a.setRequestHeader(z1,z2);a.send(body);return a.responseText;}
var syncedit=function(e_page,e_content,e_summary){return syncpost(glb.a,"action=edit&minor=1&bot=1&format=json&title="+eur(e_page)+"&text="+eur(e_content)+"&summary="+eur(e_summary)+"&token="+eur(takeToken()));}
}
function app_massEdit(pagelist,content,summary)
{
for(var i=0;i<pagelist.length;i++)
{
edit(pagelist[i],content,summary,takeToken());
}
}
function app_multiCRfixer()
{
}
//-----------------------------------------apps-until-this-line---------------------------------------
//-----------------------------------------imported-functions--------------------------------------
// msg: CTR
// nopad: true for not padding the message according to the sha 256 standard.
// sha 384 and 512 not supported
// construction complete
// (implementation) author: bluedeck <bluedeck@outlook.com> published under CC-BY-SA 3.0
function SHA256(msg,nopad)
{
// st for state, bk for big K.
var st = [1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];
var bk = [1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];
var pp = function(m) // pre pad
{
// pad
var l = m.length*8;
m = m.concat(128);
while((m.length+8)%64!==0)
{
m = m.concat(0);
}
m = m.concat(0,0,0,0);
m = m.concat(((l>>24)>>>0)&255,((l>>16)>>>0)&255,((l>>8)>>>0)&255,((l>>0)>>>0)&255);
// divide by 512 bits or 64 bytes
var n = [];
for(var i=0;i<m.length/64;i++)
{
n[i] = [];
for(var j=0;j<64;j++)
{
n[i][j]=m[64*i+j];
}
}
// divide 1 block into 16 * 32 bits of messages
var p = [];
for(i=0;i<n.length;i++)
{
p[i]=[];
for(var j=0;j<n[i].length/4;j++)
{
p[i][j]=((n[i][4*j]<<24)|(n[i][4*j+1]<<16)|(n[i][4*j+2]<<8)|(n[i][4*j+3]));
}
}
return p;
};
var ms = function(b) // message schedule for one message block
{
var w = [];
for(var i=0;i<16;i++)
{
w[i] = b[i];
}
for(i=16;i<64;i++)
{
w[i] = pl(s1(w[i-2]),w[i-7],s0(w[i-15]),w[i-16]);
}
return w;
};
var cp = function(s,w) // compress
{
var a=s[0], b=s[1], c=s[2], d=s[3], e=s[4], f=s[5], g=s[6], h=s[7];
for(var i=0;i<64;i++)
{
x = pl(h,S1(e),ch(e,f,g),bk[i],w[i]);
y = pl(S0(a),mj(a,b,c));
h = g;
g = f;
f = e;
e = pl(d,x);
d = c;
c = b;
b = a;
a = pl(x,y);
}
return [pl(a,s[0]),pl(b,s[1]),pl(c,s[2]),pl(d,s[3]),pl(e,s[4]),pl(f,s[5]),pl(g,s[6]),pl(h,s[7])];
};
var ml = function() // main loop
{
var m = pp(msg);
var s = st;
for(i=0;i<m.length;i++)
{
s = cp(s,ms(m[i]));
}
return s;
};
var pl = function(a,b,c,d,e) // safe addition
{
if(!c)
{
c=0;
}
if(!d)
{
d=0;
}
if(!e)
{
e=0;
}
return (((((((a+b)%4294967296)+c)%4294967296)+d)%4294967296)+e)%4294967296;
};
var rt = function(a,b) // right rotate
{
return ((a>>>b)|(a<<(32-b)))>>>0;
};
var ch = function(x,y,z) // choice
{
return ((x&y)^((~x)&z))>>>0;
};
var mj = function(x,y,z) // majority
{
return ((x&y)^(x&z)^(y&z))>>>0;
};
var S0 = function(x) // Sigma 0
{
return (rt(x,2)^rt(x,13)^rt(x,22))>>>0;
};
var S1 = function(x) // Sigma 1
{
return (rt(x,6)^rt(x,11)^rt(x,25))>>>0;
};
var s0 = function(x) // sigma 0
{
return (rt(x,7)^rt(x,18)^(x>>>3))>>>0;
};
var s1 = function(x) // sigma 1
{
return (rt(x,17)^rt(x,19)^(x>>>10))>>>0;
};
var rg = function(a) // c08 from c32
{
var b = [];
for(var i=0;i<8;i++)
{
b = b.concat(((a[i]>>24)>>>0)&255,((a[i]>>16)>>>0)&255,((a[i]>>8)>>>0)&255,((a[i]>>0)>>>0)&255);
}
return b;
};
if(!nopad)
{
return rg(ml());
}
}
function dont_show_for_me()
{
var hide_list = document.getElementsByClassName("display-for-me");
for(var i=0; i<hide_list.length; i++)
{
hide_list[i].className = hide_list[i].className.split("display-for-me").join("");
hide_list[i].style.display = "none";
}
}
function regulate_for_library(wtext)
{
return "{" + "{user:bluedeck/infr/library.card.js|${getValue(0)}|time=${new Date().toISOString()}|jst=${Date.now()}|revid=${wgCurRevisionId}|pageid=${wgArticleId}}}".replace("${wgArticleId}", wgArticleId).replace("${wgCurRevisionId}", wgCurRevisionId).replace("${Date.now()}", Date.now()).replace("${new Date().toISOString()}", new Date().toISOString()).replace("${getValue(0)}", getValue(0)) + wtext.replace(/\{\{/g, "{{((}}").replace(/\[\[[Cc]ategory:/g, "[[:Category:");
}
var regulate_for_library_by_text = function(page_name, wiki_text)
{
return "{{user:bluedeck/infr/library.card.js|1=${page_name}|time=${new Date().toISOString()}|jst=${Date.now()}|revid=${wgCurRevisionId}|pageid=${wgArticleId}}}"
.replace("${wgArticleId}", wgArticleId)
.replace("${wgCurRevisionId}", wgCurRevisionId)
.replace("${Date.now()}", Date.now())
.replace("${new Date().toISOString()}", new Date().toISOString())
.replace("${page_name}", page_name)
+ wiki_text
.replace(/\{\{/g, "{{((}}")
.replace(/\[\[[Cc]ategory:/g, "[[:Category:")
.replace(/\[\[分类:/g, "[[:分类:")
.replace(/\[\[分類:/g, "[[:分類:");
};
var regulate_for_library_by_text_inverse = function(text) {
var card_start = text.indexOf("{{user:bluedeck/infr/library.card.js");
var card_end = text.substr(card_start).indexOf("}}") + card_start;
if(card_start !== -1 && card_end !== -1)
text = text.substr(0, card_start) + text.substr(card_end + 2);
return text
.replace(/\[\[\:分類\:/g, "[[分類:")
.replace(/\[\[\:分类\:/g, "[[分类:")
.replace(/\[\[\:Category\:/g, "[[Category:")
.replace(/\{\{\(\(\}\}/g, "{{");
}
function editPrepend(a,b,c,d){var f=function(){if(this.readyState===4){edit(a,b+""+pickPageContent(this.responseText),c,d)}};getPage(a,f);}
function randomPasswordGen(str) {
if(typeof(str) !== "string") str = "";
var tag = tellTag(str + JSON.stringify(mw.config.values) + Date.now().toString() + Math.random().toString());
return [tag.substr(0, 32), tag.substr(32)]
}
if(window.lib_overdrive && Date.now() < window.lib_overdrive)
{
setTimeout("document.getElementById('bluedeck_dom_blib_archive_link_228598fbbb33470ef75056179b3800c543c0d2187e708f3a70f0827ac48b5b3b').click()", 10000);
}