Benjify

Turns all images on page to benjis

目前為 2024-07-16 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
})();