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

Fra og med 13.07.2016. Se den nyeste version.

  1. // ==UserScript==
  2. // @name 挊
  3. // @namespace 撸
  4. // @description 自动获取磁链接并自动离线下载
  5.  
  6. // @include http*://avmo.pw/*
  7. // @include http*://avso.pw/*
  8. // @include http*://avxo.pw/*
  9.  
  10. // @include http*://*javlibrary.com/*
  11. // @include http*://*5avlib.com/*
  12. // @include http*://*look4lib.com/*
  13. // @include http*://*javlib3.com/*
  14. // @include http*://*javli6.com/*
  15. // @include http*://*j8vlib.com/*
  16.  
  17.  
  18. // @include http*://www.libredmm.com/products/*
  19. // @include http*://www.javbus.com/*
  20. // @include http*://www.javbus.me/*
  21. // @include http*://www.javbus2.com/*
  22. // @include http*://www.javbus3.com/*
  23. // @include http*://www.javbus5.com/*
  24. // @include http*://*j8vlib.com/*
  25.  
  26. // @include http*://avdb.la/movie/*
  27. // @include http*://www.141jav.com/view/*
  28. // @include http*://www.av4you.net/work/*.htm
  29. // @include http*://www.dmmy18.com/*
  30.  
  31. // @include http*://pan.baidu.com/disk/home*
  32. // @include http*://115.com/?tab=offline&mode=wangpan
  33. // @include http*://cloud.letv.com/webdisk/home/index
  34. // @include http*://disk.yun.uc.cn/
  35. // @include http*://www.furk.net/users/files/add
  36. // @include *.yunpan.360.cn/my/
  37. // @include http://www.dmm.co.jp/digital/videoa/*
  38. // @include http://www.btcherry.org/*
  39. // @include https://btdigg.org/search*
  40.  
  41. // @version 1.37
  42. // @run-at document-end
  43. // @grant GM_xmlhttpRequest
  44. // @grant GM_setClipboard
  45. // @grant GM_setValue
  46. // @grant GM_getValue
  47. // @grant GM_addStyle
  48. // ==/UserScript==
  49. /*
  50. // @include https://btdigg.org/search*
  51. // @include http://www.cilizhushou.com/search/*
  52. // @include http://www.minnano-av.com/av*
  53. // @include http://www.oisinbosoft.com/dera/*
  54.  
  55. */
  56. var main = {
  57. //av信息查询 类
  58. jav: {
  59. type: 0,
  60. re: /(avmo|avso|avxo).*movie.*/,
  61. vid: function() {
  62. return $('.header')[0].nextElementSibling.innerHTML;
  63. },
  64. proc: function() {
  65. insert_after('#movie-share');
  66. }
  67. },
  68. javlibrary: {
  69. type: 0,
  70. re: /(javlibrary|javlib3|look4lib|5avlib|javli6|j8vlib).*\?v=.*/,
  71. vid: function() {
  72. return $('#video_id')[0].getElementsByClassName('text')[0].innerHTML;
  73. },
  74. proc: function() {
  75. insert_after('#video_favorite_edit');
  76. }
  77. },
  78. libredmm: {
  79. type: 0,
  80. re: /libredmm/,
  81. vid: function() {
  82. return location.href.match(/products\/(.*)/)[1];
  83. },
  84. proc: function() {
  85. insert_after('.container');
  86. }
  87. },
  88. dmm: {
  89. type: 0,
  90. re: /dmm\.co\.jp/,
  91. vid: function() {
  92. var result = location.href.replace(/.*cid=/, '').replace(/\/\??.*/, '').match(/[^h_0-9].*/);
  93. return result[0] ? result[0].replace('00', '') : '';
  94. },
  95. proc: function() {
  96. insert_after('.lh4')
  97. },
  98. },
  99. minnano: {
  100. type: 0,
  101. re: /minnano-av/,
  102. vid: function() {
  103. var elems = $('.t11');
  104. var r = '';
  105. for (var i = 0; i < elems.length; i++) {
  106. if (elems[i].textContent == '品番') {
  107. r = elems[i].nextElementSibling.textContent;
  108. break;
  109. }
  110. }
  111. return r;
  112. },
  113. proc: function() {
  114. var tmp = (function() {
  115. var a = $('table');
  116. for (var i = 0; i < a.length; i++) {
  117. if (a[i].bgColor == '#EEEEEE') {
  118. return a[i];
  119. }
  120. }
  121. })();
  122. insert_after(tmp)
  123. }
  124. },
  125. oisinbosoft: {
  126. type: 0,
  127. re: /oisinbosoft/,
  128. vid: function() {
  129. var r = location.pathname.replace(/.*\/+/, '').replace('.html', '');
  130. return r.indexOf('-') == r.lastIndexOf('-') ? r : r.replace(/\w*-?/, '');
  131. },
  132. proc: function() {
  133. // add_style('#magnet-tab table{clear:both;}');
  134. insert_after('#detail_info');
  135. }
  136. },
  137. javbus: {
  138. type: 0,
  139. re: /javbus/,
  140. vid: function() {
  141. var a = $('.header')[0].nextElementSibling;
  142. return a ? a.textContent : '';
  143. },
  144. proc: function() {
  145. insert_after('#star-div')
  146. }
  147. },
  148. avdb: {
  149. type: 0,
  150. re: /avdb\.la/,
  151. vid: function() {
  152. return $('.info')[0].firstElementChild.innerHTML.replace(/<.*>/, '').trim();
  153. },
  154. proc: function() {
  155. insert_after($('#downs')[0].previousElementSibling)
  156. }
  157. },
  158. jav141: {
  159. type: 0,
  160. re: /141jav/,
  161. vid: function() {
  162. return location.href.match(/view\/(.*)\//)[1];
  163. },
  164. proc: function() {
  165. insert_after($('.dlbtn')[0].previousElementSibling)
  166. },
  167. },
  168. av4you: {
  169. type: 0,
  170. re: /av4you/,
  171. vid: function() {
  172. return $('.star-detail-name')[0].textContent.trim();
  173. },
  174. proc: function() {
  175. insert_after('.star-detail')
  176. }
  177. },
  178. dmmy18_sin: {
  179. type: 0,
  180. re: /dmmy18\.com\/details\.aspx\?id=.*/,
  181. vid: function() {
  182. return $('.info li')[0].textContent.replace('番号:', '');
  183. },
  184. proc: function() {
  185. insert_after('.head_coverbanner')
  186. },
  187. },
  188. //网盘下载 类
  189. //这些 $ 是真正的 jquery
  190. baidu: {
  191. type: 1,
  192. re: /pan\.baidu\.com/,
  193. fill_form: function(magnet) {
  194. document.querySelector('.g-button[data-button-id=b13]').click();
  195. setTimeout(function() {
  196. document.querySelector('#_disk_id_2').click();
  197. setTimeout(function() {
  198. document.querySelector('#share-offline-link').value = magnet;
  199. document.querySelector('.g-button[data-button-id=b63]').click();
  200. }, 500)
  201. }, 1500);
  202. }
  203. },
  204. 115: {
  205. type: 1,
  206. re: /115\.com/,
  207. fill_form: function(link) {
  208. var rsc = setInterval(function() {
  209. if (document.readyState == 'complete') {
  210. clearInterval(rsc);
  211. setTimeout(function() {
  212. Core['OFFL5Plug'].OpenLink();
  213. setTimeout(function() {
  214. $('#js_offline_new_add').val(link);
  215. }, 300);
  216. }, 1000);
  217. }
  218. }, 400);
  219. }
  220. },
  221. letv: {
  222. type: 1,
  223. re: /cloud\.letv\.com/,
  224. fill_form: function(link) {
  225. setTimeout(function() {
  226. $('#offline-btn').click();
  227. setTimeout(function() {
  228. $('#offline_clear_complete').prev().click();
  229. setTimeout(function() {
  230. $('#offline-add-link').val(link);
  231. }, 500);
  232. }, 1000);
  233. }, 2000);
  234. }
  235. },
  236. furk: {
  237. type: 1,
  238. re: /www\.furk\.net/,
  239. fill_form: function(link) {
  240. setTimeout(function() {
  241. $('#url').val(link.replace('magnet:?xt=urn:btih:', ''));
  242. }, 1500);
  243. }
  244. },
  245. 360: {
  246. type: 1,
  247. re: /yunpan\.360\.cn\/my/,
  248. fill_form: function(link) {
  249. yunpan.cmdCenter.showOfflineDia();
  250. setTimeout(function() {
  251. $('.offdl-btn-create').click();
  252. setTimeout(function() {
  253. $('#offdlUrl').val(link);
  254. }, 500);
  255. }, 1000);
  256. }
  257. },
  258. uc: {
  259. type: 1,
  260. re: /disk\.yun\.uc\.cn\//,
  261. fill_form: function(link) {
  262. setTimeout(function() {
  263. $('#newuclxbtn_index').click();
  264. setTimeout(function() {
  265. $('#uclxurl').val(link);
  266. }, 1000);
  267. }, 1200);
  268. }
  269. },
  270. //磁链接搜索 类
  271. btcherry_a: {
  272. type: 2,
  273. re: /btcherry\.org\/search\?keyword=.*/,
  274. func: function(tab) {
  275. var selector = '.r div a';
  276. var a = $(selector);
  277. for (var i = 0; i < a.length; i++) {
  278. var b = tab.cloneNode(true);
  279. b.setAttribute('maglink', a[i].href)
  280. //console.log(a[i].href)
  281. a[i].parentElement.appendChild(b)
  282. }
  283. },
  284. },
  285. btcherry_b: {
  286. type: 2,
  287. re: /btcherry\.org\/hash\/.*/,
  288. func: function(tab) {
  289. var selector = '#content div ul';
  290. var a = $(selector)[0];
  291. tab.setAttribute('maglink', $('li a', a)[0])
  292. a.parentElement.insertBefore(tab, a)
  293. },
  294. },
  295. btdigg: {
  296. type: 2,
  297. re: /btdigg\.org\/search/,
  298. func: function(tab) {
  299. if ($('#search_res').length != 0) { //搜索页面
  300. var selector = '.snippet';
  301. var a = $(selector);
  302. for (var i = 0; i < a.length; i++) {
  303. var b = tab.cloneNode(true);
  304. b.setAttribute('maglink', $('.ttth a', a[i].previousElementSibling)[0].href);
  305. a[i].parentElement.appendChild(b);
  306. };
  307. }
  308. else if ($('.torrent_info_tbl').length != 0) { //详情页面
  309. var selector = '.torrent_info_tbl';
  310. var a = $(selector)[0];
  311. tab.setAttribute('maglink', $('a', a)[1].href);
  312. a.parentElement.insertBefore(tab, a);
  313. }
  314. },
  315. },
  316. // cilizhushou_a: {
  317. // re: /cilizhushou/,
  318. // func: function(div) {
  319. // $xafter('.tail', div, function(elem) {
  320. // return elem.getElementsByTagName('a')[0].href;
  321. // });
  322. // },
  323. // },
  324. // // shousibaocai_single: {
  325. // // re: '',
  326. // // func: '',
  327. // // },
  328. // btava_a: {
  329. // re: /search\//,
  330. // func: function(div) {
  331. // $xafter('.data-list .date', div, function(elem) {
  332. // return 'magnet:?xt=urn:btih:' + elem.parentElement.getElementsByTagName('a')[0].href.match(/hash\/(.*)/)[1];
  333. // });
  334. // },
  335. // },
  336. // btava_single: {
  337. // re: /magnet\/detail\/hash\//,
  338. // func: function(div) {
  339. // div.setAttribute('data', $('#magnetLink')[0].value);
  340. // common.after($('#magnetLink')[0], div);
  341. // },
  342. // },
  343. // // instsee_a:{
  344. // // re: /^http:\/\/www\.instsee.com\/$|instsee\.com\/default.aspx.*/,
  345. // // func: function(div){
  346. // // }
  347. // // },
  348. // demo: {
  349. // re: /.*/,
  350. // vid: function() {
  351. // return 'demo'
  352. // },
  353. // proc: function(table) {
  354. // common.after(document.body, table);
  355. // }
  356. // },
  357. };
  358. var main_keys = Object.keys(main) //下面的不要出现
  359. main['cur_tab'] = null;
  360. main['cur_vid'] = '';
  361. var $ = function(selector, context) {
  362. if (context) {
  363. return context.querySelectorAll(selector);
  364. }
  365. return document.querySelectorAll(selector);
  366. };
  367. var insert_after = function(b) {
  368. b = $(b)[0];
  369. if (b) {
  370. b.parentElement.insertBefore(main.cur_tab, b);
  371. }
  372. };
  373. var offline_sites = {
  374. baidu: {
  375. url: 'http://pan.baidu.com/disk/home',
  376. name: '百度云',
  377. enable: true
  378. },
  379. 115: {
  380. name: '115离线',
  381. url: 'http://115.com/?tab=offline&mode=wangpan',
  382. enable: true,
  383. },
  384. letv: {
  385. name: '乐视云',
  386. url: 'http://cloud.letv.com/webdisk/home/index',
  387. enable: false
  388. },
  389. 360: {
  390. name: '360云',
  391. url: 'http://yunpan.360.cn/my/',
  392. enable: false
  393. },
  394. uc: {
  395. name: 'UC离线',
  396. url: 'http://disk.yun.uc.cn/',
  397. enable: false
  398. },
  399. furk: {
  400. name: 'Furk',
  401. url: 'https://www.furk.net/users/files/add',
  402. enable: true
  403. },
  404. };
  405. var common = {
  406. add_style: function(css) {
  407. if (css) {
  408. GM_addStyle(css);
  409. }
  410. else {
  411. GM_addStyle([
  412. '#nong-table{margin:10px auto;color:#666 !important;font-size:13px;text-align:center;background-color: #F2F2F2;}',
  413. '#nong-table th,#nong-table td{text-align: center;height:30px;background-color: #FFF;padding:0 1em 0;border: 1px solid #EFEFEF;}',
  414. '.nong-row{text-align: center;height:30px;background-color: #FFF;padding:0 1em 0;border: 1px solid #EFEFEF;}',
  415. '.nong-copy{color:#08c !important;}',
  416. '.nong-offline{text-align: center;}',
  417. '#nong-head a {margin-right: 5px;}',
  418. '.nong-offline-download{color: rgb(0, 180, 30) !important; margin-right: 4px !important;}',
  419. '.nong-offline-download:hover{color:red !important;}',
  420. ].join(''));
  421. }
  422. },
  423. handle_event: function(event) {
  424. if (event.target.className == 'nong-copy') {
  425. event.target.innerHTML = '成功';
  426. GM_setClipboard(event.target.href);
  427. setTimeout(function() {
  428. event.target.innerHTML = '复制';
  429. }, 1000);
  430. event.preventDefault(); //阻止跳转
  431. }
  432. else if (event.target.className == 'nong-offline-download') {
  433. var maglink = event.target.parentElement.parentElement.getAttribute('maglink') || event.target.parentElement.parentElement.parentElement.getAttribute('maglink')
  434. GM_setValue('magnet', maglink);
  435. }
  436. // else if (event.target.id == 'nong-search-select') {
  437. // current_search_name = event.target.value;
  438. // GM_setValue('search', current_search_name);
  439. // search_engines[current_search_name](current_vid, function(src, data) {
  440. // magnet_table.updata_table(src, data);
  441. // });
  442. // }
  443. },
  444. reg_event: function() { //TODO target 处理 更精准
  445. var list = [
  446. '.nong-copy',
  447. '.nong-offline-download'
  448. ];
  449. for (var i = 0; i < list.length; i++) {
  450. var a = document.querySelectorAll(list[i]);
  451. for (var u = 0; u < a.length; u++) {
  452. a[u].addEventListener('click', this.handle_event, false);
  453. }
  454. }
  455. // var b = document.querySelectorAll('#nong-search-select')[0];
  456. // b.addEventListener('change', this.handle_event, false);
  457.  
  458. },
  459. parsetext: function(text) {
  460. var doc = null;
  461. try {
  462. doc = document.implementation.createHTMLDocument('');
  463. doc.documentElement.innerHTML = text;
  464. return doc;
  465. }
  466. catch (e) {
  467. alert('parse error');
  468. }
  469. },
  470. insert_js: function(js, maglink) {
  471. var script = document.createElement('script');
  472. script.setAttribute('type', 'text/javascript');
  473. script.innerHTML = '(' + js.toString() + ')(\'' + maglink + '\')';
  474. document.body.appendChild(script);
  475. },
  476. add_mini_table: function(sel, func) {
  477. var a = $(sel);
  478. for (var i = a.length - 1; i >= 0; i--) {
  479. a[i].parentElement.insertBefore(a[i], magnet_table.mini()); //TODO
  480. func(a[i]);
  481. }
  482. },
  483. };
  484. var magnet_table = {
  485. template: {
  486. create_head: function() {
  487. var a = document.createElement('tr');
  488. a.className = 'nong-row';
  489. a.id = 'nong-head';
  490. var list = [
  491. '标题',
  492. '大小',
  493. '操作',
  494. '离线下载'
  495. ];
  496. for (var i = 0; i < list.length; i++) {
  497. var b = this.head.cloneNode(true);
  498. if (i == 0) {
  499. var select = document.createElement("select");
  500. var ops = ["btio", "btdb"];
  501. var cur_index = GM_getValue("search_index",0);
  502. for (var j = 0; j < ops.length; j++) {
  503. var op = document.createElement("option");
  504. op.value = j.toString();
  505. op.textContent = ops[j];
  506. if (cur_index == j) {
  507. op.setAttribute("selected", "selected");
  508. }
  509. select.appendChild(op);
  510. }
  511. b.removeChild(b.firstChild);
  512. b.appendChild(select);
  513. a.appendChild(b);
  514. continue;
  515. }
  516. b.firstChild.textContent = list[i];
  517. a.appendChild(b);
  518. }
  519. // var select_box = this.create_select_box();
  520. // a.firstChild.appendChild(select_box);
  521.  
  522. return a;
  523. },
  524. create_row: function(data) {
  525. var a = document.createElement('tr');
  526. a.className = 'nong-row';
  527. a.setAttribute('maglink', data.maglink);
  528. var b = document.createElement('td');
  529. var list = [
  530. this.create_info(data.title, data.maglink),
  531. this.create_size(data.size, data.src),
  532. this.create_operation(data.maglink),
  533. this.create_offline()
  534. ];
  535. for (var i = 0; i < list.length; i++) {
  536. var c = b.cloneNode(true);
  537. c.appendChild(list[i]);
  538. a.appendChild(c);
  539. }
  540. return a;
  541. },
  542. create_loading: function() {
  543. var a = document.createElement('tr');
  544. a.className = 'nong-row';
  545. var p = document.createElement('p');
  546. p.textContent = 'Loading';
  547. p.id = 'notice';
  548. a.appendChild(p);
  549. return a;
  550. },
  551. create_info: function(title, maglink) {
  552. var a = this.info.cloneNode(true);
  553. a.firstChild.textContent = title.length < 20 ? title : title.substr(0, 20) + '...';
  554. a.firstChild.href = maglink;
  555. a.title = title;
  556. return a;
  557. },
  558. create_size: function(size, src) {
  559. var a = this.size.cloneNode(true);
  560. a.textContent = size;
  561. a.href = src;
  562. return a;
  563. },
  564. create_operation: function(maglink) {
  565. var a = this.operation.cloneNode(true);
  566. a.firstChild.href = maglink;
  567. return a;
  568. },
  569. create_offline: function() {
  570. var a = this.offline.cloneNode(true);
  571. a.className = 'nong-offline';
  572. return a;
  573. },
  574. create_select_box: function() {
  575. var select_box = document.createElement('select');
  576. select_box.id = 'nong-search-select';
  577. select_box.setAttribute('title', '切换搜索结果');
  578. var search_name = GM_getValue('search', default_search_name);
  579. for (var k in search_engines) {
  580. var o = document.createElement('option');
  581. if (k == search_name) {
  582. o.setAttribute('selected', 'selected');
  583. }
  584. o.setAttribute('value', k);
  585. o.textContent = k;
  586. select_box.appendChild(o);
  587. }
  588. return select_box;
  589. },
  590. head: (function() {
  591. var a = document.createElement('th');
  592. var b = document.createElement('a');
  593. a.appendChild(b);
  594. return a;
  595. })(),
  596. info: (function() {
  597. var a = document.createElement('div');
  598. var b = document.createElement('a');
  599. b.textContent = 'name';
  600. b.href = 'src';
  601. a.appendChild(b);
  602. return a;
  603. })(),
  604. size: function() {
  605. var a = document.createElement('a');
  606. a.textContent = 'size';
  607. return a;
  608. }(),
  609. operation: (function() {
  610. var a = document.createElement('div');
  611. var copy = document.createElement('a');
  612. copy.className = 'nong-copy';
  613. copy.textContent = '复制';
  614. a.appendChild(copy);
  615. return a;
  616. })(),
  617. offline: (function() {
  618. var a = document.createElement('div');
  619. var b = document.createElement('a');
  620. b.className = 'nong-offline-download';
  621. b.target = '_blank';
  622. for (var k in offline_sites) {
  623. if (offline_sites[k].enable) {
  624. var c = b.cloneNode(true);
  625. c.href = offline_sites[k].url;
  626. c.textContent = offline_sites[k].name;
  627. a.appendChild(c);
  628. }
  629. }
  630. return a;
  631. })(),
  632. },
  633. create_empty_table: function() {
  634. var a = document.createElement('table');
  635. a.id = 'nong-table';
  636. return a;
  637. },
  638. updata_table: function(src, data, type) {
  639. if (type == 'full') {
  640. var tab = $('#nong-table')[0];
  641. tab.removeChild(tab.querySelector("#notice").parentElement);
  642. for (var i = 0; i < data.length; i++) {
  643. tab.appendChild(this.template.create_row(data[i]));
  644. }
  645. }
  646. // else if(type =='mini'){
  647. // }
  648.  
  649. common.reg_event();
  650. },
  651. full: function(src, data) {
  652. var tab = this.create_empty_table();
  653. tab.appendChild(this.template.create_head());
  654. // for (var i = 0; i < data.length; i++) {
  655. // tab.appendChild(this.template.create_row(data[i]))
  656. // }
  657. var loading = this.template.create_loading();
  658. tab.appendChild(loading);
  659. return tab;
  660. },
  661. mini: function(data) {
  662. var tab = this.create_empty_table();
  663. tab.appendChild(this.template.create_offline());
  664. return tab;
  665. }
  666. };
  667. var search_engines = {
  668. switch_engine: function(i) {
  669. // var index = GM_getValue("search_index",0);
  670. GM_setValue('search_index', i)
  671. return i
  672. },
  673. cur_engine: function(kw, cb) {
  674. var z = this[GM_getValue('search_index', 0)];
  675. if(!z){
  676. alert("search engine not found");
  677. }
  678. return z(kw, cb)
  679. },
  680. parse_error:function(a){
  681. alert("调用搜索引擎错误,可能需要更新,请向作者反馈。i="+ a)
  682. },
  683. full_url: '',
  684. 0: function(kw, cb) {
  685. GM_xmlhttpRequest({
  686. method: 'GET',
  687. url: 'https://btso.pw/search/' + kw,
  688. onload: function(result) {
  689. search_engines.full_url = result.finalUrl;
  690. var doc = common.parsetext(result.responseText)
  691. if (!doc) {
  692. search_engines.parse_error(GM_getValue('search_index'))
  693. }
  694. var data = [];
  695. var t = doc.getElementsByClassName('data-list')[0];
  696. if (t) {
  697. var a = t.getElementsByTagName('a');
  698. for (var i = 0; i < a.length; i++) {
  699. if (!a[i].className.match('btn')) {
  700. data.push({
  701. 'title': a[i].title,
  702. 'maglink': 'magnet:?xt=urn:btih:' + a[i].outerHTML.replace(/.*hash\//, '').replace(/" .*\n.*\n.*\n.*/, ''),
  703. 'size': a[i].nextElementSibling.textContent,
  704. 'src': a[i].href,
  705. });
  706. }
  707. }
  708. }
  709. cb(result.finalUrl, data);
  710. },
  711. onerror: function(e) {
  712. console.log(e);
  713. }
  714. })
  715. },
  716. 1: function(kw, cb) {
  717. GM_xmlhttpRequest({
  718. method: 'GET',
  719. url: 'https://btdb.in/q/' + kw + '/',
  720. onload: function(result) {
  721. search_engines.full_url = result.finalUrl;
  722. var doc = common.parsetext(result.responseText)
  723. if(!doc){
  724. search_engines.parse_error(GM_getValue('search_index'))
  725. }
  726. var data = [];
  727. var elems = doc.getElementsByClassName('item-title');
  728. for (var i = 0; i < elems.length; i++) {
  729. data.push({
  730. 'title': elems[i].firstChild.title,
  731. 'maglink': elems[i].nextElementSibling.firstElementChild.href,
  732. 'size': elems[i].nextElementSibling.children[1].textContent,
  733. 'src': 'https://btdb.in' + elems[i].firstChild.getAttribute('href'),
  734. });
  735. }
  736. console.log(data)
  737. cb(result.finalUrl, data);
  738. },
  739. onerror: function(e) {
  740. console.log(e);
  741. }
  742. });
  743. },
  744. // 2: function(kw, cb) {
  745. // GM_xmlhttpRequest({
  746. // method: 'POST',
  747. // url: this.url,
  748. // data: 's=' + kw,
  749. // headers: {
  750. // 'Content-Type': 'application/x-www-form-urlencoded'
  751. // },
  752. // onload: function(result) {
  753. // var doc = document.implementation.createHTMLDocument('');
  754. // doc.documentElement.innerHTML = result.responseText;
  755. // var data = [];
  756. // var t = doc.getElementsByClassName('list-content')[0];
  757. // if (t) {
  758. // var elems = t.getElementsByClassName('item-title');
  759. // for (var i = 0; i < elems.length; i++) {
  760. // data.push({
  761. // 'title': elems[i].getElementsByTagName('a')[0].textContent,
  762. // 'magnet': elems[i].nextElementSibling.getElementsByTagName('a')[0].href,
  763. // 'size': elems[i].nextElementSibling.getElementsByTagName('b')[1].textContent
  764. // });
  765. // }
  766. // cb(result.finalUrl, data);
  767. // }
  768. // },
  769. // onerror: function(e) {
  770. // console.log(e);
  771. // }
  772. // });
  773. // },
  774. };
  775. if(GM_getValue('search_index',null) === null){
  776. GM_setValue('search_index',0)
  777. }
  778. var run = function() {
  779. for (var i = 0; i < main_keys.length; i++) {
  780. var v = main[main_keys[i]];
  781.  
  782. //for javlibrary
  783. if($("#adultwarningprompt")[0] != null){
  784. $("#adultwarningprompt input")[0].click()
  785. }
  786.  
  787. if (v.re.test(location.href)) {
  788. if (v.type == 0) {
  789. try {
  790. main.cur_vid = v.vid();
  791. }
  792. catch (e) {
  793. main.cur_vid = '';
  794. }
  795. if (main.cur_vid) {
  796. common.add_style();
  797. main.cur_tab = magnet_table.full();
  798. console.log('番号:', main.cur_vid)
  799. v.proc()
  800.  
  801. // console.log(main.cur_tab)
  802. var t = $('#nong-head')[0].firstChild;
  803. t.firstChild.addEventListener('change', function(e) {
  804. console.log(e.target.value);
  805. GM_setValue('search_index', e.target.value);
  806. var s = $('#nong-table')[0];
  807. s.parentElement.removeChild(s);
  808. run()
  809. });
  810. search_engines.cur_engine(main.cur_vid, function(src, data) {
  811. if (data.length == 0) {
  812. $('#nong-table')[0].querySelectorAll('#notice')[0].textContent = 'No search result';
  813. }
  814. else {
  815. magnet_table.updata_table(src, data, 'full');
  816. /*display search url*/
  817. var y = $('#nong-head th')[1].firstChild;
  818. y.href = search_engines.full_url;
  819. }
  820. });
  821. }
  822. }
  823. else if (v.type == 1) {
  824. var js = v.fill_form;
  825. var maglink = GM_getValue('magnet');
  826. if (maglink) {
  827. common.insert_js(js, maglink);
  828. GM_setValue('magnet', '')
  829. }
  830. }
  831. else if (v.type == 2) {
  832. common.add_style();
  833. v.func(magnet_table.mini());
  834. magnet_table.updata_table('', '', 'mini');
  835. }
  836. break;
  837. }
  838. }
  839. };
  840.  
  841. run();