Jump to content

User:TopGun/common.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by TopGun (talk | contribs) at 02:07, 28 December 2011 (test function). 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.
// [[user:js/watchlist]]
//Unwatchlist in 2 clicks, view only new changes since last (while watchlist's open) + rearrange
if (wgCanonicalSpecialPageName == 'Watchlist')
  importScript('user:js/watchlist.js');

importScript('user:UncleDouggie/smart_watchlist.js'); //Highlight, categorize etc your watchlist
importScript('User:Ais523/watchlistnotifier.js'); //Bold new changes since last view + notification
importScript('User:TopGun/links.js'); //Useful custom links on top left


//</source>
/*<pre>*/
//On diff pages this script replaces ''(Difference between revisions)''with
//different tools for reverting the edit and warning the user that made the edit.
//For instructions see talk page.
// Revert tools by Lorian
function getElementsByClass(searchClass,node,tag) {
  // Function from http://www.dustindiaz.com/getelementsbyclass/
  var classElements = new Array();
  if ( node == null )
    node = document;
  if ( tag == null )
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if ( pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}


//Not working with me yet:
//importScript('user:TopGun/mass_rollback.js'); //Nuke all unchanged contributions by a user