Add Download Link on zhelper v4 search page

在zhelper v4的搜索页面添加 download 点击就下载 这又又是chatgpt写的 哈哈哈

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Add Download Link on zhelper v4 search page
// @description		在zhelper v4的搜索页面添加 download 点击就下载 这又又是chatgpt写的  哈哈哈
// @namespace   https://download.v4.zhelper.net/download/
// @include     https://download.v4.zhelper.net/download/*
// @match  *.zhelper.net/search/*
// @version     1
// @grant       none 
// @author			chatgpt
// @license MIT
// ==/UserScript==

// Find all elements with the "list-group-item" class
var items = document.getElementsByClassName("list-group-item");

// Loop through each item
for (var i = 0; i < items.length; i++) {
  var item = items[i];

  // Use a regular expression to capture the part of the URL that follows "/download/"
  var match = item.href.match(/\/download\/(.*)/);

  // Check if the regular expression matched the URL
  if (match && match.length > 1) {
    // The part of the URL that follows "/download/" is the first capture group (index 1)
    var downloadUrl = match[1];

    // Create a new link element
    var link = document.createElement("a");
    link.innerText = "download";
    link.href = "https://test2.zlib.download/download/" + downloadUrl;
    link.className = "download-link";

    // Add the link to the page
    item.appendChild(link);
  }
}