Google Chrome Highlight nofollow links Javascript

27 Views Asked by At

I try to highlight all nofollow links in the webpage by bookmark a code, but it's not working Can someone tell me what I am doing wrong, here is my code:

javascript:var a = document.getElementsByTagName('a');for(var i=0; i<a.length; i++)if (a[i].rel === 'nofollow') {a[i].style.backgroundColor = 'red';a[i].style.fontSize = '2em';}

I expect to highlight every nofollow link in the page

1

There are 1 best solutions below

0
Daniel Stasiak On

You forgot to add the opening curly brace after the for loop definition. Working code:

var a = document.getElementsByTagName('a');

for(var i=0; i<a.length; i++) {
    if (a[i].rel === 'nofollow') {
        a[i].style.backgroundColor = 'red';
        a[i].style.fontSize = '2em';
    }
}