Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// ==UserScript==
// @name image hider
// @namespace
// @downloadURL
// @updateURL
// @version 1.26
// @description hide images until you want them
// @include https://6.f*.org/*
// @require
// @copyright 2018, Chad Lavimoniere
// ==/UserScript==
/* jshint -W097 */
'use strict';
function hideImages() {
var imgs=document.getElementsByTagName("img");
var img_count=imgs.length;
for (var i=0; i<img_count; i++) {
var A = document.getElementsByTagName("img")[i];
var h = A.height;
var w = A.width;
var x=imgs[i].getAttribute("src");
var div = document.createElement("div");
A.parentNode.replaceChild(div, A);
var b = document.createElement("div");
var img = document.createElement("img");
img.setAttribute("src", x);
img.setAttribute("style", "display: inline-block; width:"+w+"px; height:"+h+"px; position: absolute; opacity: 0;")
b.setAttribute("style", "background-color: none; width:"+w+"px; height:"+h+"px; color: inherit; text-align: center; line-height:"+h+"px; position: absolute;");
b.setAttribute("class", "image-hider");
img.setAttribute("class", "hidden");
div.setAttribute("style", "background-color: none; width:"+w+"px; height:"+h+"px; position: relative;");
img.setAttribute("onclick", "if (this.getAttribute(\"class\")==\"hidden\") {; this.setAttribute('class', 'shown');} else {; this.setAttribute('class', 'hidden');}");
$(window).on("load", function() {
//do what you need here
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment