Gebruiker:Zanaq/Zeusmode/zm2.js
< Gebruiker:Zanaq | Zeusmode
Opmerking: nadat u de wijzigingen hebt gepubliceerd is het wellicht nodig uw browsercache te legen.
- Firefox / Safari: houd Shift ingedrukt terwijl u op Vernieuwen klikt of druk op Ctrl-F5 of Ctrl-R (⌘-Shift-R op een Mac)
- Google Chrome: druk op Ctrl-Shift-R (⌘-Shift-R op een Mac)
- Internet Explorer / Edge: houd Ctrl ingedrukt terwijl u op Vernieuwen klikt of druk op Ctrl-F5
- Opera: druk op Ctrl-F5.
/* ZeusMode Version 2.beta.6
[[Image:Zeus_head_thumb-zanaq.png|left]]
'''Zeusmode''' - by [[User:Zanaq|Zanaq]] - is an extensive elaboration of Sam Hocevar's godmode-light script and some other [[Wikipedia:WikiProject_User_scripts/Scripts|scripts]]. It has been tested with [[Mozilla]], [[Mozilla Firefox]] and Opera. Some functionality is retained when using [[Safari]] or [[Chrome]].
*/
console.log('ZeusMode: started: ' + new Date());
// -----------------------------------------------------------------------------
// tools for [[User:Zanaq/Zeusmode]]
// -----------------------------------------------------------------------------
//------------------------------------
// Find an elememt in an array
// (c) Zanaq 2008 - released under GPL
//------------------------------------
//findInArray(['hallo','daaag','hoipipeloi'], '"daa');
function findInArray(elements, searchString, caseSensitive) {
elementString = elements.toSource().toUpperCase();
a = elementString.indexOf(searchString.toUpperCase());
if (a == -1) return (-1);
b = elementString.substring(a + 1).match(/, "/g);
if (!b) return (elements.length - 1);
return (elements.length - b.length - 1);
}
//------------------------------------
// Create a pseudo combobox
// (c) Zanaq 2008 - released under GPL
//------------------------------------
function createComboBox(id, width, defaultvalue, values, captions) {
//return(values[1]);
cmbb = '<table CELLSPACING="-2px" CELLPADDING="-2px" BORDER="0" style=display:inline;margin-bottom:-5px;margin-top:50px;padding:0;><tr><td style="">';
cmbb += ' <select style="margin-right:-' + (width) + 'px;width:' + width + 'px;border:0" onChange="JavaScript:changeSelect(this, \'' + id + '\');" id="sel' + id + '" class="dropDown" value="' + defaultvalue + '"/>';
for (iii = 0; iii < values.length; iii++) {
cmbb += '<option value="' + values[iii] + '"/>' + captions[iii];
}
cmbb += '</select>';
cmbb += '<span style=background:#000;margin-right:22px><input onKeyUp=\'JavaScript:changeTextbox("' + id + '", ' + values.toSource() + ', event)\' style="width:' + (width - 22) + 'px" id="' + id + '" class="txtBox"/ value="' + defaultvalue + '"></span></td></tr></table>';
return (cmbb);
}
function changeTextbox(id, elements, e) {
//if (findInArray(['8','27','36','35','37','38','39','40'], e.keyCode.toString()) !=-1)
if (((e.keyCode < 47) && (e.keyCode != 32)) || (e.keyCode == 91) || (e.keyCode == 92) || (e.keyCode == 93) || (e.keyCode == 144) || (e.keyCode == 145)) return (0);
//alert(e.keyCode);
x = document.getElementById(id);
xx = document.getElementById('sel' + id);
//elements=xx.options;
q = x.selectionStart;
if (q == 0) return (0);
val = x.value.substring(0, q);
a = findInArray(elements, '"' + val);
if (a == -1) return (0);
x.value = elements[a];
x.selectionStart = q;
x.selectionEnd = x.value.length;
xx.value = elements[a];
}
function changeSelect(x, id) {
document.getElementById(id).value = x.value;
}
// -----------------------------------------------------------------------------
// XMLHttpRequest support
// From Sam Hocevar's godmode
// -----------------------------------------------------------------------------
if (document.implementation.createDocument) {
var xmlparser = new DOMParser();
}
function XMLParse(string) {
if (document.implementation.createDocument) {
return xmlparser.parseFromString(string, "text/xml");
} else if (window.ActiveXObject) {
var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async = "false";
ret = xmldoc.loadXML(string);
if (!ret)
return null;
return xmldoc.documentElement;
}
return null;
}
var xmlhttp;
function HTTPClient() {
var http;
if (window.XMLHttpRequest) {
http = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
http = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
http = false;
}
}
}
return http;
}
/*--------------------------------------
Add a link to a given item
From the collection at the english wikipedia
--------------------------------------*/
function addlilink(tabs, url, name, id, title, key) {
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if (id) li.id = id;
li.appendChild(na);
tabs.appendChild(li);
if (id) {
if (key && title) {
ta[id] = [key, title];
} else if (key) {
ta[id] = [key, ''];
} else if (title) {
ta[id] = ['', title];
}
}
// re-render the title and accesskeys from existing code in wikibits.js
return li;
}
/*--------------------------------------
Save a page
--------------------------------------*/
function zmSavePage(pagename, content, summary, timestamp, successCallback, failureCallback) {
$.ajax({
url: mw.util.wikiScript('api'),
data: {
format: 'json',
action: 'edit',
title: pagename,
summary: summary,
text: content,
starttimestamp: timestamp,
token: mw.user.tokens.get('csrfToken'),
watchlist: 'nochange'
},
dataType: 'json',
type: 'POST',
success: function(data) {
if (data && data.edit && data.edit.result == 'Success') {
successCallback()
} else {
failureCallback();
console.log('Error: API may have returned error code "' + data.error.code + '": ' + data.error.info);
}
},
error: function(xhr) {
failureCallback();
}
});
}
/*--------------------------------------
Zeus
--------------------------------------*/
if (location.href.indexOf('&autoedit=') == -1) // Compatible with popups?
{
if (typeof(zm_loaded) == "undefined") //prevent loading twice
{
zm_extension = 1;
jQuery.getScript('/w/index.php?title=Special:MyPage/zeusmodepreferences.js&action=raw&ctype=text/javascript', function(script, textStatus) {
zmLoadPreferences();
})
zm_loaded = 1;
}
}
function zmLoadPreferences() {
jQuery.getScript('//nl.wikipedia.org/w/index.php?title=Gebruiker:Zanaq/Zeusmode/' + mw.config.get('wgContentLanguage') + '.js&action=raw&ctype=text/javascript', function(script, textStatus) {
zmVersion = '0.042';
zmLoadScripts();
})
}
function zmLoadScripts() {
console.log('ZeusMode: loading scripts: ' + new Date());
if (navigator.appName != 'Microsoft Internet Explorer' && window.location.href.indexOf('veaction=') == -1) {
if (typeof(isSysop) == "undefined") isSysop = (mw.config.get('wgUserGroups').toString().indexOf('sysop') == -1) ? false : true;
if (typeof(zmUseQuickTemplate) == "undefined") zmUseQuickTemplate = true;
if (typeof(zmUseLocalTemplates) == "undefined") zmUseLocalTemplates = true;
if (typeof(zmUseCustomTemplates) == "undefined") zmUseCustomTemplates = false;
if (typeof(zmCustomTemplateLocation) == "undefined") zmCustomTemplateLocation = '';
if (typeof(zmUseRevert) == "undefined") zmUseRevert = true;
if (typeof(zmUsePlace) == "undefined") zmUsePlace = true;
if (typeof(zmUseUndo) == "undefined") zmUseUndo = true;
if (typeof(zmUseRollback) == "undefined") zmUseRollback = (isSysop == true) ? false : true;
if (typeof(zmUseWatchlist) == "undefined") zmUseWatchlist = true;
if (typeof(zmUseSinceLinks) == "undefined") zmUseSinceLinks = true;
if (typeof(zmUseSinceTab) == "undefined") zmUseSinceTab = true;
if (typeof(zmUseLastTab) == "undefined") zmUseLastTab = true;
if (typeof(zmUseNewPages) == "undefined") zmUseNewPages = true;
if (typeof(zmUseMarkPatrolled) == "undefined") zmUseMarkPatrolled = true;
if (typeof(zmUseMisc) == "undefined") zmUseMisc = true;
if (typeof(zmUseBlockRequest) == "undefined") zmUseBlockRequest = (isSysop == true) ? false : true;
if (typeof(zmRecentChangesLink) == "undefined") zmRecentChangesLink = true;
if (typeof(zmzmRecentChangesDefault) == "undefined") zmRecentChangesDefault = '?hidepatrolled=1&hideliu=1&limit=500';
if (typeof(zmUseUserListLinks) == "undefined") zmUseUserListLinks = true;
if (typeof(zmUseWhatLinksHere) == "undefined") zmUseWhatLinksHere = true;
if (typeof(zmUsePreviewFindDominantMeaning) == "undefined") zmUsePreviewFindDominantMeaning = false;
//<pre><nowiki>
if (navigator.appName == 'Opera' || navigator.appName == 'Netscape') {
mw.loader.load('//nl.wikipedia.org/w/index.php?title=Gebruiker:Zanaq/Zeusmode/opera.js&action=raw&ctype=text/javascript');
}
//</nowiki></pre>
if ((typeof(zmver) == "undefined") || (zmver < zmVersion) || (document.location.href.indexOf('Zeusmode:Preferences') != -1)) {
mw.loader.load('//nl.wikipedia.org/w/index.php?title=Gebruiker:Zanaq/Zeusmode/preferences.js&action=raw&ctype=text/javascript');
}
if (document.location.href.indexOf('Zeusmode:Preferences') == -1) {
if ((zmUseNewPages) && ((mw.config.get('wgCanonicalSpecialPageName') == "Newpages") || (document.location.href.indexOf('&diff=') != -1) || (document.location.href.indexOf('?diff=') != -1) || (document.location.href.indexOf('&rcid=') != -1)))
mw.loader.load('//nl.wikipedia.org/w/index.php?title=Gebruiker:Zanaq/Zeusmode/newpages.js&action=raw&ctype=text/javascript');
if ((mw.config.get('wgCanonicalSpecialPageName') == 'Whatlinkshere') || (mw.config.get('wgTitle').substr(-1) == ')'))
mw.loader.load('//nl.wikipedia.org/w/index.php?title=Gebruiker:Zanaq/Zeusmode/whatlinkshere.js&action=raw&ctype=text/javascript');
if ((zmUseQuickTemplate) && (document.location.href.indexOf('&action=history') == -1) && ((mw.config.get('wgCanonicalNamespace') != 'Special') || (mw.config.get('wgCanonicalSpecialPageName') == "Contributions")))
mw.loader.load('//nl.wikipedia.org/w/index.php?title=Gebruiker:Zanaq/Zeusmode/qtemplate2.js&action=raw&ctype=text/javascript');
if ((zmUseRevert) && ((mw.config.get('wgCanonicalSpecialPageName') == 'Contributions') || (document.location.href.indexOf('&action=history') != -1) || (document.location.href.indexOf('&diff=') != -1) || (document.location.href.indexOf('?diff=') != -1) || (document.location.href.indexOf('&undo=') != -1)))
mw.loader.load('//nl.wikipedia.org/w/index.php?title=Gebruiker:Zanaq/Zeusmode/revert.js&action=raw&ctype=text/javascript');
if ((zmUseWatchlist) && ((mw.config.get('wgCanonicalSpecialPageName') == "Watchlist") || (mw.config.get('wgCanonicalNamespace') != 'Special')))
mw.loader.load('//nl.wikipedia.org/w/index.php?title=Gebruiker:Zanaq/Zeusmode/watchlist.js&action=raw&ctype=text/javascript');
if (zmUseMisc)
mw.loader.load('//nl.wikipedia.org/w/index.php?title=Gebruiker:Zanaq/Zeusmode/misc.js&action=raw&ctype=text/javascript');
//link to preferences
mw.util.addPortletLink("p-navigation", "/wiki/Zeusmode:Preferences", "Zeusmode:Preferences");
}
}
}
//</nowiki></pre>