From Brett
Revision as of 08:28, 4 March 2014 by WikiSysop (Talk | contribs) (+gist URL)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Sometimes I encounter Google results pages but as service is unreliable here in China, I often want to get directly to the result rather than having the vain hope of waiting to go through Google.<SOME QUERY HERE><SOME ARGS HERE>&url=<ESCAPED URI COMPONENT HERE>

It is too much of a pain to type out decodeURIComponent on the relevant portion of the URL, so I worked with the following...

While this bookmarklet will do the trick if already loaded:

var url = window.location.href.match(/[?&]url=([^&]*)(?=&|$)/);
url = url && url[1];
window.location = decodeURIComponent(url);

(or in bookmarklet form, courtesy of :)


...usually Firefox just keeps on running, so I made the following page, google-redirect.html

(T'would be nice if Firefox could allow multi-line locations in bookmarks for preserving the line breaks of bookmarklets--dare I, moreover, dream of syntax highlighting here courtesy of an add-on? Would that it were, would that it might... For now, I'm just pasting the same code another time in the description so I can at least read it; hopefully I will always remember to update such bookmarklets in both the location and description (and deal with the annoyance of needing to add it after "javascript:").)

var url = window.location.href.match(/[?&]url=([^&]*)(?=&|$)/);
url = url && url[1];
url = decodeURIComponent(url).match(/[?&]url=([^&]*)(?=&|$)/);
url = url && url[1];
window.location = decodeURIComponent(url);

...and I made a bookmark leading to it, but leading to:


...and with the keyword "redir", so I could quickly hit ctrl-l to get into the location bar, copy-paste the URL, type "redir" and space and then paste (ctrl-x) to redirect quickly to whatever URL was appended at the end of the URL. Probably sounds convoluted unless you've had to deal with the Google issues as over here. This also has the advantage of not needing the maintenance trouble described above for bookmarklets.