Greasy Fork is available in English.

Xingtan Download Edited Torrents

个人中心获取已编辑的种子的下载链接

  1. // ==UserScript==
  2. // @name Xingtan Download Edited Torrents
  3. // @namespace https://github.com/hui-shao
  4. // @homepage https://greasyfork.org/zh-CN/scripts/484514
  5. // @version 0.1
  6. // @description 个人中心获取已编辑的种子的下载链接
  7. // @license GPLv3
  8. // @author hui-shao
  9. // @match https://xingtan.one/userdetails.php?*
  10. // @icon https://xingtan.one/favicon.ico
  11. // @grant none
  12. // @require https://cdn.bootcss.com/jquery/3.7.1/jquery.min.js
  13.  
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. function createButton() {
  20. const father_node = document.querySelector("td:has(>div#ka5)");
  21. button.id = "btn001";
  22. button.textContent = "提取链接";
  23. button.style.borderRadius= "6px"
  24. button.style.height = "40px";
  25. button.style.width = "15%";
  26. button.style.backgroundColor = "#76EEC6";
  27. button.style.display = "none";
  28. button.onclick = async function () {
  29. button.disabled = true;
  30. get_passkey();
  31. button.disabled = false;
  32. };
  33. father_node.appendChild(button);
  34. }
  35.  
  36. function get_passkey() {
  37. let passkey = "";
  38. const passkey_url = "https://xingtan.one/usercp.php";
  39.  
  40. let arr = document.querySelectorAll("div#ka5 tbody>tr>td.rowfollow[align=left]>a");
  41. let url_str = "";
  42.  
  43. $.when($.get(passkey_url))
  44. .done(function(resp) {
  45. // 处理成功的响应
  46. let tr_father = $(resp).find("tbody>tr:has(>td.nowrap:contains('密钥'))");
  47. passkey = $(tr_father).find(":last-child").text()
  48. console.log(passkey)
  49.  
  50. for (let i=0; i < arr.length; i++){
  51. url_str += arr[i].href.replace("details", "download") + "&passkey=" + passkey + "\n";
  52. }
  53. download_txt("torrent_urls_withpasskey",url_str);
  54.  
  55. })
  56. .fail(function(error) {
  57. // 处理失败的请求
  58. alert("请求passkey失败, 请手动添加:" + error.status + " " + error.statusText);
  59. for (let i=0; i < arr.length; i++){
  60. url_str += arr[i].href.replace("details", "download") + "\n";
  61. }
  62. download_txt("torrent_urls",url_str);
  63.  
  64. });
  65. }
  66.  
  67. function download_txt(filename, text) {
  68. console.debug("[Script] Start Download.");
  69. let pom = document.createElement('a');
  70. pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
  71. pom.setAttribute('download', filename);
  72. pom.click();
  73. }
  74.  
  75.  
  76. var button = document.createElement("button");
  77.  
  78. document.onreadystatechange = ()=>{
  79. if(document.readyState == "complete") {
  80. console.debug("[Script] Document Complete.");
  81.  
  82. createButton();
  83.  
  84. // 监听节点变化
  85. let elem = document.querySelector("div#ka5");
  86. const observer = new MutationObserver((mutationsList, observer) => {
  87. console.log(mutationsList, observer);
  88. button.style.display = elem.style.display;
  89. });
  90. observer.observe(elem, {childList: true, attributes: true });
  91. }
  92. };
  93.  
  94. })();