Skip to content

Instantly share code, notes, and snippets.

@speters
Created January 31, 2019 06:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save speters/e37e99c2399606bc3192f4011161bfae to your computer and use it in GitHub Desktop.
Save speters/e37e99c2399606bc3192f4011161bfae to your computer and use it in GitHub Desktop.
Violentmonkey/Greasemonkey userscript to embed images on selected sites
// ==UserScript==
// @name Embed images on selected sites
// @namespace 7d47d98c-acd8-434f-b058-72f9ce028241
// @version 0.1
// @description Turn image URLs into embeded images.
// @author Print
// @match *://forum.zerspanungsbude.net/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var img = document.getElementsByTagName("a");
for (var i = 0, l = img.length; i < l; i++) {
var imgno = img[i];
var reg = new RegExp(/.*\.(png|svg|jpg|jpeg|gif|webp|tiff)/i);
if (reg.test(imgno.href)){
console.log(imgno.href);
imgno.innerHTML = "<img src="+imgno.href+" width='100%'>";
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment