PearCrypt Skip

Extract all direct links on PearCrypt without the site loading all its bloated garbage.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         PearCrypt Skip
// @version      05-18-26
// @description  Extract all direct links on PearCrypt without the site loading all its bloated garbage.
// @author       maybeyou
// @match        https://pearcrypt.lol/container/*
// @grant        none
// @run-at       document-start
// @namespace https://greatest.deepsurf.us/users/1122886
// ==/UserScript==

(function() {
    'use strict';

    var s = document.createElement('style');
    s.textContent = 'body{display:none!important}';
    document.documentElement.appendChild(s);

    function ready(fn) {
        if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', fn);
        else fn();
    }

    function waitEl(sel, ms) {
        return new Promise(function(res, rej) {
            var t = Date.now();
            function check() {
                var el = document.querySelector(sel);
                if (el) return res(el);
                if (Date.now() - t > (ms||20000)) return rej();
                requestAnimationFrame(check);
            }
            check();
        });
    }

    function waitDialog(ms) {
        return new Promise(function(res, rej) {
            var obs = new MutationObserver(function() {
                var d = document.querySelector('[role="dialog"]');
                if (d && d.dataset.state === 'open') { obs.disconnect(); res(d); }
            });
            obs.observe(document.body, {childList:true, subtree:true, attributes:true, attributeFilter:['data-state']});
            setTimeout(function(){ obs.disconnect(); rej(); }, ms||8000);
        });
    }

    async function getLinks() {
        var btn = await waitEl('button:has(svg.lucide-link2)');
        btn.click();
        var dlg = await waitDialog();
        var els = dlg.querySelectorAll('div[data-radix-scroll-area-viewport] div.rounded-md');
        return Array.from(els).map(function(e){ return e.textContent.trim(); });
    }

    function show(links) {
        window.stop();
        document.documentElement.innerHTML = '';
        var pre = document.createElement('pre');
        pre.textContent = links.join('\n');
        pre.style.cssText = 'margin:20px;font-family:monospace;white-space:pre-wrap;word-break:break-all';
        document.body.appendChild(pre);
    }

    ready(function() {
        getLinks().then(function(links) {
            if (!links.length) throw new Error();
            show(links);
        }).catch(function() {
            document.documentElement.innerHTML = 'Error';
        });
    });
})();