Sauce Opener

For when your pasta feels too dry. Highlight text and Alt+T to open sauce. Highlighting numbers will open the holy scriptures, urls will open themselves and strings will open a Google search

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

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

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

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

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

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

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

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

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

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

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

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

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

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

"use strict";
// ==UserScript==
// @name         Sauce Opener
// @namespace    https://9gag.com/
// @version      1.1.5
// @description  For when your pasta feels too dry. Highlight text and Alt+T to open sauce. Highlighting numbers will open the holy scriptures, urls will open themselves and strings will open a Google search
// @author       Redeven
// @match        *://*/*
// @grant        none
// ==/UserScript==
(function () {
    'use strict';
    function getSauce() {
        const SELECTION = window.getSelection();
        if (SELECTION === null || SELECTION === void 0 ? void 0 : SELECTION.toString()) {
            const SAUCE_REGEX = /^[0-9]{1,6}$/g;
            const URL_REGEX = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g;
            const SAUCE = SELECTION.toString().trim();
            if (SAUCE_REGEX.test(SAUCE)) {
                window.open(`https://nhentai.net/g/${SAUCE}`, '_blank');
            }
            else if (URL_REGEX.test(SAUCE)) {
                window.open(SAUCE);
            }
            else {
                window.open(`https://www.google.com/search?q=${SAUCE}`);
            }
        }
    }
    document.addEventListener('keydown', (event) => {
        if (event.key === 't' && event.altKey) {
            event.preventDefault();
            getSauce();
        }
    });
})();