Greasy Fork

Greasy Fork is available in English.

MioBT磁链增强

在MioBT的列表页添加一个磁链图标从而允许你不进入详情页直接进行下载

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         MioBT磁链增强
// @namespace    http://tampermonkey.net/
// @version      1.02
// @description  在MioBT的列表页添加一个磁链图标从而允许你不进入详情页直接进行下载
// @author       Yukiteru
// @match        *://www.miobt.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const TRACKER_URL = 'http://open.acgtracker.com:1096/announce';
    const MAGNET_ICON_TEXT = '🧲';
    const HEADER_TEXT = '磁链';

    const listTable = document.querySelector('#listTable');
    if (!listTable) {
        return;
    }

    const thead = listTable.querySelector('thead tr');
    const titleHeader = thead?.querySelector('th.l3');

    if (thead && titleHeader) {
        const newTh = document.createElement('th');
        newTh.textContent = HEADER_TEXT;
        newTh.className = 'tableHeaderOver';
        newTh.setAttribute('axis', 'string');
        newTh.style.textAlign = 'center';
        newTh.style.width = '35px';
        titleHeader.parentNode.insertBefore(newTh, titleHeader.nextSibling);
    }

    const links = listTable.querySelectorAll('tbody tr td a[href^="show-"]');

    links.forEach(link => {
        const parentTd = link.closest('td');
        if (!parentTd) return;

        const href = link.getAttribute('href');
        if (!href) return;

        const match = href.match(/^show-([a-f0-9]{40})\.html$/i);
        if (!match || !match[1]) {
            return;
        }
        const infoHash = match[1].toLowerCase();

        const magnetHref = `magnet:?xt=urn:btih:${infoHash}&tr=${encodeURIComponent(TRACKER_URL)}`;

        const newTd = document.createElement('td');
        newTd.style.textAlign = 'center';

        const magnetLink = document.createElement('a');
        magnetLink.href = magnetHref;
        magnetLink.textContent = MAGNET_ICON_TEXT;
        magnetLink.style.textDecoration = 'none';
        magnetLink.style.fontSize = '1.1em';

        newTd.appendChild(magnetLink);

        parentTd.parentNode.insertBefore(newTd, parentTd.nextSibling);
    });

})();