Benjify

Turns all images on page to benjis

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name          Benjify
// @namespace     Joshy2Saucy
// @description	  Turns all images on page to benjis
// @include       *
// @version       1.1
// @license       Joshy2Saucy
// ==/UserScript==

(function() {
var Program = {
    // To add images: Google image search for the desired images, then run the following command in your browser console (tested in FF):
    // var output = ''; document.body.innerHTML.match(/(?=imgurl=)(.+?)(?=&)/g).map(function(value) {var url = encodeURIComponent(decodeURIComponent(decodeURIComponent(value)).replace('imgurl=', '').replace(/'/g, '\\\'')); if (url) output += '\'' + url + '\',';}); window.open('data:text/plain,' + output, '_blank', 'width=500,height=500,scrollbars=1');
    // Copy and paste the output below. Make sure the opening and closing []s are still there, and make sure the last line does not end with a comma.
    replacementImages: [
        'https://i.imgur.com/Kt673Kv.png','https://i.imgur.com/5KHuSxr.png','https://i.imgur.com/Nobrqcr.png','https://i.imgur.com/0E5QkVZ.png','https://i.imgur.com/ChuPbAz.png','https://i.imgur.com/Wxzjoul.png','https://i.imgur.com/0H6gG1j.png','https://i.imgur.com/kaNQoIs.png'],
    loaded: false,
    changeBufferTimer: null,

    main: function() {
        if (!this.loaded) {
            this.loaded = true;
            document.addEventListener('DOMSubtreeModified', this.domChanged, false);
            this.domChangedBuffered();
        }
    },

    domChanged: function() {
        if (this.changeBufferTimer) {
            clearTimeout(this.changeBufferTimer);
            this.changeBufferTimer = null;
        }
        this.changeBufferTimer = setTimeout(this.domChangedBuffered.bind(this), 222); //-- 222 milliseconds
    },

    domChangedBuffered: function() {
        var images = document.getElementsByTagName('img');
        for (var i = 0; i < images.length; i++) {
            images[i].src = this.replacementImages[Math.floor(Math.random() * this.replacementImages.length)];
        }
    }
};

window.addEventListener('load', Program.main.bind(Program), false);
})();