Greasy Fork

Greasy Fork is available in English.

背景変更(Feederチャット)

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

当前为 2020-05-01 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         背景変更(Feederチャット)
// @namespace    http://tampermonkey.net/
// @version      0.7
// @description  Feederチャットの背景を変更するスクリプトです。
// @author       You
// @match        *.x-feeder.info/*/
// @match        *.x-feeder.info/*/sp/
// @exclude      *.x-feeder.info/*/settings/**
// @require      http://greasyfork.icu/scripts/396472-yaju1919/code/yaju1919.js?version=798050
// @require      http://greasyfork.icu/scripts/387509-yaju1919-library/code/yaju1919_library.js?version=755144
// @require      http://greasyfork.icu/scripts/388005-managed-extensions/code/Managed_Extensions.js?version=720959
// @grant        GM.setValue
// @grant        GM.getValue
// ==/UserScript==

(function() {
    'use strict';
    let inputBoolBtn, inputDebugBoolBtn, inputChangeInterval, inputImgURL, inputFilterColor, inputFilterOpacity;
    const backgroundColor_copy = $("#wrapper").css("backgroundColor");
    const backgroundImage_copy = $("body").css("backgroundImage");
    const setConfig = () => {
        const h = $("<div>");
        let start_flag = false;
        let exeFunc = () => start_flag ? funcMainAndChange() : null;
        inputBoolBtn = yaju1919.addInputBool(h, {
            title: "壁紙変更",
            value: false,
            change: exeFunc,
        });
        inputDebugBoolBtn = yaju1919.addInputBool(h, {
            title: "デバッグ用",
            vlaue: 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,
        });
        let h2 = $("<div>").appendTo(h);
        h2.text("フィルタの透明度 : 0");
        inputFilterOpacity = yaju1919_library.appendInputRange(h, {
            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
            });
        };
        let count = 0;
        const main = () => {
            const boolBtn = inputBoolBtn();
            const debugBoolBtn = inputDebugBoolBtn();
            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;
            };
            if (debugBoolBtn) {
                console.log(`----- デバッグ用 -----\ninputBoolBtn : ${boolBtn}\ninputDebugBoolBtn : ${debugBoolBtn}\ninputChangeInterval : ${changeInterval}\ninputImgURL : ${imgURL}\ninputFilterColor : ${filterColor}\ninputFilterOpacity : ${filterOpacity}\nimgURLs : ${imgURLs}\ncount : ${count}\nimgURLs[count] : ${imgURLs[count]}\n----------------------`);
            }
            if (imgURL === "" || !boolBtn) {
                removeBgImg();
            } else {
                removeBgImg();
                $("#wrapper").css({
                    backgroundColor: "transparent"
                });
                yaju1919.setBgImg(imgURLs[count], {
                    color: filterColor,
                    opacity: Number(filterOpacity) / 100
                });
            };
            count++
            h2.text(`フィルタの透明度 : ${Math.floor(filterOpacity)}`);
        };
        let si, change = () => {
            {
                if (!inputChangeInterval) return;
                const changeInterval = inputChangeInterval();
                clearInterval(si);
                si = setInterval(main, changeInterval * 1000);
            };
        };
        const funcMainAndChange = () => {
            change();
            main();
        };
        start_flag = true;
        return h;
    };
    win.Managed_Extensions["背景変更"] = {
        config: setConfig,
        tag: "装飾",
    };
})();