Jump to content

User:Jorgenev/scripts/EnhancedUserContribs.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.
/* This script provides an interface for hiding various automated scripts from the contribs list.
 */

// Name, Regex
var scripts1 = [["Huggle", "Wikipedia:HG"],
["Twinkle", "Wikipedia:TW"],
["Dab solver", "view/Dab solver"],
["CSD Helper", ">CSDH<"],
["AssessorTags", ">AssessorTags<"],
["Dabfix", ">Dabfix<"],
["AWB", ">AWB<"],
["WPCleaner", ">WPCleaner<"],
["Igloo", "(>GLOO<)|(>IG<)"],
["SPIhelper", "Archiving case ((to)|(from))"],
["Default Reversion", "(/wiki/Help:Reverting)|(Undid revision)"],
["HotCat", ">HotCat<"],
["popups", ">popups<"],
["closeAFD", "((Closing debate, result was)|(> closed as))"],
["NowCommonsReview", ">nowcommonsreviewer<"],
["Checklinks", ">Checklinks<"],
["AFCHelper4", "((Declining submission: submission)|(Your submission at <))"],
["?AFDScript", "(adding orphaned AfD)|(Relisting <)"],
["EasyBlock", "(You have been blocked)|(from this IP address, it has been blocked for)"]]

function update()
{
 var li = document.getElementById("bodyContent").getElementsByTagName("li");
 var i = -1;
 while(++i<li.length)
 {
  var i2 = -1;
  var hide = false;
  while(++i2<scripts1.length)
  {
   hide = hide || ( ( document.getElementsByName("masterscripts1")[0].checked || document.getElementsByName(scripts1[i2][0].replace(" ","") + "1")[0].checked ) && li[i].innerHTML.match(scripts1[i2][1]) );
  }
  
  if(document.getElementById("mode1").innerHTML=="Show")
  {
     hide = !hide;   
  }

  if(hide)
  {
   li[i].style.display = "none";
  }
  else
  {
   li[i].style.display = "list-item";
  }
 }
}

function switchmode()
{
     if(document.getElementById("mode1").innerHTML == "Show")
     {
           document.getElementById("mode1").innerHTML = "Hide";
      }
      else
     {
          document.getElementById("mode1").innerHTML = "Show";
     }

      update();
}

function toggleMaster()
{
    if(document.getElementsByName("masterscripts1")[0].checked)
     {
         document.getElementById("subsections1").style.display = "none";
      }
     else
     {
          document.getElementById("subsections1").style.display = "inline";
      }

       update();
}

$(function () {
  if((location.href.indexOf("Special:Contributions")!=-1||
      location.href.indexOf("Special%3AContributions")!=-1))
    {
var li = document.getElementById("bodyContent").getElementsByTagName("li");


var index;

index = -1;

  var counts = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];

while(++index <scripts1.length)
{
  var index2;
  index2 = -1;
  while(++index2<li.length)
  {
   if(li[index2].innerHTML.match(scripts1[index][1]))
   {
       counts[index]++;
   }
 }
}


      var add = "";
       var i2 = -1;
      var disp1 = 0;
  while(++i2<scripts1.length)
  {
      if(counts[i2] > 0)
       {
            add += "<input type=checkbox name="+ scripts1[i2][0].replace(" ","") + "1" + " onclick=javascript:update(); /> "+ scripts1[i2][0] + " (" + counts[i2] + ")";
           disp1 += counts[i2];
        }
         else
         {
            add += "<span name="+ scripts1[i2][0].replace(" ","") + "1 /> ";
         }
        
  }

   add += "</span>"
var explainNode = document.getElementById("mw-sp-contributions-explain");
if(disp1 > 0 && explainNode){
       explainNode.innerHTML = '<hr><input type=checkbox name=masterscripts1 onclick=javascript:toggleMaster(); /><button id=mode1 type=button style="border-style:groove; padding: 0px; margin:0px;" onclick=javascript:switchmode(); >Hide</button> scripts (' + disp1 + ')<span id=subsections1>:<br />&nbsp; &nbsp; &nbsp; &nbsp; ' +
add + explainNode.innerHTML;
     }}
});