zimuku

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

  1. // ==UserScript==
  2. // @name zimuku
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.12
  5. // @description zimuku明细页直接显示下载地址
  6. // @author backrock12
  7. // @match *zmk.pw/*
  8. // @include /.*zimuku\..*\/.*/
  9. // @include *srtku.com/*
  10. // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js
  11. // @grant GM_xmlhttpRequest
  12. // @grant GM_download
  13. // @license MIT
  14. // ==/UserScript==
  15.  
  16. (function () {
  17. "use strict";
  18.  
  19. async function gethtml(url) {
  20. return new Promise((resolve, reject) => {
  21. GM_xmlhttpRequest({
  22. url: url,
  23. method: "GET",
  24. onload: function (response) {
  25. resolve(response.responseText);
  26. },
  27. });
  28. });
  29. }
  30.  
  31. async function showurl() {
  32. let lhref = location.href;
  33. lhref = lhref.replace("/detail/", "/dld/");
  34.  
  35. const htmltxt = await gethtml(lhref);
  36.  
  37. if (!htmltxt) return;
  38. let doc = $("<html></html>");
  39. doc.html(htmltxt);
  40. let td = doc.find(".col-xs-12 td:nth-child(1) div");
  41. //console.log(td);
  42.  
  43. const subinfo = $(".subinfo");
  44. subinfo.append(td);
  45. }
  46.  
  47. function noad() {
  48. function subnoad(csspath) {
  49. const ad1 = $(csspath);
  50. if (csspath.length > 0) ad1.css("display", "none");
  51. }
  52.  
  53. subnoad(".table");
  54. subnoad("div.tbhd");
  55. subnoad("font[color=#ca6445]");
  56. subnoad(".rside");
  57. subnoad(".rater-click-tips");
  58. subnoad(".rater-star-item-tips");
  59. }
  60.  
  61. async function subdown(url) {
  62. url = url.replace("/detail/", "/dld/");
  63. const htmltxt = await gethtml(url);
  64.  
  65. if (!htmltxt) return;
  66. let doc = $("<html></html>");
  67. doc.html(htmltxt);
  68. let td = doc.find(".down ul li a");
  69. if (td.length == 0) {
  70. alert("获取下载页失败");
  71. }
  72. const durl = td[0].href;
  73. td[0].click();
  74. console.log(durl);
  75.  
  76. return;
  77. GM_xmlhttpRequest({
  78. url: durl,
  79. method: "GET",
  80. onload: function (response) {
  81. console.log(response.finalUrl);
  82. },
  83. });
  84.  
  85. return;
  86. GM_download({
  87. url: durl,
  88. name: "name",
  89. onerror: (error) => {
  90. console.log(url);
  91. console.log(error);
  92. alert("下载失败");
  93. },
  94. });
  95. }
  96.  
  97. function showtable() {
  98. var ischeckbox = false;
  99.  
  100. //const alist = $("#subtb td.first a");
  101. const alist = $("table td.first > a");
  102.  
  103. alist.each((i, e) => {
  104. if (e.getAttribute("SHOWTABLE") == "true") {
  105. return;
  106. }
  107. e.setAttribute("SHOWTABLE", "true");
  108.  
  109. console.log(e.href);
  110.  
  111. const td = document.createElement("td");
  112. const button = document.createElement("button");
  113. button.id = "TALLDownBtnpage";
  114. button.textContent = "下载";
  115. button.className = "btn btn-md btn-default btn-sm";
  116. button.onclick = () => {
  117. subdown(e.href);
  118. };
  119. td.append(button);
  120. e.parentNode.parentNode.append(td);
  121.  
  122. //---------------------
  123. //insertcheckbox(e, i);
  124. });
  125.  
  126. function insertcheckbox(e, i) {
  127. function alldown() {
  128. const list = $("input[type='checkbox']:checked");
  129. //console.log(list);
  130. list.each(async (i, e) => {
  131. const vurl = $(e).attr("value");
  132. if (vurl) {
  133. await subdown(vurl);
  134. }
  135. });
  136. }
  137.  
  138. if (!ischeckbox) {
  139. $("th.first").before(
  140. "<td> <input style='width: 25px;height: 17px;' type='checkbox' id='allcheck' class='checkbox' /></td>"
  141. );
  142.  
  143. const allbutton = document.createElement("button");
  144. allbutton.id = "TALLDownBtnpage";
  145. allbutton.textContent = "下载";
  146. allbutton.className = "btn btn-md btn-default btn-sm";
  147. allbutton.onclick = alldown;
  148. $("th.first").append(allbutton);
  149.  
  150. $("#subtb thead > tr").append(
  151. "<td> <input style='width: 25px;height: 17px;' type='checkbox' id='allcheck' class='checkbox' /></td>"
  152. );
  153.  
  154. $("#allcheck").click(function () {
  155. $("input[type='checkbox']").attr("checked", $(this).prop("checked"));
  156. });
  157. ischeckbox = true;
  158. }
  159.  
  160. const td2 = document.createElement("td");
  161. const check = document.createElement("input");
  162. check.setAttribute("type", "checkbox");
  163. check.setAttribute("id", "mayi");
  164. $(td2).append(
  165. "<input style='width: 25px;height: 17px;' type='checkbox' id='downcheck' class='checkbox' value='" +
  166. e.href +
  167. "' name='" +
  168. i +
  169. "'/>"
  170. );
  171.  
  172. $(e).parent().before(td2);
  173. }
  174. }
  175.  
  176. function addtable() {}
  177.  
  178. function start() {
  179. if (/subs\/.*/.test(location.href)) {
  180. console.log("002");
  181. // noad();
  182. showtable();
  183. } else if (/detail\/.*/.test(location.href)) {
  184. console.log("003");
  185. noad();
  186. showurl();
  187. }else
  188. {
  189. console.log("001");
  190. showtable();
  191. }
  192. }
  193.  
  194. start();
  195. })();