Replace Links with Images on 1337x.to

Replace specified links with images on 1337x.to

目前為 2024-08-10 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Replace Links with Images on 1337x.to
// @namespace    http://tampermonkey.net/
// @version      0.1
// @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;
        // 检查链接是否匹配指定的格式
        const match = href.match(/https:\/\/imgtraffic\.com\/i-1\/(\d{4}\/\d{2}\/\d{2}\/[a-z0-9]+)\.jpeg\.html/);
        if (match) {
            const imgSrc = `https://imgtraffic.com/1/${match[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);
        }
    });
})();