From StrategyWiki, the video game walkthrough and strategy guide wiki
Jump to navigation Jump to search
(expanding)
m (Reverted edits by 46.118.112.149 (talk) to last revision by Skizzerz)
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{User:Ryan Schmidt/UserNav}}This is a repository of various javascript tools that may be useful to you when editing and such. To get these tools, put the javascript in your user js (usually [[Special:Mypage/BlueCloud.js]]), then clear your browser cache.
This is a repository of various javascript tools that may be useful to you when editing and such. To get these tools, put the javascript in your user js (usually [[Special:Mypage/dolphin.js]]), then clear your browser cache.


==IMPORTANT: Before adding any of the below==
== Current Scripts ==
Before using any of the scripts below, make sure that you put this at the very '''top''' of your BlueCloud.js page.
These scripts are all designed to be used in recent versions of MediaWiki which have the ResourceLoader. For best results use MediaWiki 1.20 or newer. All scripts are self-contained and do not require any extra work on your part besides enabling it in your user js page.
<pre>
//Common library functions used by many of the scripts below
document.write('<script type="text/javascript" src=" \
http://strategywiki.org/w/index.php?title=User:Skizzerz/Scripts/library.js \
&action=raw&ctype=text/javascript"></script>');
</pre>


=== AJAX Patrol ===
This script allows you to patrol pages via AJAX instead of having to load the patrol successful page and navigate back in order to get to the next diff. This script was created by myself. Should work on all skins.


== Edit section link for the top section ==
This is available as a [[Special:Preferences|Gadget]] on StrategyWiki, so the manual loading should only be necessary if you wish to test development versions (if applicable) or you wish to load it on a different wiki.
Adds an edit link that lets you section edit the very top section.
<pre>
<pre>
/******************************************
// AJAX Patrol script
** Add Section Edit link for top section **
// by Skizzerz
******************************************/
// Uncomment the following line if you do NOT wish to have this script
if (wgAction == 'view' && wgNamespaceNumber >=0)
// automatically load the next diff when the patrol is finished.
addOnloadHook(function(){
//var AjaxPatrolAutoNext = false;
  var h2s = document.getElementsByTagName('H2');
mw.loader.load( 'http://strategywiki.org/w/index.php?title=User:Skizzerz/Scripts/AjaxPatrol.js&action=raw&ctype=text/javascript' );
  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'));
})
</pre>
</pre>


== Auto-edit script ==
=== Edit Summary Warning Nullify ===
Enables an auto-clicking script
<pre>
/********************
** AutoEdit Script **
********************/
document.write('<script type="text/javascript" src=" \
http://en.wikipedia.org/w/index.php?title=User:Lupin/autoedit.js \
&action=raw&ctype=text/javascript"></script>');
</pre>
 
== Find-and-replace script ==
Enables a search-and-replace function for the edit box, including regular expression searches.  A small magnifying glass icon will appear on the left side of the macro buttons (the lightblue images above the edit box).
<pre>
/****************************
** Find and Replace Script **
****************************/
document.write('<script type="text/javascript" src=" \
http://en.wikipedia.org/w/index.php?title=User:Zocky/SearchBox.js \
&action=raw&ctype=text/javascript"></script>');
</pre>
 
== Edit Summary Warning Nullify ==
Nullifies the edit warning when you enter a blank summary
Nullifies the edit warning when you enter a blank summary
<pre>
<pre>
Line 69: Line 28:
</pre>
</pre>


== QuickDelete ==
=== Recent Changes Patrol ===
Changes the link of the 'delete' tab from the confirmation page to a javascript prompt for faster deletion.
Adds a new "Patrol" tab on [[Special:RecentChanges]] and [[Special:BlankPage]] which loads an AJAX patrol interface to automatically step through all the pending diffs in recent changes (oldest first).
<pre>
/**********************************
** QuickDelete Script for Sysops **
**********************************/
function quickDeleteSetup() {
var tab = document.getElementById('ca-delete');
if(!tab) return;
var link = tab.getElementsByTagName('a')[0];
link.href = 'javascript:quickDelete();';
}


function quickDelete() {
This script is still experimental and is in early alpha. Please report any bugs or feature requests to my [[User talk:Skizzerz|talk page]].
var reason = window.prompt('Reason');
if(reason == null) return;
window.location = ugPage + '&action=delete&wpReason=' + reason + '&submitdelete=true';
}


addOnloadHook(quickDeleteSetup);
<pre>
// Recent Changes Patrol script
// by Skizzerz
mw.loader.load( 'http://strategywiki.org/w/index.php?title=User:Skizzerz/Scripts/RcPatrol.js&action=raw&ctype=text/javascript' );
</pre>


