Created
June 23, 2019 14:14
-
-
Save megamit/6e3aa76e14b0d0fe333abb7aa827521f to your computer and use it in GitHub Desktop.
Load imgur images without referrer for FactorioPrints
This file contains hidden or 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 Load imgur images without referrer for FactorioPrints | |
// @namespace http://mreb.uk | |
// @version 1 | |
// @description It looks like the actual images are not actually deleted but just blocked by referrer. Loading the images via tampermonkey fixes the site | |
// @author megamit | |
// @match https://factorioprints.com/blueprints | |
// @connect i.imgur.com | |
// @grant GM_xmlhttpRequest | |
// @grant unsafeWindow | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const replaceImage = img => result => { img.src = URL.createObjectURL(result.response) } | |
function processImages() { | |
const images = unsafeWindow.document.querySelectorAll('img[src^="https://i.imgur.com/"]') | |
.forEach(img => { | |
const imgurUrl = img.src; | |
img.src = '' | |
GM_xmlhttpRequest({ | |
method: 'GET', | |
url: imgurUrl, | |
responseType: 'blob', | |
onload: replaceImage(img), | |
onerror: console.error | |
}) | |
}) | |
} | |
setInterval(processImages, 100) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment