GreasyFork Script Finder

获取当前页面的主域名并打开 GreasyFork 查找脚本

Versione datata 01/03/2025. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         GreasyFork Script Finder
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  获取当前页面的主域名并打开 GreasyFork 查找脚本
// @author       Felix
// @license      Felix
// @match        *://*/*
// @grant        GM_registerMenuCommand
// @grant        GM_openInTab
// ==/UserScript==

(function() {
    'use strict';

    // 注册菜单命令
    GM_registerMenuCommand("查找该域名的GreasyFork脚本", function() {
        // 获取当前页面的完整域名
        const domain = window.location.hostname;

        // 使用正则表达式提取主域名
        const mainDomain = domain.replace(/^.*\.(?:com|org|net|gov|edu|io|co|info|me|tv)(?:\.[a-z]{2,})?$/, "$&").split('.').slice(-2).join('.');

        // 生成 GreasyFork 搜索链接
        const url = `https://greasyfork.org/zh-CN/scripts/by-site/${mainDomain}`;

        // 在新标签页中打开该链接
        GM_openInTab(url, { active: true });
    });
})();