Greasy Fork is available in English.

背景変更(Feederチャット)

Feederチャットの背景を変更するスクリプトです。

2020/04/26時点のページです。最新版はこちら。

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
// ==UserScript==
// @name         背景変更(Feederチャット)
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Feederチャットの背景を変更するスクリプトです。
// @author       You
// @match        *.x-feeder.info/*/
// @match        *.x-feeder.info/*/sp/
// @exclude      *.x-feeder.info/*/settings/**
// @require      https://greasyfork.org/scripts/396472-yaju1919/code/yaju1919.js?version=798050
// @require      https://greasyfork.org/scripts/387509-yaju1919-library/code/yaju1919_library.js?version=755144
// @require      https://greasyfork.org/scripts/388005-managed-extensions/code/Managed_Extensions.js?version=720959
// @grant        GM.setValue
// @grant        GM.getValue
// ==/UserScript==

(function() {
    'use strict';
    var inputBoolBtn, inputChangeInterval, inputImgURL, inputFilterColor, inputFilterOpacity;
    const backgroundColor_copy = $("#wrapper").css("backgroundColor");
    const backgroundImage_copy = $("body").css("backgroundImage");
    const setConfig = () => {
        const h = $("<div>");
        var start_flag = false;
        var exeFunc = () => start_flag ? funcMainAndChange() : null;
        inputBoolBtn = yaju1919.addInputBool(h, {
            title: "壁紙変更",
            value: false,
            change: exeFunc,
        });
        inputChangeInterval = yaju1919.addInputNumber(h, {
            title: "切り替え時間",
            placeholder: "背景画像の切り替え時間(単位:秒)",
            save: "AM_inputChangeInterval",
            width: "90%",
            value: 5,
            min: 0,
            max: Infinity,
            change: exeFunc,
        });
        inputImgURL = yaju1919.addInputText(h, {
            title: "画像のURL",
            placeholder: "背景にしたい画像のURLを入力(複数の場合は改行で区切って入力)",
            save: "AM_inputImgURL",
            width: "90%",
            textarea: true,
            change: exeFunc,
        });
        inputFilterColor = yaju1919.addInputText(h, {
            title: "フィルタの色",
            placeholder: "RGB形式のカラーコードを入力",
            save: "AM_inputFilterColor",
            width: "90%",
            change: exeFunc,
        });
        inputFilterOpacity = yaju1919_library.appendInputRange(h, {
            title: "フィルタの透明度",
            save: "AM_inputFilterOpacity",
            width: "90%",
            value: 0,
            min: 0,
            max: 100,
            change: exeFunc,
        });
        const removeBgImg = () => {
            $("body").removeAttr('style').css({
                "backgroundImage": "url(" + backgroundImage_copy + ")",
            });
            yaju1919.setBgImg(null, {
                opacity: 0
            });
            $("#wrapper").css({
                backgroundColor: backgroundColor_copy
            });
        };
        var count = 0;
        const main = () => {
            const boolBtn = inputBoolBtn();
            const changeInterval = inputChangeInterval();
            const imgURL = inputImgURL();
            const filterColor = inputFilterColor();
            const filterOpacity = inputFilterOpacity();
            const imgURLs = imgURL.split("\n").filter(v => v);
            if (count > imgURLs.length - 1) {
                count = 0;
            };
            //--- デバッグ用 通常時はコメントアウト ---
            //console.log("デバッグ用" + "\n" + "inputBoolBtn : " + boolBtn + "\n" + "inputChangeInterval : " + changeInterval + "\n" + "inputImgURL : " + imgURL + "\n" + "count : " + count + "\n" + "imgURLs : " + imgURLs + "\n" + "inputFilterColor : " + filterColor + "\n" + "inputFilterOpacity : " + filterOpacity);
            //-----------------------------------------
            if (imgURL === "" || !boolBtn) {
                removeBgImg();
            } else {
                removeBgImg();
                $("#wrapper").css({
                    backgroundColor: "transparent"
                });
                yaju1919.setBgImg(imgURLs[count], {
                    color: filterColor,
                    opacity: Number(filterOpacity) / 100
                });
            };
            count++
        };
        var si, change = () => {
            {
                if (!inputChangeInterval) return;
                const changeInterval = inputChangeInterval();
                clearInterval(si);
                si = setInterval(main, changeInterval * 1000);
            };
        };
        const funcMainAndChange = () => {
            change();
            main();
        };
        start_flag = true;
        //console.log("start_flag : " + start_flag); // デバッグ用 通常時はコメントアウト
        return h;
    };
    win.Managed_Extensions["背景変更"] = {
        config: setConfig,
        tag: "装飾",
    };
})();