Skip to content

Instantly share code, notes, and snippets.

@vyznev
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vyznev/9c0cca3109ddfbe043cc to your computer and use it in GitHub Desktop.
Save vyznev/9c0cca3109ddfbe043cc to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name ImageShack one-click recovery
// @version 0.2
// @namespace http://vyznev.net
// @description Highlights ImageShack images on Stack Exchange, and adds a click hadler that attempts to reload them from archive.org
// @author Ilmari Karonen
// @license ISC (http://opensource.org/licenses/ISC)
// @match *://*.stackexchange.com/*
// @match *://*.stackoverflow.com/*
// @match *://*.superuser.com/*
// @match *://*.serverfault.com/*
// @match *://*.stackapps.com/*
// @match *://*.mathoverflow.net/*
// @match *://*.askubuntu.com/*
// @grant none
// ==/UserScript==
var inject = function ($) {
var re = /^https?:\/\/(([\-a-z0-9]+\.)*imageshack\.us\/img\d+\/.*)$/i;
$(document).on('click', 'img[src*="imageshack.us"]', function () {
var m = re.exec( this.src );
if (!m) return true;
this.src = "http://web.archive.org/web/2/" + m[1];
return false;
} );
};
var script = document.createElement('script');
script.textContent = "(" + inject + ")(jQuery);";
(document.body || document.documentElement).appendChild(script);
var style = document.createElement('style');
style.textContent = 'img[src*="imageshack.us"] { opacity: 0.33; border: 2px dashed red; }';
(document.head || document.documentElement).appendChild(style);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment