Greasy Fork

Greasy Fork is available in English.

嗅探下载组合包

脚本整合

当前为 2025-03-21 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         嗅探下载组合包
// @namespace    https://facaikotei.github.io/
// @version      1.1
// @description  脚本整合
// @author       (c)2025 facaikotei
// @match        *://*/*
// @grant        GM_addElement
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @require      https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js
// @require      https://unpkg.com/[email protected]/dist/hotkeys.min.js
// @license      GPL-3.0
// @homepageURL  http://greasyfork.icu/scripts/529908
// ==/UserScript==

(function () {
    'use strict';

    // 处理传的key字符串转换成数组 (c)2022 jaywcjlove (c)2013 madrobby
    function getKeys(key) {
        if (typeof key !== 'string') key = '';
        key = key.replace(/\s/g, ''); // 匹配任何空白字符,包括空格、制表符、换页符等等
        const keys = key.split(','); // 同时设置多个快捷键,以','分割
        let index = keys.lastIndexOf('');

        // 快捷键可能包含',',需特殊处理
        for (; index >= 0;) {
            keys[index - 1] += ',';
            keys.splice(index, 1);
            index = keys.lastIndexOf('');
        }
        return keys;
    }

    // 返回键码 (c)2022 jaywclove (c)2013 madrobby
    const code = x => hotkeys.keyMap[x.toLowerCase()] || hotkeys.modifier[x.toLowerCase()] || x.toUpperCase().charCodeAt(0);

    $(function () {
        $(".MyBT").append("<div id='MyImage' class='jianBian'>图片<div style='opacity:0;'>图片</div></div>");
        GM_addStyle(".MyBT>div>div{width:150px;}");
        $("#MyImage").on("click", function () {
            let shortCutString = GM_getValue("shortCutString") || 'alt+W';
            let keyCode;
            let shiftKey = false;
            let ctrlKey = false;
            let altKey = false;
            let metaKey = false;
            getKeys(shortCutString)[0].split('+').forEach((x) => {
                x = code(x);
                switch (x) {
                    case 16:
                        shiftKey = true;
                        break;
                    case 17:
                        ctrlKey = true;
                        break;
                    case 18:
                        altKey = true;
                        break;
                    case 91:
                        metaKey = true;
                        break;
                    case '*':
                        keyCode = 87;
                        shiftKey = false;
                        ctrlKey = false;
                        altKey = true;
                        metaKey = false;
                        break;
                    default:
                        keyCode = x;
                        break;
                }
            });
            document.dispatchEvent(new KeyboardEvent("keydown", {
                keyCode: keyCode,
                shiftKey: shiftKey,
                ctrlKey: ctrlKey,
                altKey: altKey,
                metaKey: metaKey
            }));
        });
        $("body").on("change", ".shortCutString", () => {
            GM_setValue("shortCutString", $(".shortCutString").val());
        });
    });
})();