Jump to content

User:Logicalthinker33/vector.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Logicalthinker33 (talk | contribs) at 15:21, 1 September 2010. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// include the Luasóg framework
importScript('User:Luasóg bot/framework.js');
 
// wait for the page to load
window.onload = function(){
	// instantiate an instance of Luasog pointing at the en.wiki API
	var luasog = new Luasog("http://en.wikipedia.org/w/api.php");
 
	// set up the callback function
	var callback = function(data){
		// add the number of edits for this user to the inner HTML of the contributions link
		document.getElementById("pt-mycontris").innerHTML =
		document.getElementById("pt-mycontris").innerHTML.replace
		("</a>", " ("+data.query.userinfo.editcount+")</a>");
	};
 
	// request the edit count for this use and call callback when done
	luasog.request({action:"query", meta:"userinfo",uiprop:"editcount"}, callback);
};
// Adds a "Replace" tab which pops up two prompt boxes; one for a regexp and one for a replacement
function wpTextboxReplace()
{
    var s = prompt("Search regexp:");
    if(s){
        var r = prompt("Replace /"+s+"/ with:");
        if(!r && r != '') return;
        var txt = document.editform.wpTextbox1;
        txt.value = txt.value.replace(new RegExp(s, "mg"), r);
    }
}
addOnloadHook(function () {
    if (document.forms.editform) {
        addPortletLink('p-cactions', 'javascript:wpTextboxReplace()', 'Replace', 'ca-replace',
                       'Regexp replace for the edit window', 'R', document.getElementById('ca-history'));
    }
});
 
//