User:Stang/common.js

// Bluedeck Mediawiki Applet 0.1.2.x // 请勿在未咨询 Bluedeck 的情况下引用该脚本. // 该脚本是一个未设计为可以公开引用的私人脚本，您的引用可能导致意外操作以及同您现有脚本的冲突. // 请确保先咨询 Bluedeck 后引用脚本~ // 当您喜欢某项功能，您可以告知 Bluedeck 开发一个可引用的插件. Bluedeck 乐意开发有人愿意使用的插件.

importScript("user:bluedeck/serve/22a3c85609d4d626bc01cd87df71d01f6bb9a62efce214d37b0d4faf4f3ebb74.js");	// parse SDS

importScript("User:Bluedeck/serve/ar-auto-t.js");	//auto AR

var glb={};

glb.url = "https://zh.wikipedia.org"; 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:" ",// container u2:" ",// screen u3:" ",// window u4:"Alive ",// 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; }

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 [' '].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); }

function DS(a)		// Dashpanel Socket direct calling name {	switch(Math.floor(a/100)) {		case 1:		// CSD {			var deletereasons={101:"G1: 无实际内容",102:"G2: 测试页面",103:"G3: 破坏",105:"G5: 曾经存废删除后重建",108:"G8: 技术原因",110:"G10: 作者请求",111:"G11: 广告",113:"G13: 机器翻译",115:"G15: 孤立页面",122:"R2: 跨名字空间的重定向",123:"R3: 错误重定向",131:"O1: 用户请求",134:"O4: 空的分类",141:"A1: 无实际内容",145:"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===404){window.open(glb.url+"/wiki/"+tellTag_sdsName(getValue(0)));} break; }		case 5:		// edit {			if(a===501){loadPageIntoBox;} if(a===502){edit(getValue(0),getValue(1),getValue(2),takeToken);} break; }		case 6:		// article rescue {			if(a===601){app_massArticleRescue;} break; }		case 7:		// let's go places ~ {			if(a===701){outputValue(0,glb.u+"/etc/sandbox/box"+Date.now);} else if(a===706){outputValue(0,"user:bluedeck/common.js");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; }

function loadSdsAdminPanel {	document.getElementsByTagName("body")[0].innerHTML="loading..."; document.getElementsByTagName("body")[0].style.background="#fff"; f=function{if(this.readyState===4){document.getElementsByTagName("body")[0].innerHTML=pickPageContent(this.responseText)}} getPage("user:bluedeck/infr/sdsadmin.js",f); }

//-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,"&","&amp;"),"<","&lt;"),"'","&apos;"),'"',"&quot;"),">","&gt;"); }

function replaceString_regulateWikitext(a) {	return replaceString(replaceString(replaceString(replaceString(a,"<","&lt;"),"{{","{{"),"",""),"[[","[[:"); }

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=" ";d=" "}		// 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+" "+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; if(glb.p==="User:Bluedeck/etc/sdsadmin") {	loadSdsAdminPanel; } if(glb.p.slice(0,18)==="User:Bluedeck/sds/") {	el("firstHeading").innerHTML="SDS data file" }

//-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;}}; var z="action=query&meta=tokens&format=json"; 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)+"&section="+eur(b)+"&text="+eur(c)+"&summary="+eur(d)+"&token="+eur(e),f); }

function editAppend(a,b,c,d) {	var f=function{if(this.readyState===4){edit(a,pickPageContent(this.responseText)+""+b,c,d)}}; 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); }

//-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/2016","\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(pagename)		// shikata nai~ {	console.log("starting sync artres precedure"); console.log("--"); 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));} var z="action=query&prop=deletedrevisions&format=json&drvprop=content|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."); console.log("--"); var indexpagerevlist=[]; var indexpagecontentlist=[]; syncedit(glb.u+"/etc/articlerescue/2","{{user:bluedeck/infr/ph.js}}","-"); for(var i=0;i<revlist.length;i++) {		indexpagerevlist[i]=JSON.parse(syncedit(glb.u+"/etc/articlerescue/2",revlist[i]["*"],"DRV lookup: "+pagename+" - Author: user talk:"+revlist[i].user+" - Time: "+revlist[i].timestamp+" - Revision ID: "+revlist[i].revid)).edit.newrevid; if(!indexpagerevlist[i]){indexpagerevlist[i]=indexpagerevlist[i-1];} console.log("("+(i+1).toString+"/"+revlist.length+") revision "+revlist[i].revid+" was put into rev "+indexpagerevlist[i]); }	console.log("--"); syncedit(glb.u+"/etc/articlerescue/2","{{user:bluedeck/infr/ph.js}}","-"); console.log("Please wait while the index page is being created..."); syncedit(glb.u+"/etc/articlerescue","{{user:bluedeck/infr/ph.js}}","-"); console.log("--"); for(var i=0;i<revlist.length;i++) {		indexpagecontentlist[i]="\n 查看存档  "+revlist[i].timestamp.split("T").join(" ").split("Z").join("")+"  user talk:"+revlist[i].user+"  "+revlist[i].size+"  "+revlist[i].revid+"  "+replaceString_regulateWikitext(revlist[i].comment)+"  " }	var finalrev=syncedit(glb.u+"/etc/articlerescue","页面"+pagename+"共有"+revlist.length+"个已删除版本，存档如下：\n\n \n\n{"+"{subst:User:Bluedeck/infr/ar.thankyou.js}}","DRV lookup: "+pagename+""); syncedit(glb.u+"/etc/articlerescue","{{user:bluedeck/infr/ph.js}}","-"); console.log("All done: "+JSON.parse(finalrev).edit.newrevid); console.log("--"); // record this artres into a json var timestamp=Date.now; var rvid=JSON.parse(finalrev).edit.newrevid; // appendJson(db.j0,[timestamp.toString,rvid.toString,pagename]); return rvid; }

function app_articleRescue_toggle_initializer {	var arr=document.getElementsByClassName("bluedeck-artres-artname"); for(var i=0;i"+arr[i].innerHTML+" "; arr[i].style.display="inline"; } }

function app_articleRescue_archiver_initializer {	var arr=document.getElementsByClassName("bluedeck-artres-archiveartres"); for(var i=0;iClear Section 1 "; arr[i].style.display="inline"; } }

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 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>>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); }

}