User:John doe 120/vector.js

function printPageSizes { var languageCodes = ['de','fr','ko','ru']; for(var i=0; i < languageCodes.length; i++) { var elements = document.getElementsByClassName('interwiki-' + languageCodes[i]); if(elements.length === 0) continue; elements = elements[0]; elements = elements.children; if(elements.length === 0) continue; console.log(elements); } } printPageSizes;

function addDateCreated { var url = window.location.href; //if (!/^https:\/\/en\.wikipedia\.org\/wiki\/.*/.test(url)) //	return; var element = document.getElementById('t-info'); if (element === null || element.childElementCount === 0) return; element = element.children[0]; if (element.tagName.toLowerCase != 'a') return; url = element.href; var e=document.querySelectorAll('.mw-body .firstHeading, #t-info a, .mw-parser-output>h2, .mw-parser-output>h3'); function addTitle(t){ for(var i=0;i.*?(.*?)1)			addTitle(' ('+(date).toFixed(2) + ' years)');		else if(date*12>1)			addTitle(' ('+(date*12).toFixed(2) + ' months)');		else			addTitle(' ('+(date*365.25).toFixed(2) + ' days)');

match = text.match(/mw-pageinfo-lasttime">.*?(.*?)</);		if (match === null) return;		datetime = match[1]+'+00:00';		addTitle('\nDate of latest edit: ' + datetime);	}	oReq.addEventListener("load", reqListener);	oReq.open("GET", url);	oReq.send; } addDateCreated; window.popupDelay=0.5*Math.pow(1.618,1.75); window.popupHideDelay=0.5*Math.pow(0.618,3); window.popupMaxWidth=350*Math.pow(1.618,1.5);

window.extraPopupFilters = [];

// define the function var xHRequests=[], k=0, urls = [], matchs=[]; function popupFilterHtmlTable (wikiText,second,third) { /*console.log(Object.keys(second)); for (var prop in second) { console.log('second.'+prop+'='); }*/	//var xhr=second.http; var url = second.url; //console.log(xhr.responseURL) //console.log; //console.log(second.url) //console.log(Object.keys(third)); if (!/^https:\/\/en\.wikipedia\.org\/w\/api\.php\?format=json&formatversion=2&action=query&titles=[^&]*?&prop=revisions\|pageprops\|info\|images\|categories&rvprop=ids\|timestamp\|flags\|comment\|user\|content&cllimit=max&imlimit=max$/.test(url)) return ''; var i = url.indexOf('title'); //if (second.url.indexOf(':',i) !== -1) //return ''; url = url.match(/titles=([^&]*?)&/)[1]; url = 'https://en.wikipedia.org/w/api.php?action=parse&format=xml&title=' + url	+ '&text=&prop=langlinks&contentmodel=wikitext'; for (var j = 0; j < urls.length; j++) { if (urls[j] === url) return matchs[j]; }	while (xHRequests.length > 0) { var rState = xHRequests[0][1].readyState; if (rState === 0 || rState === 4) xHRequests.shift; else break; }	for (var j = 0; j < xHRequests.length; j++) { var rState = xHRequests[j][1].readyState; if (xHRequests[j][0] === url && rState !== 0 && rState !== 4) return 'null '; }	k++; //console.log(url) var oReq = new XMLHttpRequest; xHRequests.push([url, oReq]); function log(string) { var date = new Date; console.log(date.getMinutes+':'+date.getSeconds+'.'+date.getMilliseconds+' '+string); }   function setSpanText(string) { var element = document.getElementsByClassName('popupData-interwiki' + k); if (element.length === 0) { return; }		element = element[0]; element.textContent = string; }	function updateProgress (oEvent) { var len = oReq.responseText.length; if (len === 0) return; setSpanText(len +' characters loaded'); //log(len); //log(oReq.readyState); //log(oReq.getResponseHeader('content-length')); var text = oReq.responseText; var match = text.match('(.*?)<'); var match2 = text.match(/<\/api>\s*$/); if (match === null && match2 !== null) { setSpanText('not found'); urls.push(url); matchs.push('not found'); return; } else if (match === null) return; //log(match[1]); match[1] += ' - 中文'; setSpanText(match[1]); urls.push(url); matchs.push(match[1]); oReq.abort; }	function transferFailed(evt) { setSpanText("An error occurred while transferring the file."); console.log("An error occurred while transferring the file."); }

function transferCanceled(evt) { setSpanText("The transfer has been canceled by the user."); console.log("The transfer has been canceled by the user."); }	oReq.addEventListener("progress", updateProgress); oReq.addEventListener("error", transferFailed); //oReq.addEventListener("abort", transferCanceled); oReq.onreadystatechange = function { switch (oReq.readyState) { case 2: setSpanText('Headers received'); break; case 3: setSpanText('Loading'); }	   };	oReq.addEventListener("load", updateProgress); oReq.open("GET", url); oReq.send; return 'null '; }

extraPopupFilters.push(popupFilterHtmlTable);