Skip to content

Instantly share code, notes, and snippets.

@bga
Created April 7, 2010 17:11
Show Gist options
  • Save bga/359141 to your computer and use it in GitHub Desktop.
Save bga/359141 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name 404cache
// @author Bga
// @version 0.11
// @description improve 404 default opera page by adding links to google and yandex cache
// ==/UserScript==
document.addEventListener("DOMContentLoaded",function(){
var $d = document, $h, v, vs, s, cs, c;
var is404 = (vs = $d.getElementsByTagName('head')).length > 0 && ($h = vs[0]) && (vs = $h.getElementsByTagName('link')).length === 1 && (v = vs[0]) && v.getAttribute('rel') === 'stylesheet' && v.href && v.href.substr(0, 17) === 'file://localhost/' && v.href.slice(-9) === 'error.css' /* && (s = v.sheet) && (cs = s.cssRules).length > 1 && (c = cs.item(1)) && c.type === CSSRule.IMPORT_RULE && c.href === 'opera.css'*/;
if(!is404)
return;
var $b = $d.body, ul = $b.getElementsByTagName('ul')[0];
var li = $d.createElement('li');
li.innerHTML = 'Try load from cache <a href="http://webcache.googleusercontent.com/search?q=cache%3A' + encodeURIComponent("" + location) + '">Google</a>, <a href="http://hghltd.yandex.net/yandbtm?url=' + encodeURIComponent("" + location) + '" >Yandex</a>';
ul.insertBefore(li, ul.firstChild);
},true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment