contextmenu

context menu

Dieses Skript sollte nicht direkt installiert werden. Es handelt sich hier um eine Bibliothek für andere Skripte, welche über folgenden Befehl in den Metadaten eines Skriptes eingebunden wird // @require https://update.greasyfork.org/scripts/534404/1832276/contextmenu.js

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

;(() => {
    if (window.self !== window.top) {
        return;
    }
    const menus = [...GM_getValue('menus', []), ...[
        {
            title: "anki",
            action: addAnki,
            key: "p"
        },
        {
            title: 'qrcode',
            action() {
                const html = document.createElement('div');
                html.innerHTML = createHtml(`
                        <style>
                            .qr-text{ width: 26vw; margin-bottom: 1vw; height: 2vw; font-size: 100%; }
                            .qr-img img{ margin: auto; max-width: 27vw }
                        </style>
                        
                        <div class="qr-container">
                            <input type="text" name="qr-text" class="qr-text" value="${location.href}">
                            <div class="qr-img"></div>
                        </div>`);
                const qr = new QRCode(html.querySelector('.qr-img'), {
                    text: location.href,
                    correctLevel: QRCode.CorrectLevel.L,
                    height: 365,
                    width: 365,
                });
                html.querySelector('.qr-text').addEventListener('change', function () {
                    this.value && qr.makeCode(this.value);
                });
                Swal.fire({
                    title: "<h3>qrcode</h3>",
                    html: html,
                    width: '32vw',
                });
            },
            key: 'm'
        },
        ...(() => {
            let menus = customizeMenu(location.href);
            navigation.addEventListener("navigate", e => {
                const newMenu = customizeMenu(e.destination.url);
                arrayDiff(newMenu, menus, (a, b) => a.title === b.title).forEach(menu => window.userJSMenu[menu.title] = GM_registerMenuCommand(menu.title, menu.action));
                arrayDiff(menus, newMenu, (a, b) => a.title === b.title).forEach(v => GM_unregisterMenuCommand(window.userJSMenu[v.title]));
                menus = newMenu;
            });
            return menus
        })(),
        /*{
            title: "sh",
            action: {
                cmd: "ls -l /var/log/!*.log",
            },
            key: "e",
            path: "cmd",
            call: (res) => {
                console.log(res.response)
            },
        }*/
        /*{
            title: "env",
            action: {
                cmd: ["env","grep","wc"],
                args: [],
                "1": ["PATH"],
                "2": ["-l"],
                env: ["PATH=$PATH:/home/xing"]
            },
            key: "e",
            path: "cmd",
            call: (res) => {
                console.log(res.response)
            },
        }*/
        /*{
            title: "ls",
            action: {cmd: "ls", args: ["-l", "/"]},
            key: "e",
            path: "cmd",
            call: (res) => {
                console.log(res.response)
            },
        }*/
    ]];

    function customizeMenu(url) {
        return GM_getValue('fetch-items', []).filterAndMapX(fetchItem => {
            const name = fetchItem['fetch-name'];
            if (!name || !fetchItem['fetch-active']) {
                return false;
            }
            let active = false;
            if (fetchItem['url-scope']) {
                for (const scope of fetchItem['url-scope'].split('||')) {
                    if (new RegExp(scope).test(url)) {
                        active = true;
                        break;
                    }
                }
                if (!active) {
                    return false;
                }
            }
            if (!fetchItem['add-contextmenu']) {
                active && superFetchHook.executeActions(name);
                return false
            }
            return {title: name, action: () => superFetchHook.executeActions(name)};
        });
    }

    PushContextMenu(...menus);
})();