2

I like to Google with JavaScript disabled. I used to do this by adding the operator gbv=1 to my search strings, but now Google has added a script that forcibly reloads the search results page with the parameter changed to gbv=2, which enables JS.

As a result, I've begun blocking scripts on Google (using the extension uBlock Origin). Unfortunately, this disables an important functionality: Any links I visit are only temporarily marked as visited on the results page. If I reload the results page, or (more realistic scenario) encounter some of the same results later while doing a new search for slightly different terms, the results I've already looked at are as blue as the ones I've never seen.

This seems to be because of the way Google redirects its search results. For example, today I did a search for "css semicolon", and the URL of the second result was displayed as

stackoverflow.com/questions/2406717/semicolon-in-css

The actual link, however, was

https://encrypted.google.com/url?q=http://stackoverflow.com/questions/2406717/semicolon-in-css&sa=U&ved=0ahUKEwiT0siQ567RAhWqj1QKHQWlDz8QFggbMAE&usg=AFQjCNFbK1Fld5AALqyb6B2c6Y0dFzvgIA

It appears that the contents of the ved field in the query string are re-generated every time the results page is reloaded. Presumably that's why the visited links are no longer highlighted – because technically, I haven't visited them before.

A number of extensions and user scripts have been created to deal with this issue, but all the ones I’ve found are designed to work with JavaScript enabled (most of them seem to involve disabling an onmousedown event that doesn’t/can’t take place when JS is disabled).

How can I make Google show me which links I’ve already visited?

1

All right, I don't know if it's kosher to answer your own question, but here's what I've come up with:

function revertURL() {
    var refs = document.querySelectorAll("h3.r > a");
    for (i = 0; i < refs.length; ++i) {
    var oldurl = refs[i].href;
    var n1 = oldurl.indexOf("q=");
    var n2 = oldurl.indexOf("sa=");
    var newurl = oldurl.slice(n1 + 2, n2 - 1);
    refs[i].href = newurl;
    }
}

Edit, four days later: After testing I've added the parentheses (around and after the function) that were needed to make it work for real.

I've also expanded the definition of refs so the script works on more types of search results: sublists of results from a single domain, Google cached pages, and image search results.

And I've added a line to decode the escaped characters the function was producing.

(function revertURL() {
    var refs = document.querySelectorAll("h3.r > a, a.fl, span._cD > a, table.images_table a");
    for (i = 0; i < refs.length; ++i) {
    var oldurl = refs[i].href;
    var n1 = oldurl.indexOf("q=");
    var n2 = oldurl.indexOf("sa=");
    var newurl = oldurl.slice(n1 + 2, n2 - 1);
    var newurl_dec = decodeURIComponent(newurl)
    refs[i].href = newurl_dec;
    }
})();
  • 1
    It is okay to answer your own question. You can try and see this for inspirations: github.com/diegocr/CleanLinks – user477799 Jan 7 '17 at 8:32
  • 1
    It is even more ok to mark it as answered if it works. :) – Alexandre Martins Jan 10 '17 at 19:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.