Last active
July 28, 2024 06:06
-
-
Save samthecodingman/7a96a2a1c55d33f0c5ec1bc9107f0e9a to your computer and use it in GitHub Desktop.
Reload the current page using Google's Web Cache [Javascript Bookmarklet] [CC-BY License]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(window.location.href.indexOf("webcache.googleusercontent.com")>-1)?alert("Error:%20You%20are%20on%20the%20cached%20version."):window.location.assign("http://webcache.googleusercontent.com/search?q=cache:"+encodeURIComponent(window.location.href.replace(/(^\w+:|^)\/\//,''))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Google Web Cache Bookmarklet
How to use
To use this bookmarklet, add it as a Bookmark to your favourites bar of your browser under the 'URL' or 'Location' field. When clicked, the Javascript function will run and reload the page from Google's Web Cache. If a page is not cached by Google (usually because of a
robots.txt
file), you will get a 404 error.Why use a bookmarklet?
Well, in comparison to a full plugin, a bookmarklet consists of a small amount of text that just performs the function you need. It may not be as pretty as a plugin, but it doesn't require updating, doesn't have version incompatibilities and most importantly won't actually read any of the page's contents. So there is zero snooping/logging/tracking risk.
How it works
On the surface...
The bookmarklet is actually quite primitive and simplistic, consisting of some simple error checking using the ternary operator:
A more in depth look...
Using that analogy,
isThisTheGoogleCache()
checks if the current page is from the Google Web Cache by searching for the substring"webcache.googleusercontent.com"
in the page URL.When that check is true, an error is thrown in the form of a warning dialog.
If the page isn't from the Web Cache, the URL scheme (usually
http://
,https://
or '//') is removed from the current URL, encoded and then passed to the Google Web Cache.Props to cachedview.me for pointing out that the URL scheme should be removed.