Skip to content

Instantly share code, notes, and snippets.

@wlerin
Last active August 8, 2017 20:17
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 wlerin/f9914950fd802daaacfd386377c844d3 to your computer and use it in GitHub Desktop.
Save wlerin/f9914950fd802daaacfd386377c844d3 to your computer and use it in GitHub Desktop.
ANN Image Replacer
// ==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