Last active
August 29, 2015 14:27
-
-
Save vyznev/9c0cca3109ddfbe043cc to your computer and use it in GitHub Desktop.
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
// ==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