From StrategyWiki, the video game walkthrough and strategy guide wiki
Jump to navigation Jump to search
(thanks Skizzerz!)
(thanks Ryan)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
//Common library functions used by many of the scripts below
//Common library functions used by many of the scripts below
document.write('<script type="text/javascript" src=" \
importScript('User:Ryan Schmidt/Scripts/library.js');
http://strategywiki.org/w/index.php?title=User:Skizzerz/Scripts/library.js \
&action=raw&ctype=text/javascript"></script>');


/*********************************
/*********************************
Line 11: Line 9:
}
}


/****************************
//QuickDelete for sysops
** Find and Replace Script **
//Change the following three lines to modify the delete reasons, remember to use + for spaces
****************************/
var qdId = ['spamvand', 'test', 'request'];
document.write('<script type="text/javascript" src=" \
var qdText = ['Spam/Vandalism', 'Test+page,+please+use+the+[[StrategyWiki:Sandbox|sandbox]]', 'Author+request'];
http://en.wikipedia.org/w/index.php?title=User:Zocky/SearchBox.js \
var qdDisp = ['Spam/Vandalism', 'Test', 'Author request'];
&action=raw&ctype=text/javascript"></script>');
importScript('User:Ryan Schmidt/Scripts/QuickDelete.js');


/**********************************
//Find and replace script
** QuickDelete Script for Sysops **
//by Zocky
**********************************/
importScript('User:Ryan Schmidt/Scripts/SearchBox.js');
function quickDeleteSetup() {
        var tab = document.getElementById('ca-delete');
        if(!tab) return;
        var link = tab.getElementsByTagName('a')[0];
        link.href = 'javascript:quickDelete();';
}


function quickDelete() {
//Auto-edit script
        var reason = window.prompt('Reason');
//by Lupin
        if(reason == null) return;
importScript('User:Ryan Schmidt/Scripts/Autoedit.js');
        window.location = ugPage + '&action=delete&wpReason=' + reason + '&submitdelete=true';
}


addOnloadHook(quickDeleteSetup);
//Add section edit link for the top section
importScript('User:Ryan Schmidt/Scripts/TopSection.js');


function checkDelete() {
//LiFilter script for Logs
    if(queryString("submitdelete")=="true") document.getElementById('deleteconfirm').wpConfirmB.click()
//by Splarka
}
importScript('User:Ryan Schmidt/Scripts/LiFilter.js');


addOnloadHook(checkDelete);
//Whois IP script
 
//by Splarka
/*****************************
importScript('User:Ryan Schmidt/Scripts/WhoisIP.js');
** LiFilter script for Logs **
*****************************/
var rightsLogOnly = (document.location.href.indexOf('type=rights')==-1 && document.location.href.indexOf('Log/rights')==-1) ? false : true
if(wgCanonicalSpecialPageName == 'Log' || wgCanonicalSpecialPageName == 'DeletedContributions' || wgCanonicalSpecialPageName == 'Linksearch' || wgCanonicalSpecialPageName == 'Contributions' || queryString('lifilter')) addOnloadHook(filterLiButton)
function filterLiButton() {
  if(document.getElementById('p-cactions')) {
    addTab('rxfilter','javascript:filterLiForm()','Filter');
    if(window.AutoLoadLogsFilter || queryString('lifilter')) filterLiForm();
  } else {
    filterLiForm(); //not a portlet skin, so add the filter anyway.
  }
}
 
function hideFilterLiForm() {
  var filtertab = document.getElementById('ca-rxfilter');
  filtertab.getElementsByTagName('a')[0].href = 'javascript:showFilterLiForm();';
  document.getElementById('rfform').style.display = 'none';
  filtertab.className = '';
}
 
function showFilterLiForm() {
  var filtertab = document.getElementById('ca-rxfilter');
  filtertab.getElementsByTagName('a')[0].href = 'javascript:hideFilterLiForm();';
  document.getElementById('rfform').style.display = 'block';
  filtertab.className = 'selected';
}
 
function filterLiForm() {
  var filtertab = document.getElementById('ca-rxfilter');
  filtertab.getElementsByTagName('a')[0].href = 'javascript:hideFilterLiForm();';
  filtertab.className = 'selected';
  var instructions = (rightsLogOnly) ? 'Regex filter the space-delimited list of rights.' : 'Regex filter the plain text representation of this list.'
  //generate the form
  var obj = (document.getElementById('contentSub')) ? document.getElementById('contentSub') : document.getElementById('topbar')
  if(!obj) return;
  var rf = document.createElement('div');
  rf.setAttribute('id','rfform');
  rf.style.color = 'black';
  var fs = document.createElement('fieldset');
    var is = document.createElement('p');
    is.appendChild(document.createTextNode(instructions));
    fs.appendChild(is);
    var lg = document.createElement('legend');
    lg.appendChild(document.createTextNode('Filter <li> list (javascript)'));
    fs.appendChild(lg);
    if(rightsLogOnly) {
      var sel = document.createElement('select');
      sel.setAttribute('id','rfselect');
      var op1 = document.createElement('option');
        op1.appendChild(document.createTextNode('added rights'));
      sel.appendChild(op1);
      var op2 = document.createElement('option');
        op2.appendChild(document.createTextNode('removed rights'));
      sel.appendChild(op2);
      var op3 = document.createElement('option');
        op3.appendChild(document.createTextNode('added OR removed'));
      sel.appendChild(op3);
      var op4 = document.createElement('option');
        op4.appendChild(document.createTextNode('added/removed/static'));
      sel.appendChild(op4);
      fs.appendChild(sel);
    }
    var lab1 = document.createElement('label');
    lab1.appendChild(document.createTextNode(' Regex string: '));
    lab1.setAttribute('for','rfinput1');
    fs.appendChild(lab1);
    fs.appendChild(document.createTextNode(' '));
    var inp1 = document.createElement('input');
    inp1.setAttribute('id','rfinput1');
    inp1.setAttribute('name','rfinput1');
    inp1.setAttribute('type','text');
    fs.appendChild(inp1);
    var chk1 = document.createElement('input');
    chk1.setAttribute('id','rfinput2');
    chk1.setAttribute('name','rfinput2');
    chk1.setAttribute('type','checkbox');
    fs.appendChild(chk1);
    var lab2 = document.createElement('label');
    lab2.appendChild(document.createTextNode('Invert '));
    lab2.setAttribute('for','rfinput2');
    fs.appendChild(lab2);
    var sub1 = document.createElement('input');
    sub1.setAttribute('type','button');
    sub1.setAttribute('value','Filter');
    addClickHandler(sub1,function() { filterLi(false) });
    sub1.setAttribute('onclick','');
    fs.appendChild(sub1)
    fs.appendChild(document.createTextNode(' '));
    var sub2 = document.createElement('input');
    sub2.setAttribute('type','button');
    sub2.setAttribute('value','Highlight');
    addClickHandler(sub2,function() { filterLi(true) });
    fs.appendChild(sub2)
  rf.appendChild(fs);
  obj.appendChild(rf);
}
 
function filterLi(hilight) {
  //grab options from form
  if(rightsLogOnly) var type = document.getElementById('rfselect').selectedIndex;
  var invert = document.getElementById('rfinput2').checked;
  var srch = document.getElementById('rfinput1').value;
  var rx = new RegExp(srch,'ig');
 
  //grab the list of all <li> in the content
  var bod = (document.getElementById('bodyContent')) ? document.getElementById('bodyContent') : document.getElementsByTagName('body')[0]
  var lis = bod.getElementsByTagName('li');
  if(lis.length==0) return;
 
  //iterate
  var rightrx = /^.*?User\:.*? from (.*?) to (.*?) \u200E.*?$/i  //the regex used to grab the Special:Log/rights changes
  for(var i=0;i<lis.length;i++) {
    if(rightsLogOnly) {
      //Special:Log/rights
      var oldr = gettext(lis[i]).replace(rightrx,'$1').replace(/\, /g,' ');
      var newr = gettext(lis[i]).replace(rightrx,'$2').replace(/\, /g,' ');
      var oldrl = oldr.split(' '); var newrl = newr.split(' ');
      for (var j=0;j<oldrl.length;j++) {
        for (var k=0;k<newrl.length;k++) {
          if(oldrl[j]==newrl[k]) {
            oldrl[j] = ''; newrl[k] = '';
          }
        }
      }
      var remr = oldrl.join(' '); var addr = newrl.join(' ');
      switch(type) {
        case 0: var look = addr; break;
        case 1: var look = remr; break;
        case 2: var look = remr + ' ' + addr; break;
        case 3: var look = oldr + ' ' + newr; break;
      }
    } else {
      //Any other list of <li> objects
      var look = gettext(lis[i]);
    }
    lis[i].style.display = '';
    lis[i].style.backgroundColor = '';
    if ((look.search(rx)!=-1 && !invert) || (look.search(rx)==-1 && invert)) {
      if(hilight) lis[i].style.backgroundColor = '#ffff99';
    } else {
      if(!hilight) lis[i].style.display = 'none';
    }
  }
}
 
/********************
** Whois IP script **
********************/
//whois tab
function ipwhoistab() {
    if(wgPageName = 'Special:Contributions') {
        var ip = document.getElementById('contentSub').innerHTML;
        ip = ip.substring(ip.indexOf(' ')+1);
        ip = ip.substring(0,ip.indexOf(' '));
        if((ip.indexOf('<') != -1)||(ip.indexOf('.') == -1)) return; // not an ip
        addTab('whois', 'http://www.dnsstuff.com/tools/whois.ch?email=on&cache=off&ip=' + ip , 'Whois' );
                var tab = document.getElementById('ca-whois');
                var a = tab.getElementsByTagName('a')[0];
                a.target = '_blank';
        ta['ca-whois'] = ['1', 'dnsstuff.com'];
        akeytt();
    }
}
addOnloadHook(ipwhoistab);


/********************
//AJAX Patrol script
** AutoEdit Script **
//Uncomment the following line if you wish to have this script
********************/
//automatically load the next diff when the patrol is finished (if applicable).
document.write('<script type="text/javascript" src=" \
//AjaxPatrolAutoNext = true;
http://en.wikipedia.org/w/index.php?title=User:Lupin/autoedit.js \
importScript('User:Ryan Schmidt/Scripts/AjaxPatrol.js');
&action=raw&ctype=text/javascript"></script>');


/******************************************
//AJAX Watch script
** Add Section Edit link for top section **
importScript('User:Ryan Schmidt/Scripts/AjaxWatch.js');
******************************************/
if (wgAction == 'view' && wgNamespaceNumber >=0)
addOnloadHook(function(){
  var h2s = document.getElementsByTagName('H2');
  var h2 = h2s[0];
  if (!h2) return;
  if (h2.parentNode.id == 'toctitle') h2 = h2s[1];
  if (!h2) return;
  var span = h2.firstChild;
  if (!span || span.className != 'editsection') return;
  var zero = span.cloneNode(true);
  if (document.getElementById('featured_icon')) zero.style.marginRight = '30px'
  var parent = document.getElementsByTagName('H1')[0];
  parent.insertBefore(zero, parent.firstChild);
  var a = zero.getElementsByTagName('A')[0];
  a.title = a.title.replace(/:.*$/,': 0');
  a.setAttribute('href', a.href.replace(/&section=1/,'&section=0'));
})

Latest revision as of 14:09, 30 September 2009

//Common library functions used by many of the scripts below
importScript('User:Ryan Schmidt/Scripts/library.js');

/*********************************
** Edit Summary Warning Nullify **
*********************************/
function check_edit_summary(event) {
  return;
}

//QuickDelete for sysops
//Change the following three lines to modify the delete reasons, remember to use + for spaces
var qdId = ['spamvand', 'test', 'request'];
var qdText = ['Spam/Vandalism', 'Test+page,+please+use+the+[[StrategyWiki:Sandbox|sandbox]]', 'Author+request'];
var qdDisp = ['Spam/Vandalism', 'Test', 'Author request'];
importScript('User:Ryan Schmidt/Scripts/QuickDelete.js');

//Find and replace script
//by Zocky
importScript('User:Ryan Schmidt/Scripts/SearchBox.js');

//Auto-edit script
//by Lupin
importScript('User:Ryan Schmidt/Scripts/Autoedit.js');

//Add section edit link for the top section
importScript('User:Ryan Schmidt/Scripts/TopSection.js');

//LiFilter script for Logs
//by Splarka
importScript('User:Ryan Schmidt/Scripts/LiFilter.js');

//Whois IP script
//by Splarka
importScript('User:Ryan Schmidt/Scripts/WhoisIP.js');

//AJAX Patrol script
//Uncomment the following line if you wish to have this script
//automatically load the next diff when the patrol is finished (if applicable).
//AjaxPatrolAutoNext = true;
importScript('User:Ryan Schmidt/Scripts/AjaxPatrol.js');

//AJAX Watch script
importScript('User:Ryan Schmidt/Scripts/AjaxWatch.js');