function checkDelete() {
== Legacy Scripts ==
    if(queryString("submitdelete")=="true") document.getElementById('deleteconfirm').wpConfirmB.click()
These scripts likely do not work anymore and were made for ancient versions of MediaWiki. The useful ones will eventually get updated.
}


addOnloadHook(checkDelete);
===IMPORTANT: Before adding any of the below===
Before using any of the scripts below, make sure that you put this at the very '''top''' of your bluecloud.js page.
<pre>
//Common library functions used by many of the scripts below
importScript('User:Skizzerz/Scripts/library.js');
</pre>
</pre>


==LiFilter==
=== Edit section link for the top section ===
Adds a filter tab to [[Special:Log]] for filtering and highlighting of results. Clicking the tab shows the filter options, and clicking again hides them. The rights log has additional filtering options. For BlueCloud skin only.
Adds an edit link that lets you section edit the very top section.
<pre>
//Add section edit link for the top section
importScript('User:Skizzerz/Scripts/TopSection.js');
</pre>


Credit goes to Splarka for making this fine script.
=== Auto-edit script ===
Enables an auto-clicking script
<pre>
//Auto-edit script
//by Lupin
importScript('User:Skizzerz/Scripts/Autoedit.js');
</pre>


=== Find-and-replace script ===
Enables a search-and-replace function for the edit box, including regular expression searches.  A small magnifying glass icon will appear on the left side of the macro buttons (the lightblue images above the edit box).
<pre>
<pre>
/*****************************
//Find and replace script
** LiFilter script for Logs **
//by Zocky
*****************************/
importScript('User:Skizzerz/Scripts/SearchBox.js');
var rightsLogOnly = (document.location.href.indexOf('type=rights')==-1 && document.location.href.indexOf('Log/rights')==-1) ? false : true
</pre>
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() {
=== QuickDelete ===
  var filtertab = document.getElementById('ca-rxfilter');
Changes the link of the 'delete' tab from the confirmation page to a javascript prompt for faster deletion.
  filtertab.getElementsByTagName('a')[0].href = 'javascript:showFilterLiForm();';
<pre>
  document.getElementById('rfform').style.display = 'none';
//QuickDelete for sysops
  filtertab.className = '';
//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:Skizzerz/Scripts/QuickDelete.js');
</pre>


function showFilterLiForm() {
===LiFilter===
  var filtertab = document.getElementById('ca-rxfilter');
Adds a filter tab to [[Special:Log]] for filtering and highlighting of results. Clicking the tab shows the filter options, and clicking again hides them. The rights log has additional filtering options. For BlueCloud skin only.
  filtertab.getElementsByTagName('a')[0].href = 'javascript:hideFilterLiForm();';
  document.getElementById('rfform').style.display = 'block';
  filtertab.className = 'selected';
}


function filterLiForm() {
Credit goes to Splarka for making this fine script.
  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) {
<pre>
  //grab options from form
//LiFilter script for Logs
  if(rightsLogOnly) var type = document.getElementById('rfselect').selectedIndex;
//by Splarka
  var invert = document.getElementById('rfinput2').checked;
importScript('User:Skizzerz/Scripts/LiFilter.js');
  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';
    }
  }
}
</pre>
</pre>


==Whois IP==
===Whois IP===
This script adds a "whois" tab on [[Special:Contributions]] pages for IPs that link to a whois website to obtain DNS data on the IP. The link will automatically open in a new window/tab on a left click. For BlueCloud skin only.
This script adds a "whois" tab on [[Special:Contributions]] pages for IPs that link to a whois website to obtain DNS data on the IP. The link will automatically open in a new window/tab on a left click. For BlueCloud skin only.


Line 256: Line 100:


<pre>
<pre>
/********************
//Whois IP script
** Whois IP script **
//by Splarka
********************/
importScript('User:Skizzerz/Scripts/WhoisIP.js');
//whois tab
</pre>
function ipwhoistab() {
 
    if(wgPageName = 'Special:Contributions') {
===AJAX Watch===
        var ip = document.getElementById('contentSub').innerHTML;
This script allows you to watch and unwatch pages via AJAX (like how the watch/unwatch tab works on Wikipedia). This script was created by myself and only works on BlueCloud (Monobook should already have AJAX page watching anyway).
        ip = ip.substring(ip.indexOf(' ')+1);
 
        ip = ip.substring(0,ip.indexOf(' '));
<pre>
        if((ip.indexOf('<') != -1)||(ip.indexOf('.') == -1)) return; // not an ip
//AJAX Watch script
        addTab('whois', 'http://www.dnsstuff.com/tools/whois.ch?email=on&cache=off&ip=' + ip , 'Whois' );
importScript('User:Skizzerz/Scripts/AjaxWatch.js');
var tab = document.getElementById('ca-whois');
var a = tab.getElementsByTagName('a')[0];
a.target = '_blank';
        ta['ca-whois'] = ['1', 'dnsstuff.com'];
        akeytt();
    }
}
addOnloadHook(ipwhoistab);
</pre>
</pre>


