Skip to content

Instantly share code, notes, and snippets.

@Gavitron
Forked from anonymous/waffleimages.user.js
Last active July 10, 2020 16:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Gavitron/4fc14eea57d66d5e3863 to your computer and use it in GitHub Desktop.
Save Gavitron/4fc14eea57d66d5e3863 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name WaffleImage Grabber
// @namespace http://www.imcrapproductions.com
// @description sup
// @include *forums.somethingawful.com/*
// @include *archives.somethingawful.com/*
// @version 1.0
// @grant none
// ==/UserScript==
// Generated by LiveScript 1.3.1
var getNewLink, deadImages, i$, len$, deadImage, deadImagePath;
getNewLink = function(url){
var parser, segments, imagePath, imageFiletype;
parser = document.createElement('a');
parser.href = url;
segments = parser.pathname.replace(/^\//, '').split('/');
imagePath = segments[0];
//alert(imagePath);
imageFileType = segments[segments.length-1].split(".")[1];
//alert(imageFileType);
//alert('http://randomwaffle.gbs.fm/images/' + imagePath.substring(0, 2) + '/' + imagePath + '.' + imageFileType);
//alert(url + ' ' + imagePath + ' ' + imageFileType);
return 'http://randomwaffle.gbs.fm/images/' + imagePath.substring(0, 2) + '/' + imagePath + '.' + imageFileType;
};
deadImages = $("img[src*='waffleimages']");
//alert('found '+deadImages.length+' images');
for (i$ = 0, len$ = deadImages.length; i$ < len$; ++i$) {
deadImage = deadImages[i$];
deadImagePath = deadImage.src;
var newLink = getNewLink(deadImagePath);
deadImage.src = newLink;
//console.log(i + ' : ' + deadImagePath + ' : ' + newLink);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment