User:Midas02/Gadget-zeus.js

From Wikipedia, the free encyclopedia
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.
//ZeusMode as MediaWiki Extension
//By [[User:Zanaq|Zanaq]]

if (location.href.indexOf('&autoedit=') == -1) // Compatible with popups?
{

if ( typeof ( zm_loaded ) == "undefined" ) //prevent loading twice
{
zm_extension = 1;

mw.loader.load( '//en.wikipedia.org/w/index.php?title=Special:MyPage/zeusmodepreferences.js'
    + '&action=raw&ctype=text/javascript' );

/* Version 2.beta.5

[[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]].

this version will only work correctly on the dutch wikipedia: see [[G:ZM]] for other versions
*/

//<pre><nowiki>

if (navigator.appName != 'Microsoft Internet Explorer') {



zmVersion='0.042';

mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Midas02/Zeusmode/'
    + wgContentLanguage + '.js&action=raw&ctype=text/javascript' );

if ( typeof ( isSysop ) == "undefined" ) isSysop = (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;

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

// -----------------------------------------------------------------------------
// 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] ;
//alert(iii);
//if (iii > 5) break;
 }

 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
//    akeytt();
    return li;
}

//</nowiki></pre>

 if (( typeof ( zmver ) == "undefined" ) || (zmver < zmVersion) ||(document.location.href.indexOf('Zeusmode:Preferences') != -1))
 {
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Midas02/Zeusmode/preferences.js'
    + '&action=raw&ctype=text/javascript' );

} 

if (document.location.href.indexOf('Zeusmode:Preferences') == -1)
{
 
if ((zmUseNewPages) && ((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  ((wgCanonicalSpecialPageName=='Whatlinkshere') || (wgTitle.substr(-1) == ')'))
mw.loader.load( '//en.wikipedia.org/w/index.php?title='
    + 'User:Midas02/Zeusmode/whatlinkshere.js&action=raw&ctype=text/javascript' );

if ( (zmUseQuickTemplate) &&  (document.location.href.indexOf('&action=history')==-1) && ((wgCanonicalNamespace != 'Special')  || (wgCanonicalSpecialPageName == "Contributions")  ))
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Midas02/Zeusmode/qtemplate2.js'
    + '&action=raw&ctype=text/javascript' );

if ( (zmUseRevert) &&  (  (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) &&    ((wgCanonicalSpecialPageName == "Watchlist") || (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' );

}

}

zm_loaded = 1;

}

}
//</nowiki></pre>