== More? ==
== More? ==
Want something that's not listed here? Try searching for it on Google or some other search engine and if you still can't find it, feel free to drop a message on my [[User talk:Ryan Schmidt|talk page]] and I'll attempt to write it :)
Want something that's not listed here? Try searching for it on Google or some other search engine and if you still can't find it, feel free to drop a message on my [[User talk:Skizzerz|talk page]] and I'll attempt to write it :)

Latest revision as of 01:03, 2 August 2014

This is a repository of various javascript tools that may be useful to you when editing and such. To get these tools, put the javascript in your user js (usually Special:Mypage/dolphin.js), then clear your browser cache.

Current Scripts[edit]

These scripts are all designed to be used in recent versions of MediaWiki which have the ResourceLoader. For best results use MediaWiki 1.20 or newer. All scripts are self-contained and do not require any extra work on your part besides enabling it in your user js page.

AJAX Patrol[edit]

This script allows you to patrol pages via AJAX instead of having to load the patrol successful page and navigate back in order to get to the next diff. This script was created by myself. Should work on all skins.

This is available as a Gadget on StrategyWiki, so the manual loading should only be necessary if you wish to test development versions (if applicable) or you wish to load it on a different wiki.

// AJAX Patrol script
// by Skizzerz
// Uncomment the following line if you do NOT wish to have this script
// automatically load the next diff when the patrol is finished.
//var AjaxPatrolAutoNext = false;
mw.loader.load( 'http://strategywiki.org/w/index.php?title=User:Skizzerz/Scripts/AjaxPatrol.js&action=raw&ctype=text/javascript' );

Edit Summary Warning Nullify[edit]

Nullifies the edit warning when you enter a blank summary

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

Recent Changes Patrol[edit]

Adds a new "Patrol" tab on Special:RecentChanges and Special:BlankPage which loads an AJAX patrol interface to automatically step through all the pending diffs in recent changes (oldest first).

This script is still experimental and is in early alpha. Please report any bugs or feature requests to my talk page.

// Recent Changes Patrol script
// by Skizzerz
mw.loader.load( 'http://strategywiki.org/w/index.php?title=User:Skizzerz/Scripts/RcPatrol.js&action=raw&ctype=text/javascript' );

Legacy Scripts[edit]

These scripts likely do not work anymore and were made for ancient versions of MediaWiki. The useful ones will eventually get updated.

IMPORTANT: Before adding any of the below[edit]

Before using any of the scripts below, make sure that you put this at the very top of your bluecloud.js page.

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

Edit section link for the top section[edit]

Adds an edit link that lets you section edit the very top section.

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

Auto-edit script[edit]

Enables an auto-clicking script

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

Find-and-replace script[edit]

Enables a search-and-replace function for the edit box, including regular expression searches. A small magnifying glass icon will appear on the left side of the macro buttons (the lightblue images above the edit box).

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

QuickDelete[edit]

Changes the link of the 'delete' tab from the confirmation page to a javascript prompt for faster deletion.

//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:Skizzerz/Scripts/QuickDelete.js');

LiFilter[edit]

Adds a filter tab to Special:Log for filtering and highlighting of results. Clicking the tab shows the filter options, and clicking again hides them. The rights log has additional filtering options. For BlueCloud skin only.

Credit goes to Splarka for making this fine script.

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

Whois IP[edit]

This script adds a "whois" tab on Special:Contributions pages for IPs that link to a whois website to obtain DNS data on the IP. The link will automatically open in a new window/tab on a left click. For BlueCloud skin only.

Credit for this script goes to Splarka

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

AJAX Watch[edit]

This script allows you to watch and unwatch pages via AJAX (like how the watch/unwatch tab works on Wikipedia). This script was created by myself and only works on BlueCloud (Monobook should already have AJAX page watching anyway).

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

More?[edit]

Want something that's not listed here? Try searching for it on Google or some other search engine and if you still can't find it, feel free to drop a message on my talk page and I'll attempt to write it :)