zimuku

zimuku明细页直接显示下载地址

目前為 2021-08-18 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         zimuku
// @namespace    http://tampermonkey.net/
// @version      3.10
// @description  zimuku明细页直接显示下载地址
// @author       backrock12
// @include      /.*zimuku\..*\/.*/
// @require      http://libs.baidu.com/jquery/2.0.0/jquery.min.js
// @grant        GM_xmlhttpRequest
// @grant        GM_download
// ==/UserScript==

(function () {
  "use strict";

  async function gethtml(url) {
    return new Promise((resolve, reject) => {
      GM_xmlhttpRequest({
        url: url,
        method: "GET",
        onload: function (response) {
          resolve(response.responseText);
        },
      });
    });
  }

  async function showurl() {
    let lhref = location.href;
    lhref = lhref.replace("/detail/", "/dld/");

    const htmltxt = await gethtml(lhref);

    if (!htmltxt) return;
    let doc = $("<html></html>");
    doc.html(htmltxt);
    let td = doc.find(".col-xs-12 td:nth-child(1) div");
    //console.log(td);

    const subinfo = $(".subinfo");
    subinfo.append(td);
  }

  function noad() {
    function subnoad(csspath) {
      const ad1 = $(csspath);
      if (csspath.length > 0) ad1.css("display", "none");
    }

    subnoad(".table");
    subnoad("div.tbhd");
    subnoad("font[color=#ca6445]");
    subnoad(".rside");
    subnoad(".rater-click-tips");
    subnoad(".rater-star-item-tips");
  }

  async function subdown(url) {
    url = url.replace("/detail/", "/dld/");
    const htmltxt = await gethtml(url);

    if (!htmltxt) return;
    let doc = $("<html></html>");
    doc.html(htmltxt);
    let td = doc.find(".down  ul li a");
    if (td.length == 0) {
      alert("获取下载页失败");
    }
    const durl = td[0].href;
    td[0].click();
    console.log(durl);

    return;
    GM_xmlhttpRequest({
      url: durl,
      method: "GET",
      onload: function (response) {
        console.log(response.finalUrl);
      },
    });

    return;
    GM_download({
      url: durl,
      name: "name",
      onerror: (error) => {
        console.log(url);
        console.log(error);
        alert("下载失败");
      },
    });
  }

  function showtable() {
    var ischeckbox = false;

    //const alist = $("#subtb td.first a");
    const alist = $("table td.first > a");

    alist.each((i, e) => {
      if (e.getAttribute("SHOWTABLE") == "true") {
        return;
      }
      e.setAttribute("SHOWTABLE", "true");

      console.log(e.href);

      const td = document.createElement("td");
      const button = document.createElement("button");
      button.id = "TALLDownBtnpage";
      button.textContent = "下载";
      button.className = "btn btn-md btn-default btn-sm";
      button.onclick = () => {
        subdown(e.href);
      };
      td.append(button);
      e.parentNode.parentNode.append(td);

      //---------------------
      //insertcheckbox(e, i);
    });

    function insertcheckbox(e, i) {
      function alldown() {
        const list = $("input[type='checkbox']:checked");
        //console.log(list);
        list.each(async (i, e) => {
          const vurl = $(e).attr("value");
          if (vurl) {
            await subdown(vurl);
          }
        });
      }

      if (!ischeckbox) {
        $("th.first").before(
          "<td> <input  style='width: 25px;height: 17px;' type='checkbox' id='allcheck'  class='checkbox' /></td>"
        );

        const allbutton = document.createElement("button");
        allbutton.id = "TALLDownBtnpage";
        allbutton.textContent = "下载";
        allbutton.className = "btn btn-md btn-default btn-sm";
        allbutton.onclick = alldown;
        $("th.first").append(allbutton);

        $("#subtb  thead > tr").append(
          "<td> <input  style='width: 25px;height: 17px;' type='checkbox' id='allcheck'  class='checkbox' /></td>"
        );

        $("#allcheck").click(function () {
          $("input[type='checkbox']").attr("checked", $(this).prop("checked"));
        });
        ischeckbox = true;
      }

      const td2 = document.createElement("td");
      const check = document.createElement("input");
      check.setAttribute("type", "checkbox");
      check.setAttribute("id", "mayi");
      $(td2).append(
        "<input   style='width: 25px;height: 17px;' type='checkbox' id='downcheck' class='checkbox' value='" +
          e.href +
          "' name='" +
          i +
          "'/>"
      );

      $(e).parent().before(td2);
    }
  }

  function addtable() {}

  function start() {
    if (/.*zimuku[^\/]*/.test(location.href)) {
      console.log("SY");
      showtable();
    } else if (/.*zimuku\..*\/subs\/.*/.test(location.href)) {
      // noad();
      showtable();
    } else if (/.*zimuku\..*\/detail\/.*/.test(location.href)) {
      noad();
      showurl();
    }
  }

  start();
})();