背景変更(Feederチャット)

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

As of 2020-04-25. See the latest version.

// ==UserScript==
// @name         背景変更(Feederチャット)
// @namespace    http://tampermonkey.net/
// @version      0.3
// @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=783630
// @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 inputImgURL, inputFilterColor, inputFilterOpacity;
    const backgroundColor_copy = $("#wrapper").css("backgroundColor");
    const backgroundImage_copy = $("body").css("backgroundImage");
    const addBtn = (h, title, func) => {
        return $("<button>").text(title).click(func).appendTo(h);
    };
    const setConfig = say => {
        const h = $("<div>");
        const main = () => {
            const imgURL = inputImgURL();
            const filterColor = inputFilterColor();
            const filterOpacity = inputFilterOpacity();
            if (imgURL === "") {
                $("body").removeAttr('style').css({
                    "backgroundImage": "url(" + backgroundImage_copy + ")",
                });
                $("body").children().each((i, e) => e.style.zIndex === "-114514" ? $(e).remove() : null);
                $("#wrapper").css({
                    backgroundColor: backgroundColor_copy
                });
            } else {
                $("#wrapper").css({
                    backgroundColor: "transparent"
                });
                yaju1919.setBgImg(imgURL, {
                    color: filterColor,
                    opacity: Number(filterOpacity) / 100
                });
            };
        };
        addBtn(h, "実行", main);
        inputImgURL = yaju1919.addInputText(h, {
            title: "画像のURL",
            placeholder: "背景にしたい画像のURLを入力",
            save: "AM_inputImgURL",
            width: "90%",
            enter: main,
        });
        inputFilterColor = yaju1919.addInputText(h, {
            title: "フィルタの色",
            placeholder: "RGB形式のカラーコードを入力",
            save: "AM_inputFilterColor",
            width: "90%",
            enter: main,
        });
        inputFilterOpacity = yaju1919_library.appendInputRange(h, {
            title: "フィルタの透明度",
            save: "AM_inputFilterOpacity",
            width: "90%",
            value: 0,
            min: 0,
            max: 100,
        });
        return h;
    };
    win.Managed_Extensions["背景変更"] = {
        config: setConfig,
        tag: "装飾",
    };
})();