Greasy Fork

来自缓存

Greasy Fork is available in English.

1ptba/hdfans-快捷下载种子

在主页列表添加一个按键下载种子文件,不用打开详情页面

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         1ptba/hdfans-快捷下载种子
// @namespace    http://shenhaisu.cc/
// @version      1.1
// @description  在主页列表添加一个按键下载种子文件,不用打开详情页面
// @author       ShenHaiSu_KimSama
// @match        https://1ptba.com/torrents.php
// @match        https://1ptba.com/torrents.php?*
// @match        https://hdfans.org/torrents.php
// @match        https://hdfans.org/torrents.php?*
// @grant        none
// @license      MIT
// @noframes
// ==/UserScript==

(function () {
  // 种子列表:/torrents.php?inclbookmarked=0&incldead=1&spstate=0&page=1
  // 种子详情:/details.php?id=8785&hit=1
  // 种子下载:/download.php?id=8785
  let baseURL = location.origin;
  document
    .querySelectorAll("table.torrentname>tbody")
    .forEach((item) => mainfunc(item));

  function mainfunc(tbody) {
    let newNode = document.createElement("button");
    let targetURL = `${baseURL}/download.php?id=${getTorrentID(tbody)}`;
    newNode.innerText = "下载";
    newNode.style.fontSize = "12px";
    tbody.firstChild.children[2].firstChild.appendChild(newNode);
    newNode.addEventListener("click", () => open(targetURL));
  }

  function getHref(tbody) {
    return tbody.firstChild.children[1].querySelector("a[href]").href || "null";
  }

  function getTorrentID(tbody) {
    return getHref(tbody)
      .match(/id=[\w]+/)[0]
      .replace("id=", "");
  }
})();