Last active
August 8, 2017 20:17
-
-
Save wlerin/f9914950fd802daaacfd386377c844d3 to your computer and use it in GitHub Desktop.
ANN Image Replacer
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 ANN Image Replacer | |
// @namespace http://scripts.social48.net | |
// @version 0.1 | |
// @description Replace small images from ANN with large ones. | |
// @author Social48 | |
// @include http://www.allnightnippon.com/wp/assets/* | |
// @grant none | |
// @run-at document-start | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function redirect(new_url) { | |
// get rid of image so it won't load twice | |
var images = document.getElementsByTagName('img'); | |
if (images.length > 0) { | |
images[0].parentNode.removeChild(images[0]); | |
} | |
window.location.replace(new_url); | |
} | |
var url = window.location.href; | |
var img_re = /(http:\/\/www\.allnightnippon\.com\/wp\/assets\/uploads\/20\d+\/\d+\/img_\d+)-\d+x\d+(\.jpg)/i; | |
if (img_re.test(url)) { | |
redirect(url.replace(img_re, "$1$2")); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment