Forum Moderators: open

Message Too Old, No Replies

js code to number serps?

cool custom firefox button

         

chewy

9:37 pm on Apr 24, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



one of the marvelous WWM-izens once created this totally cool button thing that when pressed, put a number next to each serp result.

i thought I'd be able to find an email or note referring to the author, but that seems to have been several machines ago and lost to time.

the thing was slick, fast and always worked.

now it doesn't.

can I post the code here to see if anyone can revise for the new FF?

thanks as always!

brotherhood of LAN

9:49 pm on Apr 24, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can run this from a javascript console, I tested it on a couple of SERP's and it worked OK.


var inc = 0;
var x = content.document.getElementsByClassName('r');
for(i in x)
x[i].innerHTML = (++inc)+'. '+x[i].innerHTML;


I guess whoever wrote the code you referred to made a plugin out of it, giving you the ease of clicking a button.

chewy

10:00 pm on Apr 24, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month


I tried to cut and paste here what worked...

but it won't let me put it in... let me try that again - maybe disable codes?

[code]

javascript:var%20searchResults=document.getElementsByClassName('l');for%20(var%20i%20in%20searchResults)%20{var%20numberSpan%20=%20document.createElement('span');%20var%20resultNumber%20=%20document.createTextNode(((i-0)+1)+'.%20');numberSpan.appendChild(resultNumber);searchResults[i].parentNode.insertBefore(numberSpan,%20searchResults[i]);}

[/code]

err - consider me clueless on the fine points of the code.

how do I bolt what BoL into this?