1337x - Mark Untrusted

Marks torrents uploaded by untrusted users by fetching names from the pirated games list.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         1337x - Mark Untrusted
// @namespace    https://greasyfork.org/es/users/825144-aitronz
// @version      1.5
// @description  Marks torrents uploaded by untrusted users by fetching names from the pirated games list.
// @author       aitronz
// @match        *://1337x.to/*
// @match        *://1337x.st/*
// @match        *://x1337x.ws/*
// @match        *://x1337x.eu/*
// @match        *://x1337x.se/*
// @match        *://x1337x.cc/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    const userListURL = 'https://rentry.org/pgames/raw';

    const normalizeName = name => {
        let normalized = name.replace(/\s+/g, '').toLowerCase().replace(/[^a-z0-9]/g, '');
        return normalized.includes('igggames') && !normalized.includes('igggamescom') ? normalized + 'com' : normalized;
    };

    const markRows = userList => {
        document.querySelectorAll('table.table-list tbody tr').forEach(row => {
            const uploaderCell = row.querySelector('.coll-5 a');
            if (uploaderCell) {
                const normalizedUploader = normalizeName(uploaderCell.textContent.trim());
                if (userList.includes(normalizedUploader)) {
                    row.style.cssText = 'background-color: #cccccc; opacity: 0.5; position: relative;';
                    const untrustedLabel = Object.assign(document.createElement('div'), {
                        textContent: 'Untrusted',
                        style: 'position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); color: red; font-size: 20px; font-weight: bold; text-align: center; line-height: ' + row.offsetHeight + 'px; pointer-events: none; z-index: 1;'
                    });
                    row.appendChild(untrustedLabel);
                }
            }
        });
    };

    const fetchUserList = () => {
        fetch(userListURL)
            .then(response => response.text())
            .then(data => {
                const userList = [];
                const startSection = "###Untrusted uploaders";
                const endSection = "*****";
                const startIdx = data.indexOf(startSection);
                const endIdx = data.indexOf(endSection, startIdx);
                const untrustedSection = data.substring(startIdx, endIdx);
                const lines = untrustedSection.split("\n");
                const exclusionPhrase = "Any user from The Pirate Bay / TPB";

                lines.forEach(line => {
                    const trimmedLine = line.trim();
                    if (trimmedLine.startsWith("-")) {
                        if (!trimmedLine.includes(exclusionPhrase)) {
                            let uploader = trimmedLine.slice(1).replace(/\*/g, '').trim();
                            if (uploader.includes(" - ")) {
                                uploader = uploader.split(" - ")[0].trim();
                            }
                            userList.push(...uploader.split("/").map(normalizeName));
                        }
                    }
                });

                console.log('List of untrusted uploaders:', userList);
                markRows(userList);
            })
            .catch(console.error);
    };

    const waitForTable = () => {
        const checkInterval = setInterval(() => {
            if (document.querySelector('table.table-list tbody')) {
                clearInterval(checkInterval);
                fetchUserList();
            }
        }, 50);
    };

    waitForTable();
})();