Sleazy Fork is available in English.

自动获取磁链接并自动离线下载

  1. // ==UserScript==
  2. // @name 挊
  3. // @namespace 撸
  4. // @description 自动获取磁链接并自动离线下载
  5.  
  6.  
  7.  
  8.  
  9. // @include http*://javkey.com/*
  10. // @include http*://avsox1.com/*
  11. // @include http*://avxo.pw/*
  12. // @include http*://www.av28.com/*/movie/*
  13.  
  14. // @include http*://*javlibrary.com/*
  15. // @include http*://*javlib.com/*
  16. // @include http*://*javl10.com/*
  17. // @include http*://*19lib.com/*
  18. // @include http*://*j15av.com/*
  19. // @include http*://*d21b.com/*
  20.  
  21. // @include http*://www.libredmm.com/movies/*
  22.  
  23. // @include http*://www.javbus.com/*
  24. // @include http*://www.javbus.me/*
  25. // @include http*://www.javbus.in/*
  26.  
  27.  
  28. // @include http*://blog.jav4you.com/*
  29. // @include http*://*1pondo.tv/*/index.htm
  30. // @include http*://www.dmm.co.jp/digital/videoa/*
  31. // @include http*://www.jade-net-home.com/products/*
  32.  
  33. // @include http*://pan.baidu.com/disk/home*
  34. // @include http*://115.com/?tab=offline&mode=wangpan
  35. // @include http*://www.furk.net/users/files/add
  36.  
  37. // @version 1.51
  38. // @run-at document-end
  39. // @grant GM_xmlhttpRequest
  40. // @grant GM_setClipboard
  41. // @grant GM_setValue
  42. // @grant GM_getValue
  43. // @grant GM_addStyle
  44. // @grant GM_registerMenuCommand
  45. // ==/UserScript==
  46.  
  47. var main = {
  48. //av信息查询 类
  49. jav: {
  50. type: 0,
  51. re: /(javmoo|avio|avso|avxo|av28|javkey|avsox1).*movie.*/,
  52. insert_where: "#movie-share",
  53. vid: function () {
  54. return document.querySelector(".header").nextElementSibling.innerHTML;
  55. }
  56. },
  57. javlibrary: {
  58. type: 0,
  59. re: /(javlibrary|\d\dlib|jav\d\db|d21b).*\?v=.*/,
  60. insert_where: "#video_favorite_edit",
  61. vid: function () {
  62. return document.querySelector("#video_id").getElementsByClassName("text")[0].innerHTML;
  63. }
  64. },
  65. javbus: {
  66. type: 0,
  67. re: /javbus/,
  68. insert_where: "#star-div",
  69. vid: function () {
  70. return document.querySelector(".header").nextElementSibling.textContent;
  71. }
  72. },
  73. fanhaoku: {
  74. type: 0,
  75. re: /icpmp/,
  76. insert_where: ".mod_film",
  77. vid: function () {
  78. return document.querySelector(".title_inner").title;
  79. }
  80. },
  81. libredmm: {
  82. type: 0,
  83. re: /libredmm/,
  84. insert_where: ".container",
  85. vid: function () {
  86. return location.href.match(/products\/(.*)/)[1];
  87. }
  88. },
  89. blogjav4you: {
  90. type: 0,
  91. re: /blog\.jav4you\.com/,
  92. insert_where: ".posttext",
  93. vid: function () {
  94. return document.querySelector(".posttitle a").textContent.match(/\[(.*)\]/)[1];
  95. },
  96. },
  97. pondo1: {
  98. type: 0,
  99. re: /1pondo\.tv.*\/index.htm/,
  100. insert_where: ".hdg3",
  101. vid: function () {
  102. return location.pathname.split("/")[3];
  103. },
  104. },
  105. jadenethome:{
  106. type:0,
  107. re:/jade-net-home/,
  108. insert_where:".detailStory",
  109. vid:function(){
  110. return document.querySelector("#detailRight dl dd").textContent;
  111. }
  112. },
  113. dmm: {
  114. type: 0,
  115. re: /dmm\.co\.jp/,
  116. insert_where: ".lh4",
  117. vid: function () {
  118. var result = location.href.replace(/.*cid=/, "").replace(/\/\??.*/, "").match(/[^h_0-9].*/);
  119. return result[0] ? result[0].replace("00", "") : "";
  120. }
  121. },
  122.  
  123. //网盘下载 类
  124. //这些 $ 是真正的 jquery
  125. baidu: {
  126. type: 1,
  127. re: /pan\.baidu\.com/,
  128. fill_form: function (magnet) {
  129. document.querySelector(".g-button[data-button-id=b13]").click();
  130. setTimeout(function () {
  131. document.querySelector("#_disk_id_2").click();
  132. setTimeout(function () {
  133. document.querySelector("#share-offline-link").value = magnet;
  134. document.querySelector(".g-button[data-button-id=b65]").click();
  135. }, 500);
  136. }, 1500);
  137. }
  138. },
  139. 115: {
  140. type: 1,
  141. re: /115\.com/,
  142. fill_form: function (link) {
  143. var rsc = setInterval(function () {
  144. if (document.readyState == "complete") {
  145. clearInterval(rsc);
  146. setTimeout(function () {
  147. Core["OFFL5Plug"].OpenLink();
  148. setTimeout(function () {
  149. $("#js_offline_new_add").val(link);
  150. }, 300);
  151. }, 1000);
  152. }
  153. }, 400);
  154. }
  155. },
  156. letv: {
  157. type: 1,
  158. re: /cloud\.letv\.com/,
  159. fill_form: function (link) {
  160. setTimeout(function () {
  161. $("#offline-btn").click();
  162. setTimeout(function () {
  163. $("#offline_clear_complete").prev().click();
  164. setTimeout(function () {
  165. $("#offline-add-link").val(link);
  166. }, 500);
  167. }, 1000);
  168. }, 2000);
  169. }
  170. },
  171. furk: {
  172. type: 1,
  173. re: /www\.furk\.net/,
  174. fill_form: function (link) {
  175. setTimeout(function () {
  176. $("#url").val(link.replace("magnet:?xt=urn:btih:", ""));
  177. }, 1500);
  178. }
  179. },
  180. 360: {
  181. type: 1,
  182. re: /yunpan\.360\.cn\/my/,
  183. fill_form: function (link) {
  184. yunpan.cmdCenter.showOfflineDia();
  185. setTimeout(function () {
  186. $(".offdl-btn-create").click();
  187. setTimeout(function () {
  188. $("#offdlUrl").val(link);
  189. }, 500);
  190. }, 1000);
  191. }
  192. },
  193. uc: {
  194. type: 1,
  195. re: /disk\.yun\.uc\.cn\//,
  196. fill_form: function (link) {
  197. setTimeout(function () {
  198. $("#newuclxbtn_index").click();
  199. setTimeout(function () {
  200. $("#uclxurl").val(link);
  201. }, 1000);
  202. }, 1200);
  203. }
  204. },
  205.  
  206. };
  207.  
  208. var offline_sites = {
  209. baidu: {
  210. url: "http://pan.baidu.com/disk/home",
  211. name: "百度云",
  212. enable: true
  213. },
  214. 115: {
  215. name: "115离线",
  216. url: "http://115.com/?tab=offline&mode=wangpan",
  217. enable: true,
  218. },
  219. varv: {
  220. name: "乐视云",
  221. url: "http://cloud.letv.com/webdisk/home/index",
  222. enable: false
  223. },
  224. 360: {
  225. name: "360云",
  226. url: "http://yunpan.360.cn/my/",
  227. enable: false
  228. },
  229. uc: {
  230. name: "UC离线",
  231. url: "http://disk.yun.uc.cn/",
  232. enable: false
  233. },
  234. furk: {
  235. name: "Furk",
  236. url: "https://www.furk.net/users/files/add",
  237. enable: true
  238. },
  239. };
  240. var common = {
  241. add_style: function () {
  242. GM_addStyle([
  243. "#nong-table{border-collapse: initial !important;background-color: white !important;text-align: center !important;margin:10px auto;color:#666 !important;font-size:13px;text-align:center !important;border: 1px solid #cfcfcf !important;border-radius: 10px !important;}",
  244. "#nong-table a {margin-right: 5px !important;color:blue}",
  245. "#nong-table a:hover {color:#d20f00 !important;}",
  246. "#nong-table th,#nong-table td{text-align: inherit !important;height:30px;padding:0 1em 0 !important;}",
  247. ".nong-row{text-align: inherit !important;height:30px;padding:0 1em 0 !important;border: 1px solid #EFEFEF !important;}",
  248. ".nong-row:hover{background-color: #dae8ff !important;}",
  249. ".nong-offline-download{color: rgb(0, 180, 30) !important;}",
  250. ".nong-offline-download:hover{color:red !important;}",
  251. ].join(""));
  252. },
  253. handle_copy_event: function (event) {
  254. event.target.innerHTML = "成功";
  255. GM_setClipboard(event.target.href);
  256. setTimeout(function () {
  257. event.target.innerHTML = "复制";
  258. }, 1000);
  259. event.preventDefault(); //阻止跳转
  260. },
  261. handle_dl_event: function (event) {
  262. var mag = event.target.parentElement.parentElement.parentElement.getAttribute("mag");
  263. console.info("磁链接", mag);
  264. //console.log(0);
  265. GM_setValue("magnet", mag);
  266. },
  267.  
  268. reg_event: function () {
  269. var selector_event_map = [{
  270. selector: ".nong-copy",
  271. type: "click",
  272. fn: this.handle_copy_event
  273. }, {
  274. selector: ".nong-offline-download",
  275. type: "click",
  276. fn: this.handle_dl_event
  277. }];
  278. selector_event_map.forEach(function (obj) {
  279. Array.from(document.querySelectorAll(obj.selector)).forEach(function (elem) {
  280. elem.addEventListener(obj.type, obj.fn);
  281. })
  282. });
  283. /*
  284. for (var obj of selector_event_map) {
  285. for (var elem of document.querySelectorAll(obj.selector)) {
  286. //console.log(elem, obj.type, obj.fn);
  287. elem.addEventListener(obj.type, obj.fn);
  288. }
  289. }*/
  290. },
  291. parsetext: function (text) {
  292. var doc = null;
  293. try {
  294. doc = document.implementation.createHTMLDocument("");
  295. doc.documentElement.innerHTML = text;
  296. return doc;
  297. }
  298. catch (e) {
  299. alert("parse error");
  300. }
  301. },
  302. };
  303. var magnet_table = {
  304. template: {
  305. create_head: function (src) {
  306. var a = document.createElement("tr");
  307. a.className = "nong-row";
  308. a.id = "nong-head";
  309. var head_str = [
  310. "大小",
  311. "操作",
  312. "离线下载"
  313. ];
  314. var th_list = [document.createElement("th"), document.createElement("th"), document.createElement("th"), document.createElement("th")];
  315.  
  316. var select_box = document.createElement("select");
  317. var option_str = my_search.search_name_string;
  318. //console.log("get", GM_getValue("search_index"));
  319. var index = GM_getValue("search_index", 0);
  320. var op_value = 0;
  321. option_str.forEach(function (str) {
  322. var op = document.createElement("option");
  323. op.value = op_value;
  324. op.textContent = str;
  325. if (index == op_value) {
  326. op.setAttribute("selected", "selected");
  327. }
  328. op_value++;
  329. select_box.appendChild(op);
  330. });
  331. /*
  332. for (var str of option_str) {
  333. var op = document.createElement("option");
  334. op.value = op_value;
  335. op.textContent = str;
  336. if (index == op_value) {
  337. op.setAttribute("selected", "selected");
  338. }
  339. op_value++;
  340. select_box.appendChild(op);
  341. }*/
  342. select_box.addEventListener("change", function (e) {
  343. GM_setValue("search_index", this.value);
  344. run();
  345. });
  346. th_list[0].appendChild(select_box);
  347.  
  348. th_list[1].appendChild(document.createElement("a"));
  349. th_list[1].lastChild.setAttribute("href", src);
  350. th_list[1].lastChild.setAttribute("target", "_blank");
  351. th_list[1].lastChild.textContent = head_str[0];
  352.  
  353. th_list[2].appendChild(document.createElement("a"));
  354. th_list[2].lastChild.textContent = head_str[1];
  355.  
  356. th_list[3].appendChild(document.createElement("a"));
  357. th_list[3].lastChild.textContent = head_str[2];
  358.  
  359. th_list.forEach(function (th) {
  360. a.appendChild(th);
  361. });
  362. /*
  363. for (var th of th_list) {
  364. a.appendChild(th);
  365. }
  366. */
  367. return a;
  368. },
  369. create_row: function (data) {
  370. var tr = document.createElement("tr");
  371. tr.className = "nong-row";
  372. tr.setAttribute("mag", data.mag);
  373. var td = document.createElement("td");
  374. var list = [this.create_info(data.title, data.mag), this.create_size(data.size, data.src), this.create_operation(data.mag), this.create_offline()];
  375. list.forEach(function (elem) {
  376. var c = td.cloneNode(true);
  377. c.appendChild(elem);
  378. tr.appendChild(c);
  379. });
  380. /*
  381. for (var elem of [this.create_info(data.title, data.mag), this.create_size(data.size, data.src), this.create_operation(data.mag), this.create_offline()]) {
  382. var c = td.cloneNode(true);
  383. c.appendChild(elem);
  384. tr.appendChild(c);
  385. }
  386. */
  387. return tr;
  388. },
  389. create_row_for_sukebei: function (data) {
  390. var tr = document.createElement("tr");
  391. tr.className = "nong-row";
  392. tr.setAttribute("mag", data.mag);
  393. var td = document.createElement("td");
  394. var append_elems = [
  395.  
  396. (function (title, src, self) {
  397. return self.create_info(title, src);
  398. })(data.title, data.src, this),
  399.  
  400. (function (size, src, self) {
  401. return self.create_size(size, src);
  402. })(data.size, data.src, this),
  403.  
  404. (function (torrent_url, self) {
  405. var operate = self.create_operation(torrent_url);
  406. operate.firstChild.textContent = "种子";
  407. operate.firstChild.setAttribute("class", "nong-copy-sukebei");
  408. operate.firstChild.setAttribute("target", "_blank");
  409. return operate;
  410. })(data.torrent_url, this),
  411.  
  412. (function (self) {
  413. var div = document.createElement("div");
  414. div.textContent = "暂不支持离线下载";
  415. return div;
  416. })(this)];
  417. append_elems.forEach(function (elem) {
  418. var c = td.cloneNode(true);
  419. c.appendChild(elem);
  420. tr.appendChild(c);
  421. });
  422. /*
  423. for (var elem of append_elems) {
  424. var c = td.cloneNode(true);
  425. c.appendChild(elem);
  426. tr.appendChild(c);
  427. }
  428. */
  429. return tr;
  430. },
  431. create_info: function (title, mag) {
  432. var a = this.info.cloneNode(true);
  433. a.firstChild.textContent = title.length < max_title_length ? title : title.substr(0, max_title_length) + "...";
  434. a.firstChild.href = mag;
  435. a.title = title;
  436. return a;
  437. },
  438. create_size: function (size, src) {
  439. var a = this.size.cloneNode(true);
  440. a.textContent = size;
  441. a.href = src;
  442. return a;
  443. },
  444. create_operation: function (mag) {
  445. var a = this.operation.cloneNode(true);
  446. a.firstChild.href = mag;
  447. return a;
  448. },
  449. create_offline: function () {
  450. var a = this.offline.cloneNode(true);
  451. a.className = "nong-offline";
  452. return a;
  453. },
  454.  
  455. info: (function () {
  456. var a = document.createElement("div");
  457. var b = document.createElement("a");
  458. b.textContent = "name";
  459. b.href = "src";
  460. b.target = "_blank";
  461. a.appendChild(b);
  462. return a;
  463. })(),
  464. size: function () {
  465. var a = document.createElement("a");
  466. a.textContent = "size";
  467. a.target = "_blank";
  468. return a;
  469. }(),
  470. operation: (function () {
  471. var a = document.createElement("div");
  472. var copy = document.createElement("a");
  473. copy.className = "nong-copy";
  474. copy.textContent = "复制";
  475. a.appendChild(copy);
  476. return a;
  477. })(),
  478. offline: (function () {
  479. var a = document.createElement("div");
  480. var b = document.createElement("a");
  481. b.className = "nong-offline-download";
  482. b.target = "_blank";
  483. for (var k in offline_sites) {
  484. if (offline_sites[k].enable) {
  485. var c = b.cloneNode(true);
  486. c.href = offline_sites[k].url;
  487. c.textContent = offline_sites[k].name;
  488. a.appendChild(c);
  489. }
  490. }
  491. return a;
  492. })(),
  493. },
  494. generate_head: function () {
  495. var tab = document.createElement("table");
  496. tab.id = "nong-table";
  497. tab.appendChild(this.template.create_head("https://greasyfork.org/zh-CN/scripts/8392-%E6%8C%8A"));
  498. return tab;
  499. },
  500. generate: function (src, data) {
  501. //console.log(src);
  502. //console.log(data);
  503. var tab = document.querySelector("#nong-table");
  504. tab.querySelector("#nong-head th a").href = src;
  505. if (src.match("nyaa.si")) {
  506. data.forEach((d) => {
  507. tab.appendChild(this.template.create_row_for_sukebei(d));
  508. });
  509. /*
  510. for (var d of data) {
  511. tab.appendChild(this.template.create_row_for_sukebei(d));
  512. }
  513. */
  514. }
  515. else {
  516. data.forEach((d) => {
  517. tab.appendChild(this.template.create_row(d));
  518. });
  519. /*
  520. for (var d of data) {
  521. tab.appendChild(this.template.create_row(d));
  522. }
  523. */
  524. }
  525. return tab;
  526. },
  527.  
  528. };
  529. var my_search = {
  530. current: function (kw, cb) {
  531. var search = my_search[GM_getValue("search_index", 0)];
  532. try {
  533. return search(kw, cb);
  534. }
  535. catch (e) {
  536. this.search_error();
  537. }
  538. },
  539. search_error: function (r) {
  540. alert("搜索出现错误,请检查网络");
  541. },
  542. search_name_string: ["btso", "btdb", "nyaa.si", "btkitty","torrentkitty","btlibrary"],
  543. 0: function (kw, cb) {
  544. GM_xmlhttpRequest({
  545. method: "GET",
  546. url: "https://btso.pw/search/" + kw,
  547. onload: function (result) {
  548. let doc = common.parsetext(result.responseText);
  549. let data = [];
  550. let t = doc.getElementsByClassName("data-list")[0];
  551. if (t) {
  552. for (let elem of t.getElementsByTagName("a")) {
  553. if (!elem.className.match("btn")) {
  554. data.push({
  555. "title": elem.title,
  556. "mag": "magnet:?xt=urn:btih:" + elem.outerHTML.replace(/.*hash\//, "").replace(/" .*\n.*\n.*\n.*/, ""),
  557. "size": elem.nextElementSibling.textContent,
  558. "src": elem.href,
  559. });
  560. }
  561. }
  562. }
  563. else {
  564. data.push({
  565. "title": "没有找到磁链接",
  566. "mag": "",
  567. "size": "0",
  568. "src": result.finalUrl,
  569. });
  570. }
  571. cb(result.finalUrl, data);
  572. },
  573. onerror: function (e) {
  574. console.error(e);
  575. throw "search error";
  576. }
  577. });
  578. },
  579. 1: function (kw, cb) {
  580. GM_xmlhttpRequest({
  581. method: "GET",
  582. url: "http://btdb.to/q/" + kw + "/",
  583. onload: function (result) {
  584. let doc = common.parsetext(result.responseText);
  585. let data = [];
  586. let t = doc.getElementsByClassName("item-title");
  587. if (t) {
  588. for (let elem of t) {
  589. data.push({
  590. "title": elem.firstChild.title,
  591. "mag": elem.nextElementSibling.firstElementChild.href,
  592. "size": elem.nextElementSibling.children[1].textContent,
  593. "src": "https://btdb.in" + elem.firstChild.getAttribute("href"),
  594. });
  595. }
  596. }
  597. else {
  598. data.push({
  599. "title": "没有找到磁链接",
  600. "mag": "",
  601. "size": "0",
  602. "src": result.finalUrl,
  603. });
  604. }
  605.  
  606. cb(result.finalUrl, data);
  607. },
  608. onerror: function (e) {
  609. console.error(e);
  610. throw "search error";
  611. }
  612. });
  613. },
  614. 2: function (kw, cb) {
  615. GM_xmlhttpRequest({
  616. method: "GET",
  617. url: "https://sukebei.nyaa.si/?f=0&c=0_0&q=" + kw,
  618. onload: function (result) {
  619. let doc = common.parsetext(result.responseText);
  620. let data = [];
  621. let t = doc.querySelectorAll("tr.default");
  622. if (t.length!==0) {
  623. for (let elem of t) {
  624. data.push({
  625. "title": elem.querySelector("td:nth-child(2)>a:nth-child(1)").title,
  626. "mag": "",
  627. "torrent_url": "https://nyaa.si" + elem.querySelector("td:nth-child(3)>a:nth-child(1)").href,
  628. "size": elem.querySelector("td:nth-child(4)").textContent,
  629. "src": "https://nyaa.si" + elem.querySelector("td:nth-child(2)>a:nth-child(1)").href,
  630. });
  631. }
  632. }
  633. else {
  634. data.push({
  635. "title": "没有找到磁链接",
  636. "mag": "",
  637. "torrent_url": "",
  638. "size": "0",
  639. "src": result.finalUrl,
  640. });
  641. }
  642.  
  643. cb(result.finalUrl, data);
  644. },
  645. onerror: function (e) {
  646. console.error(e);
  647. throw "search error";
  648. }
  649. });
  650. },
  651. 3: function (kw, cb) {
  652. GM_xmlhttpRequest({
  653. method: "POST",
  654. url: "http://btkitty.pet/",
  655. data: "keyword=" + kw+"&hidden=true",
  656. headers: {
  657. "Content-Type": "application/x-www-form-urlencoded"
  658. },
  659. onload: function (result) {
  660. let doc = common.parsetext(result.responseText);
  661. let data = [];
  662. let t = doc.getElementsByClassName("list-con");
  663. if (t) {
  664. for (let elem of t) {
  665. data.push({
  666. "title": elem.querySelector("dt a").textContent,
  667. "mag": elem.querySelector("dd a").href,
  668. "size": elem.querySelector(".option span:nth-child(3) b").textContent,
  669. "src": elem.querySelector("dt a").href,
  670. });
  671. }
  672. }
  673. else {
  674. data.push({
  675. "title": "没有找到磁链接",
  676. "mag": "",
  677. "size": "0",
  678. "src": result.finalUrl,
  679. });
  680. }
  681. cb(result.finalUrl, data);
  682. },
  683. onerror: function (e) {
  684. console.error(e);
  685. throw "search error";
  686. }
  687. });
  688. },
  689. 4: function (kw, cb) {
  690. GM_xmlhttpRequest({
  691. method: "GET",
  692. url: "https://www.torrentkitty.tv/search/"+kw,
  693. onload: function (result) {
  694. let doc = common.parsetext(result.responseText);
  695. let data = [];
  696. let t = doc.querySelectorAll("#archiveResult tr");
  697. if (t) {
  698. t = Array.slice(t,1,t.length)
  699. for (let elem of t) {
  700. data.push({
  701. "title": elem.querySelector(".name").textContent,
  702. "mag": elem.querySelector(".action>a:nth-child(2)").href,
  703. "size": elem.querySelector(".size").textContent,
  704. "src": elem.querySelector(".action>a:nth-child(1)").href,
  705. });
  706. }
  707. }
  708. else {
  709. data.push({
  710. "title": "没有找到磁链接",
  711. "mag": "",
  712. "size": "0",
  713. "src": result.finalUrl,
  714. });
  715. }
  716. cb(result.finalUrl, data);
  717. },
  718. onerror: function (e) {
  719. console.error(e);
  720. throw "search error";
  721. }
  722. });
  723. },
  724. 5: function (kw, cb) {
  725. GM_xmlhttpRequest({
  726. method: "POST",
  727. url: "http://btlibrary.pw",
  728. data: "keyword=" + kw,
  729. headers: {
  730. "Content-Type": "application/x-www-form-urlencoded"
  731. },
  732. onload: function (result) {
  733. let doc = common.parsetext(result.responseText);
  734. let data = [];
  735. let t = doc.querySelectorAll(".item");
  736. if (t) {
  737. for (let elem of t) {
  738. data.push({
  739. "title": elem.querySelector(".item-title>a").textContent,
  740. "mag": elem.querySelector(".item-detail>span:nth-child(1)>a").href,
  741. "size": elem.querySelector(".item-detail>span:nth-child(3)>b").textContent,
  742. "src": elem.querySelector(".item-title>a").href,
  743. });
  744. }
  745. }
  746. else {
  747. data.push({
  748. "title": "没有找到磁链接",
  749. "mag": "",
  750. "size": "0",
  751. "src": result.finalUrl,
  752. });
  753. }
  754. cb(result.finalUrl, data);
  755. },
  756. onerror: function (e) {
  757. console.error(e);
  758. throw "search error";
  759. }
  760. });
  761. },
  762. };
  763.  
  764. var display_table = function (vid, insert_where) {
  765. common.add_style();
  766. if (!document.querySelector("#nong-head")) {
  767. var tab_with_head = magnet_table.generate_head();
  768. if (typeof insert_where === "string") {
  769. var elem = document.querySelector(insert_where);
  770. //console.log("display_table", tab, elem);
  771. if (elem) {
  772. elem.parentElement.insertBefore(tab_with_head, elem);
  773. }
  774. }
  775. else if (typeof insert_where === "function") {
  776. insert_where(tab_with_head);
  777. }
  778. else {
  779. console.error("插入表格错误");
  780. return;
  781. }
  782. }
  783. else {
  784. var head = document.querySelector("#nong-head");
  785. Array.from(document.querySelectorAll(".nong-row")).forEach(function (row) {
  786. if (row !== head) {
  787. row.parentElement.removeChild(row);
  788. }
  789. });
  790. }
  791. my_search.current(vid, function (data, src) {
  792. var tab = magnet_table.generate(data, src);
  793. common.reg_event();
  794. });
  795. };
  796.  
  797. var vid_mode = function (v) {
  798. var vid = "";
  799. try {
  800. vid = v.vid();
  801. }
  802. catch (error) {
  803. vid = "";
  804. console.error("没有找到番号", v.vid.toString());
  805. }
  806. if (vid) {
  807. console.info("番号:", vid);
  808. display_table(vid, v.insert_where);
  809. }
  810. };
  811.  
  812. var dl_mode = function (v) {
  813.  
  814. var mag = GM_getValue("magnet", "");
  815. //console.info(1, "开始离线下载", mag);
  816. if (mag) {
  817. var script = document.createElement("script");
  818. script.setAttribute("type", "text/javascript");
  819. script.innerHTML = "(" + v.fill_form.toString() + ")(\"" + mag + "\")";
  820. document.body.appendChild(script);
  821. //console.info(info);
  822. }
  823. GM_setValue("magnet", "");
  824. };
  825.  
  826. var run = function () {
  827. max_title_length = GM_getValue("max_title_length", 40);
  828. var main_keys = Object.keys(main);
  829. for (var i = 0; i < main_keys.length; i++) {
  830. var v = main[main_keys[i]];
  831.  
  832. if (v.re && v.re.test(location.href)) {
  833. if (v.type === 0) {
  834.  
  835. //----
  836.  
  837. //for javlibrary
  838. if (main_keys[i] === "javlibrary") {
  839. if (document.querySelector("#adultwarningprompt")) {
  840. document.querySelectorAll("#adultwarningprompt input")[0].click();
  841. }
  842. }
  843. //----
  844.  
  845. vid_mode(v);
  846. }
  847. else if (v.type == 1) {
  848. dl_mode(v);
  849. }
  850. break;
  851. }
  852. }
  853. };
  854. var max_title_length = GM_getValue("max_title_length", 40);
  855. var set_max_title_length = function () {
  856. var len = prompt("请输入你想要的标题长度", GM_getValue("max_title_length", 40));
  857. if (len !== null && len !== "") {
  858. GM_setValue("max_title_length", len);
  859. run();
  860. }
  861. };
  862.  
  863. GM_registerMenuCommand("挊-标题长度", set_max_title_length);
  864. run();
  865.  
  866.  
  867.