Greasy Fork

Greasy Fork is available in English.

SleazyFork 到 GreasyFork 链接桥接

自动将 SleazyFork 上不可用的链接重定向到 GreasyFork/

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name          SleazyFork to GreasyFork Link Bridge
// @name:de       SleazyFork zu GreasyFork Link-Brücke
// @name:fr       SleazyFork to GreasyFork Link Bridge
// @name:es       Enlace entre SleazyFork y GreasyFork
// @name:it       SleazyFork to GreasyFork Link Bridge
// @name:ru       SleazyFork — GreasyFork Связующее звеno
// @name:zh-CN    SleazyFork 到 GreasyFork 链接桥接
//
// @description   Redirects unavailable links from SleazyFork to GreasyFork automatically.
// @description:de  Leitet nicht verfügbare Links von SleazyFork automatisch auf GreasyFork weiter.
// @description:fr  Redirige automatiquement les liens indisponibles de SleazyFork vers GreasyFork.
// @description:es  Redirige automáticamente los enlaces no disponibles de SleazyFork a GreasyFork.
// @description:it  Reindirizza automaticamente i link non disponibili da SleazyFork a GreasyFork.
// @description:ru  Автоматически перенаправляет недоступные ссылки из SleazyFork в GreasyFork.
// @description:zh-CN 自动将 SleazyFork 上不可用的链接重定向到 GreasyFork/
//
// @version      0.0.8
// @author       Wack.3gp (http://greasyfork.icu/users/4792)
// @copyright    2026+, Wack.3gp
// @namespace    http://greasyfork.icu/users/4792
// @license      CC BY-NC-SA-4.0; https://creativecommons.org/licenses/by-nc-sa/4.0/
// @icon         https://sleazyfork.org/vite/assets/blacklogo16-DftkYuVe.png
//
// @match        https://sleazyfork.org/*users/*
//
// @grant        GM_xmlhttpRequest
// @grant        GM_info
// @grant        GM_notification
// @connect      sleazyfork.org
//
// @supportURL      http://greasyfork.icu/scripts/576108/feedback
// @compatible      Chrome tested with Tampermonkey
// @contributionURL https://www.paypal.com/donate?hosted_button_id=BYW9D395KJWZ2
// @contributionAmount €1.00
// ==/UserScript==

(function() {
    'use strict';

    const handleCoffeeDonation = () => {
        let runs = parseInt(localStorage.getItem('bridge_click_runs') || '0');
        runs++;
        localStorage.setItem('bridge_click_runs', runs);

        if (runs % 50 === 0) {
            const donationUrl = (typeof GM_info !== 'undefined') ? GM_info.script.header.match(/@contributionURL\s+(.+)/)[1] : "https://www.paypal.com/donate?hosted_button_id=BYW9D395KJWZ2";
            
            GM_notification({
                title: '☕ Support Wack.3gp',
                text: `You've used the "Link Bridge" ${runs} times! Helpful? Click here to buy me a coffee.`,
                image: 'https://sleazyfork.org/vite/assets/blacklogo96-CxYTSM_T.png',
                timeout: 10000,
                onclick: function() {
                    window.open(donationUrl, "_blank");
                }
            });
        }
    };

    const scriptItems = document.querySelectorAll('li[data-script-id]');

    scriptItems.forEach(item => {
        const link = item.querySelector('.script-link');
        if (!link) return;

        const fullUrl = link.href;

        GM_xmlhttpRequest({
            method: "HEAD",
            url: fullUrl,
            onload: function(response) {
                if (response.status === 404) {
                    const allLinksInItem = item.querySelectorAll('a');
                    
                    allLinksInItem.forEach(a => {
                        const currentHref = a.getAttribute('href');
                        
                        if (currentHref) {
                            if (currentHref.startsWith('/')) {
                                a.href = "http://greasyfork.icu" + currentHref;
                            } else if (currentHref.includes('sleazyfork.org')) {
                                a.href = currentHref.replace('sleazyfork.org', 'greasyfork.org');
                            }

                            a.addEventListener('click', handleCoffeeDonation);
                        }
                    });
                }
            }
        });
    });
})();