拡張機能マネージャー

ユーザーによる動的な設定が必要な複数のユーザースクリプトを管理します。

当前为 2021-01-09 提交的版本,查看 最新版本

// ==UserScript==
// @name         拡張機能マネージャー
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @license      MIT
// @description  ユーザーによる動的な設定が必要な複数のユーザースクリプトを管理します。
// @author       You
// @match        *.x-feeder.info/*/
// @match        *.x-feeder.info/*/sp/
// @exclude      *.x-feeder.info/*/settings/*
// @match        http://drrrkari.com/room/
// @match        http://www.3751chat.com/ChatRoom*
// @match        https://pictsense.com/*
// @match        http://www.himachat.com/
// @match        https://discord.com/*
// @match        https://*.open2ch.net/*
// @require      http://code.jquery.com/jquery-3.5.1.min.js
// @require      https://gf.qytechs.cn/scripts/419945-global-managedextensions/code/Global_ManagedExtensions.js?version=889360
// @require      https://gf.qytechs.cn/scripts/419888-antimatterx/code/antimatterx.js?version=889299
// @require      https://gf.qytechs.cn/scripts/417889-sendmessage/code/sendMessage.js?version=876786
// @grant        none
// ==/UserScript==

(function(unsafeWindow) {
    'use strict';
    /*-------------------------------------------------- カスタマイズ領域 --------------------------------------------------*/
    var fontColor = "white", // 文字色
        backgroundColor = "rgba(0, 0, 0, 0.7)"; // 背景色
    /*------------------------------------------------------------------------------------------------------------------*/
    var $ = window.$,
        amx = window.antimatterx,
        sendMessage = window.sendMessage;
    //--------------------------------------------------
    var h = $("<div>").css({
            position: "fixed",
            zIndex: "99999",
            top: "0",
            left: "0",
            display: "inline-block"
        }).appendTo("body"),
        content = $("<div>").text("拡張機能マネージャー").css({
            padding: "1em",
            paddingTop: "3em",
            color: fontColor,
            backgroundColor: backgroundColor,
            width: "22em",
            height: "100vh",
            maxWidth: "90vw",
            overflow: "scroll",
            textAlign: "left",
            fontSize: "1em"
        }).appendTo(h),
        toggleBtn = $(amx.addInputBool(h[0], {
            title: "拡張機能",
            insertBefore: true,
            change: function(flag) {
                h.css("left", flag ? 0 : -h.width() * 1.4);
            }
        })).css({
            position: "fixed",
            left: "0",
            maxWidth: "100%"
        }),
        selectHolder = $("<div>").appendTo(content).after("<br>"),
        mainHolder = $("<div>").appendTo(content);
    h.css({
        transition: "all .5s",
        left: -h.width() * 1.4
    });
    //--------------------------------------------------
    var tagList = (function(extensions) {
        var obj = {
            "▼タグから選択": null,
            "すべて": Object.keys(extensions)
        };
        Object.keys(extensions).forEach(function(k) {
            if (!amx.isType(extensions[k], "Object")) return;
            var tag = extensions[k].tag;
            if (amx.isType(tag, "String")) obj[tag] = (obj[tag] || []).concat([k]);
            else if (amx.isType(tag, "Array")) {
                tag.forEach(function(v) {
                    obj[v] = (obj[v] || []).concat([k]);
                });
            };
        });
        Object.keys(obj).forEach(function(k) {
            if (amx.isType(obj[k], "Array")) obj[k] = JSON.stringify(obj[k]);
        });
        return obj;
    })(unsafeWindow.Global_ManagedExtensions);
    //--------------------------------------------------
    var selects = [];

    function updateSelect() {
        selectHolder.find("select").each(function(i, e) {
            amx.triggerEvent(e, "updateselect");
        });
    };
    selects.push($(amx.addSelect(selectHolder[0], {
        list: (function() {
            var obj = {
                "▼拡張機能を選択": null
            };
            Object.keys(unsafeWindow.Global_ManagedExtensions).forEach(function(k, i) {
                obj[k] = k;
            });
            return obj;
        })(),
        width: "90%",
        change: function(v) {
            mainHolder.empty();
            if (/^(|null)$/.test(v)) return;
            var ext = unsafeWindow.Global_ManagedExtensions[v],
                config = (amx.isType(ext, "Function") ? ext :
                    amx.isType(ext.config, "Function") ? ext.config : undefined);
            if (config === undefined) return;
            mainHolder.append(config(sendMessage));
            selects[1].val(null); // もう片方の選択肢を空にする
        }
    })));
    selects.push($(amx.addSelect(selectHolder[0], {
        list: tagList,
        width: "90%",
        change: function(v) {
            mainHolder.empty();
            if (/^(|null)$/.test(v)) return;
            JSON.parse(v).forEach(function(k, i) {
                var ext = unsafeWindow.Global_ManagedExtensions[k],
                    config = (amx.isType(ext, "Function") ? ext :
                        amx.isType(ext.config, "Function") ? ext.config : undefined);
                if (config !== undefined) $("<div>").text(++i + ". " + k).appendTo(mainHolder).append(config(sendMessage)).after("<br><br>");
            });
            selects[0].val(null); // もう片方の選択肢を空にする
        }
    })));
    selectHolder.find("select").on("click", updateSelect);
    updateSelect();
})(this.unsafeWindow || window);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址