Search Scripts on GreasyFork/Sleazyfork

Search GleasyFork or Sleasyforks for scripts of the current site

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Search Scripts on GreasyFork/Sleazyfork
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Search GleasyFork or Sleasyforks for scripts of the current site
// @author       You
// @match        *://*/*
// @license MIT
// @grant        GM_openInTab
// @grant        GM_registerMenuCommand
// ==/UserScript==

(function() {
    'use strict';
    
    let domain = window.location.hostname;
    // www.を削除
    if (domain.startsWith('www.')) {
        domain = domain.substring(4);
    }
    
    // GreasyForkで検索
    if (typeof GM_registerMenuCommand !== 'undefined') {
        GM_registerMenuCommand(`Search GreasyFork for ${domain}`, function() {
            const url = `https://greasyfork.org/ja/scripts/by-site/${domain}?filter_locale=0`;
            GM_openInTab(url, false);
        });
        
        // Sleazyforkで検索
        GM_registerMenuCommand(`Search Sleazyfork for ${domain}`, function() {
            const url = `https://sleazyfork.org/ja/scripts/by-site/${domain}?filter_locale=0`;
            GM_openInTab(url, false);
        });
    }
})();