Skip to content

Instantly share code, notes, and snippets.

@megamit
Created June 23, 2019 14:14
Show Gist options
  • Save megamit/6e3aa76e14b0d0fe333abb7aa827521f to your computer and use it in GitHub Desktop.
Save megamit/6e3aa76e14b0d0fe333abb7aa827521f to your computer and use it in GitHub Desktop.
Load imgur images without referrer for FactorioPrints
// ==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