Jump to content

User:7/hidepatrolled.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.
/* Hide edit-filter pages not yet rolled back - Adapted from [[User:Mr.Z-man/hideClosedAFD]]
   Example page:  http://en.wikipedia.org/w/index.php?title=Special:RecentChanges&limit=250&tagfilter=repeating+characters
   Add this to your monobook.js or vector.js with the following syntax: 
                    importScript('User:7/hidepatrolled.js');

*/

function hidePatrolledRecentChanges() {
  if ((mw.config.get('wgPageName').indexOf('Special:RecentChanges') != -1)) {
    mw.util.addPortletLink('p-cactions', 'javascript:hidePatrolledTags()', "hide patrolled", "ca-hidePatrolled", "Hide recent changes with no rollback tag visible (they may have alread been patrolled)");
    mw.util.addPortletLink('p-cactions', 'javascript:showPatrolledTags()', "show patrolled", "ca-showPatrolled", "Show all recent changes");
    hidePatrolledTags();  //hide patrolled by default - will parameterize it later
  }
};

function hidePatrolledTags() {
  // all rows in the recent change are tables (and TDs) with style mw-enhanced-rc
  var patrolled = getElementsByClassName(document, "table", "mw-enhanced-rc");
  document.getElementById('ca-hidePatrolled').style.display = 'none';
  document.getElementById('ca-showPatrolled').style.display = '';
  for (var i in patrolled)
  {
    if(patrolled[i].innerHTML.indexOf('mw-rollback-link')==-1)
       patrolled[i].style.display = 'none';
  }
};

function showPatrolledTags() {
  var patrolled = getElementsByClassName(document, "table", "mw-enhanced-rc");
  document.getElementById('ca-showPatrolled').style.display = 'none';
  document.getElementById('ca-hidePatrolled').style.display = '';
  for (var i in patrolled)
  {
    patrolled[i].style.display = '';
  }
};

addOnloadHook(hidePatrolledRecentChanges);