Scritp Request: Highlight link text based on url

Subscribe to Scritp Request: Highlight link text based on url 5 posts, 3 voices

 
Rommel Scriptwright

There is a script that will highlight links based on words but what I need is one that highlights based on matching part of the url.

[url=http://userscripts.org/scripts/show/1478]Highlight certain links[/url]

 
Webb User

You could do this with CSS. This (works on this page only) changes any link containing "users" red and any link containing "forums" blue.

---------------------Code---------------------------
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document url("http://userscripts.org/forums/2/topics/57"){
A[href*="users"]{color:red !important;}
A[href*="forums"]{color:blue !important;}
}
---------------------Code---------------------------

 
Rommel Scriptwright

BTW, Case closed.
A friend wrote me a 12 line script that doe what I wanted.
I'm gonna try your version though also.

 
Rommel Scriptwright

Found a script somewhere on the greasemonkey site that used in conjunction with this is pretty nice.

function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}

addGlobalStyle('A[href*="forums"]{color:blue !important;}');

 
Henrik N Admin

Yeah, that's pretty much what Webb posted, above. You could use that with the Stylish extension.

If you want to stick with a GM script, this is shorter:

GM_addStyle('A[href*="forums"]{color:blue !important;}');