Replace Links with Images on 1337x.to

Replace specified links with images on 1337x.to

2024-08-10 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Replace Links with Images on 1337x.to
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Replace specified links with images on 1337x.to
// @author       Wei Zong
// @match        *://1337x.to/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // 获取所有的a标签
    const links = document.querySelectorAll('a.js-modal-url');

    links.forEach(link => {
        const href = link.href;

        // 检查链接是否匹配 imgtraffic.com 的两种格式
        const imgtrafficMatch = href.match(/https:\/\/imgtraffic\.com\/[a-z]-1\/(\d{4}\/\d{2}\/\d{2}\/[a-z0-9]+)\.jpeg\.html/);
        if (imgtrafficMatch) {
            const imgSrc = `https://imgtraffic.com/1/${imgtrafficMatch[1]}.jpeg`;
            const imgElement = document.createElement('img');
            imgElement.src = imgSrc;
            imgElement.dataset.original = imgSrc;
            imgElement.classList.add('img-responsive', 'descrimg', 'lazy');
            imgElement.style.display = 'block';

            link.parentNode.replaceChild(imgElement, link);
        }

        // 检查链接是否匹配 37xpics.space 格式
        const imgElement = link.querySelector('img');
        if (imgElement && imgElement.src && imgElement.src.includes('37xpics.space/images')) {
            const src = imgElement.src.replace('.th.jpg', '.jpg'); // 替换 .th.jpg 为 .jpg
            imgElement.src = src;
            imgElement.dataset.original = src;
            link.parentNode.replaceChild(imgElement, link);
        }
    });

    // 获取所有的img标签
    const imgs = document.querySelectorAll('img');

    imgs.forEach(img => {
        const src = img.src;
        const dataOriginal = img.dataset.original;

        // 替换 imgtraffic.com 中的 /1s/ 为 /1/
        if (src.includes('https://imgtraffic.com/1s/')) {
            const newSrc = src.replace('https://imgtraffic.com/1s/', 'https://imgtraffic.com/1/');
            img.src = newSrc;
        }

        if (dataOriginal && dataOriginal.includes('https://imgtraffic.com/1s/')) {
            const newDataOriginal = dataOriginal.replace('https://imgtraffic.com/1s/', 'https://imgtraffic.com/1/');
            img.dataset.original = newDataOriginal;
        }
    });
})();