Realtime Domain Scanner

Сканирует домены на сайте в реальном времени и выводит их в текстовое поле с сортировкой в столбик.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Realtime Domain Scanner
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Сканирует домены на сайте в реальном времени и выводит их в текстовое поле с сортировкой в столбик.
// @author       https://github.com/lReDragol/Tampermonkey
// @license      MIT
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const container = document.createElement('div');
    container.style.position = 'fixed';
    container.style.top = '10px';
    container.style.right = '10px';
    container.style.width = '300px';
    container.style.height = '400px';
    container.style.overflowY = 'scroll';
    container.style.backgroundColor = 'white';
    container.style.border = '1px solid black';
    container.style.zIndex = '10000';
    container.style.padding = '10px';
    container.style.fontSize = '12px';
    container.style.fontFamily = 'monospace';
    container.style.color = 'black';
    container.style.whiteSpace = 'pre-wrap';
    document.body.appendChild(container);

    const domainSet = new Set();

    function addDomain(domain) {
        if (!domainSet.has(domain)) {
            domainSet.add(domain);
            const domainList = Array.from(domainSet).sort().join('\n');
            container.textContent = domainList;
        }
    }

    function scanPerformanceEntries() {
        const entries = performance.getEntriesByType('resource');
        entries.forEach(entry => {
            try {
                const urlObj = new URL(entry.name);
                addDomain(urlObj.hostname);
            } catch (e) {
                console.error('Error parsing URL from performance entry:', entry.name);
            }
        });
    }

    setInterval(scanPerformanceEntries, 1000);

    const originalOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method, url) {
        try {
            const urlObj = new URL(url);
            addDomain(urlObj.hostname);
        } catch (e) {
            console.error('Error parsing URL:', url);
        }
        return originalOpen.apply(this, arguments);
    };

    const originalFetch = window.fetch;
    window.fetch = function(input, init) {
        try {
            const url = typeof input === 'string' ? input : input.url;
            const urlObj = new URL(url);
            addDomain(urlObj.hostname);
        } catch (e) {
            console.error('Error parsing fetch URL:', input);
        }
        return originalFetch.apply(this, arguments);
    };

    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            if (mutation.addedNodes) {
                mutation.addedNodes.forEach((node) => {
                    if (node.tagName) {
                        const src = node.src || node.href;
                        if (src) {
                            try {
                                const urlObj = new URL(src);
                                addDomain(urlObj.hostname);
                            } catch (e) {
                                console.error('Error parsing tag URL:', src);
                            }
                        }
                    }
                });
            }
        });
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();