/waffleimages.user.js Secret
Created
February 20, 2017 03:41
-
-
Save LoneBoco/20f17173781f0e535bf14ef87e084b74 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 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); | |
} | |
var deadLinks = $("a[href*='waffleimages']"); | |
for (i$ = 0, len$ = deadLinks.length; i$ < len$; ++i$) { | |
var deadLink = deadLinks[i$]; | |
var deadLinkPath = $(deadLink).attr('href'); | |
var newLink = getNewLink(deadLinkPath); | |
$(deadLink).attr('href', newLink); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment