User:Ark25/Bookmarklets

Script for showing only the red lines in a list

2020-03-31 - [1] [2]

javascript:$('.mw-parser-output li').each(function(){if(!$(this).find('a.new').length)this.style.display='none'}) - makes list items without redlinks disapear.


javascript:$('.mw-parser-output li').each(function(){if(!$(this).find('a.new').length)this.innerHTML=''}) - makes the content of the list items without redlinks disapear

Say for example these 4 lines:

  1. Big Springs - Big Springs, Ohio
  2. Billingstown - Billingstown, Ohio
  3. Birds Run - Birds Run, Ohio
  4. Birmingham - Birmingham, Ohio

After applying the filter, only the 2nd and the 3rd line should be visible (Billingstown and Birds Run are red links at this moment):

  1.  
  2. Billingstown - Billingstown, Ohio
  3. Birds Run - Birds Run, Ohio
  4.  


Script for removing lines in a list (those lines not containing string)


javascript:$('.mw-parser-output li').css('display','');if(str = prompt('Please enter a string to search for:'))$('.mw-parser-output li').each(function(){if(!$(this).text().includes(str))this.style.display='none'}) - This script works only on Wikipedia


javascript:(function(){for(var a=document.getElementsByTagName("li"),b=prompt("Please enter a string to search for:"),c=0;c<a.length;c++)a[c].style.display=a[c].innerText.includes(b)?"":"none"})() - This script works anywhere


Script for adding prefix and suffix to all the lines in the <TEXTAREA>


javascript:(function(){for(var e=document.getElementsByTagName('textarea'),i=0;i<e.length;i++)e[i].value='PREFIX'+e[i].value.split("\n").join('SUFIX\nPREFIX')+'SUFIX'})(); - Only works in Firefox