Add Download Link on zhelper v4 search page

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

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

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 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);
  }
}