Chrome Link Detection

I use usercript for Chrome and Firefox, and I check the links the user visited. I have

a{ color: blue; } a:visited{ color: red !important; } 

in my css imported as soon as the page loads. The A-links on the page I visited are red, not blue by default. Then I use:

 alert(window.getComputedStyle(document.getElementById("myLink"), null).getPropertyValue("color")) 

on each link, and they all return in red for visited links in Firefox, but in Chrome they all return in blue.

I was wondering how to implement the search for visited links using javascript with Chrome. JQuery code or plain javascript code is fine. Thanks in advance.

+6
javascript jquery firefox google-chrome visited
source share
1 answer

A_horse_with_no_name is correct. Security issue :visited was fixed in 2010 by browser vendors after an excellent demo ( Spyjax ; no longer) demonstrated that any web page can find out if you visited any given URL. You can check that getComputedStyle by reference no longer returns the color :visited - even within the same domain:

 // Test I used within the JS console. // :visited is no longer detectable by getComputedStyle. function getLinkColor(url) { var a = document.createElement('a'); a.href = a.textContent = url; document.body.appendChild(a); return document.defaultView.getComputedStyle(a, null).color; } getLinkColor('http://stackoverflow.com/questions/5394099/detect-visited-link-in-chrome'); getLinkColor('http://stackoverflow.com/some-fake-path'); 

For Chrome extensions, if you want to determine if the user has visited the URL, I think you need to request permission to "history" and call chrome.history.getVisits .

+8
source share

All Articles