JAV老司机

JAV老司机神器,支持各Jav老司机站点。拥有高效浏览Jav的页面排版,JAV高清预览大图,JAV列表无限滚动自动加载,合成“挊”的自动获取JAV磁链接,一键自动115离线下载。。。。没时间解释了,快上车!

Stan na 20-09-2018. Zobacz najnowsza wersja.

  1. // ==UserScript==
  2. // @name JAV老司机
  3. // @namespace https://sleazyfork.org/zh-CN/users/25794
  4. // @version 2.1.0
  5. // @supportURL https://sleazyfork.org/zh-CN/scripts/25781/feedback
  6. // @source https://github.com/hobbyfang/javOldDriver
  7. // @description JAV老司机神器,支持各Jav老司机站点。拥有高效浏览Jav的页面排版,JAV高清预览大图,JAV列表无限滚动自动加载,合成“挊”的自动获取JAV磁链接,一键自动115离线下载。。。。没时间解释了,快上车!
  8. // @author Hobby
  9.  
  10. // @require https://cdn.jsdelivr.net/npm/jquery@2.2.4/dist/jquery.min.js
  11. // http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.4.min.js
  12. // @require https://cdn.jsdelivr.net/npm/jquery.cookie@1.4.1/jquery.cookie.min.js
  13. // @require https://cdn.jsdelivr.net/npm/persistencejs@0.3.0/lib/persistence.js
  14. // @require https://cdn.jsdelivr.net/npm/persistencejs@0.3.0/lib/persistence.store.sql.js
  15. // @require https://cdn.jsdelivr.net/npm/persistencejs@0.3.0/lib/persistence.store.websql.js
  16. // @resource icon http://geekdream.com/image/115helper_icon_001.jpg
  17.  
  18. // @include http*://*javlibrary.com/*
  19. // @include http*://*javlib.com/*
  20. // @include http*://www.javbus.com/*
  21. // @include http*://tellme.pw/avsox
  22. // @include http*://tellme.pw/avmoo
  23. // @include http*://115.com/*
  24.  
  25. // @include http*://*/vl_update*
  26. // @include http*://*/vl_newrelease*
  27. // @include http*://*/vl_newentries*
  28. // @include http*://*/vl_mostwanted*
  29. // @include http*://*/vl_bestrated*
  30. // @include http*://*/vl_genre*
  31. // @include http*://*/vl_star*
  32. // @include http*://*/?v=jav*
  33.  
  34. // @include http*://www.*bus*/*
  35. // @include http*://www.*dmm*/*
  36.  
  37. // @include http*://*/movie/*
  38. // @include http*://*/cn*
  39. // @include http*://*/tw*
  40. // @include http*://*/ja*
  41. // @include http*://*/en*
  42.  
  43.  
  44. // @run-at document-idle
  45. // @grant GM_xmlhttpRequest
  46. // @grant GM_addStyle
  47. // @grant GM_getValue
  48. // @grant GM_setValue
  49. // @grant GM_notification
  50. // @grant GM_setClipboard
  51. // @grant GM_getResourceURL
  52.  
  53. // @connect *
  54. // connect blogjav.net
  55. // connect pixhost.to
  56. // connect 115.com
  57. // connect btso.pw
  58. // connect btdb.to
  59. // connect sukebei.nyaa.si
  60. // connect btkitty.pet
  61. // connect cnbtkitty.me
  62. // connect www.torrentkitty.tv
  63. // connect btlibrary.xyz
  64.  
  65. // @copyright hobby 2016-12-18
  66.  
  67. // 大陆用户推荐Chrome(V41+) + Tampermonkey(必须扩展) + ShadowsocksR/XX-Net(代理) + Proxy SwitchyOmega(扩展)的环境下配合使用。
  68. // 上车请使用chrome浏览器,其他浏览器的问题本人不支持发现和修复相关问题。
  69.  
  70. // 注意:2.0在每个版本号更新后,javlibrary每个不同域名站点在登录javlibrary的情况下,都会分别首次运行此脚本,根据电脑性能情况不同,需消耗约2分钟以上(以1000个车牌量计算)缓存个人数据到本地浏览器中.
  71. // 此目的用于过滤个人已阅览过的内容提供快速判断.目前在同步过程中根据电脑性能不同情况,会有页面消耗CPU资源不同程度的较高占比.
  72. // 当然如果不登录javlibrary或同版本号已经同步过,则无此影响.后续版本更新中将计划优化此性能.
  73.  
  74. // v2.1.0 增加javbus站内磁链列表的复制、115离线的快捷键功能。
  75.  
  76. // v2.0.16 更新永久支持javlib新域名(能科学上网的司机们建议访问javlibrary原始域名,这样减少每次更换域名消耗同步数据时间)。jav字幕站点已失效,移除下载字幕功能。
  77. // v2.0.15 修复已知问题。更新javlib新域名支持。新域名首次运行会出现cpu占比较高,正常等待几分钟即可。
  78. // v2.0.14 修复缩略图域名失效问题。
  79. // v2.0.11 更新两个站点域名。
  80. // v2.0.7 增加一种情况Jav列表排序功能支持(仅javlib)。
  81. // v2.0.5 增加Jav列表“按评分排序”、“按时间排序”功能(仅javlib),及更新Jav站点域名。
  82. // v2.0.4 2.0版本性能优化。
  83. // v2.0.0 增加自动同步个人数据缓存到本地,jav列表能识别个人已阅览过的内容(需登录javlibray),针对javlibrary的高评价栏目,增加过滤"不看我阅览过"功能。
  84.  
  85. // v1.2.0 针对javlibrary的高评价栏目,增加过滤“只看当前月份”、“只看近两月份”功能。另默认此栏目近两月份的内容增加背景颜色区分。
  86. // v1.2.0 更新了合成“挊”脚本的更多网站的支持,感谢作者thunderhit,同时修复原脚本部分网站功能失效问题。
  87. // v1.1.0 优化更新了JAV列表无限滚动自动加载的代码,增加JAV列表中显示"发行日期"和"评分"的排版,以及修复了已知问题。
  88. // v1.0.3 优化了高清预览大图的获取。
  89. // v1.0.2 优化了javlibrary排版,做了最低分辨率1280x800的排版适配调整,及修复了已知问题。
  90. // v1.0.0 支持javlibrary.com、javbus.com、avmo.pw、avso.pw等老司机站点,第一版发布。
  91.  
  92. // ==/UserScript==
  93. /* jshint -W097 */
  94. (function () {
  95. 'use strict';
  96. let jav_userID = GM_getValue('jav_user_id', 0); //115用户ID
  97. //icon图标
  98. let icon = GM_getResourceURL('icon');
  99.  
  100. // 对Date的扩展,将 Date 转化为指定格式的String
  101. // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,/';
  102. // 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
  103. // 例子:
  104. // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
  105. // (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
  106. Date.prototype.Format = function (fmt) { //author: meizz
  107. var o = {
  108. "M+": this.getMonth() + 1, //月份
  109. "d+": this.getDate(), //日
  110. "h+": this.getHours(), //小时
  111. "m+": this.getMinutes(), //分
  112. "s+": this.getSeconds(), //秒
  113. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  114. "S": this.getMilliseconds() //毫秒
  115. };
  116. if (/(y+)/.test(fmt))
  117. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  118. for (var k in o)
  119. if (new RegExp("(" + k + ")").test(fmt))
  120. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  121. return fmt;
  122. };
  123.  
  124. /**
  125. * 公用类
  126. * @Class
  127. */
  128. let Common = {
  129. /**
  130. * html文本转换为Document对象
  131. * @param {String} text
  132. * @returns {Document}
  133. */
  134. parsetext: function (text) {
  135. var doc = null;
  136. try {
  137. doc = document.implementation.createHTMLDocument('');
  138. doc.documentElement.innerHTML = text;
  139. return doc;
  140. }
  141. catch (e) {
  142. alert('parse error');
  143. }
  144. },
  145.  
  146. /**
  147. * 判断日期是否最近X个月份的日期
  148. * @param {String} DateStr 日期
  149. * @param {Number} MonthNum 月数(X)
  150. * @returns {boolean}
  151. */
  152. isLastXMonth: function (DateStr, MonthNum) {
  153. let now = new Date(); //当前日期
  154. let compDate = new Date(DateStr);
  155. let m2 = now.getFullYear() * 12 + now.getMonth();
  156. let m1 = compDate.getFullYear() * 12 + compDate.getMonth();
  157. if ((m2 - m1) < MonthNum) {
  158. return true;
  159. }
  160. return false;
  161. },
  162.  
  163. /**
  164. * 方法: 通用chrome通知
  165. * @param title
  166. * @param body
  167. * @param icon
  168. * @param click_url
  169. */
  170. notifiy: function (title, body, icon, click_url) {
  171. var notificationDetails = {
  172. text: body,
  173. title: title,
  174. timeout: 10000,
  175. image: icon,
  176. onclick: function () {
  177. window.open(click_url);
  178. }
  179. };
  180. GM_notification(notificationDetails);
  181. },
  182. /**
  183. * 加入AV预览内容图
  184. * @param avid av唯一码
  185. * @param @function func 函数
  186. */
  187. addAvImg: function (avid, func) {
  188. //异步请求搜索blogjav.net的番号
  189. GM_xmlhttpRequest({
  190. method: "GET",
  191. //大图地址
  192. url: 'http://blogjav.net/?s=' + avid,
  193. onload: function (result) {
  194. //console.log("时间111111:"+ new Date().getTime());
  195. var doc = Common.parsetext(result.responseText);
  196. //console.log("时间222222:"+ new Date().getTime());
  197. let a_array = $(doc).find(".more-link");
  198. let a = a_array[0];
  199. for (let i = 0; i < a_array.length; i++) {
  200. var fhd_idx = a_array[i].innerHTML.search(/FHD/);
  201. //debugger;
  202. if (fhd_idx > 0) {
  203. a = a_array[i];
  204. break;
  205. }
  206. }
  207.  
  208. if (a) {
  209. //异步请求调用内页详情的访问地址
  210. GM_xmlhttpRequest({
  211. method: "GET",
  212. //大图地址
  213. url: a.href,
  214. headers: {
  215. referrer: "http://pixhost.to/" //绕过防盗图的关键
  216. },
  217. onload: function (XMLHttpRequest) {
  218. //console.log("时间333333:"+ new Date().getTime());
  219. var bodyStr = XMLHttpRequest.responseText;
  220. var yixieBody = bodyStr.substring(bodyStr.search(/<span id="more-(\S*)"><\/span>/), bodyStr.search(/<div class="category/));
  221.  
  222. var img_start_idx = yixieBody.search(/"><img .*src="https*:\/\/(\S*)pixhost.to\/thumbs\//);
  223. //debugger;
  224. //如果找到内容大图
  225. if (img_start_idx > 0) {
  226. var new_img_src = yixieBody.substring(yixieBody.indexOf('src', img_start_idx) + 5, yixieBody.indexOf('alt') - 2);
  227. var targetImgUrl = new_img_src.replace('thumbs', 'images').replace('//t', '//img').replace(/[\?*\"*]/, '').replace('https', 'http');
  228.  
  229. //如果找到全高清大图优先显示全高清的
  230. console.log("图片地址:" + targetImgUrl);
  231.  
  232. //创建img元素,加载目标图片地址
  233. //创建新img元素
  234. var $img = $('<img name="javRealImg" title="点击可放大缩小 (图片正常时)"></img>');
  235. $img.attr("src", targetImgUrl);
  236. $img.attr("style", "float: left;cursor: pointer;");
  237.  
  238. //将新img元素插入指定位置
  239. func($img);
  240. console.log("时间444444:" + new Date().getTime());
  241. }
  242. },
  243. onerror: function (e) {
  244. console.log(e);
  245. }
  246. });//end GM_xmlhttpRequest
  247. }
  248. },
  249. onerror: function (e) {
  250. console.log(e);
  251. }
  252. });//end GM_xmlhttpRequest
  253. },
  254. };
  255.  
  256. //定义函数全局变量
  257. let MyMovie;
  258. let MyBrowse;
  259. let MyWant;
  260. let MySeen;
  261. let MyHave;
  262.  
  263. /**
  264. * websql数据库类
  265. * @type {{DBinit: DBinit}
  266. */
  267. let JavWebSql = {
  268. /**
  269. * 数据库初始化
  270. * @constructor
  271. */
  272. DBinit: function () {
  273.  
  274. // 配置
  275. persistence.store.websql.config(persistence, "MyMovie1021", 'database', 10 * 1024 * 1024);
  276.  
  277. // 我的影片
  278. MyMovie = persistence.define('my_movie', {
  279. //影片id
  280. //movie_id: "INTEGER",
  281. //索引编码 如javlikqu54
  282. index_cd: "VARCHAR(20)",
  283. //识别编码 如CHN-141
  284. code: "VARCHAR(20)",
  285. //缩略图路径
  286. thumbnail_url: "VARCHAR(200)",
  287. //片名
  288. movie_name: "VARCHAR(300)",
  289. //演员
  290. actor: "VARCHAR(50)",
  291. //封面图路径
  292. cover_img_url: "VARCHAR(200)",
  293. //发布日期
  294. release_date: "DATETIME",
  295. //评分
  296. score: "INTEGER",
  297. //片长(分钟)
  298. duration: "INTEGER",
  299. //导演
  300. director: "VARCHAR(50)",
  301. //制作商
  302. maker: "VARCHAR(50)",
  303. //发行商
  304. publisher: "VARCHAR(50)",
  305. //创建时间
  306. add_time: "DATETIME"
  307. });
  308.  
  309. // 我浏览过(网页)
  310. MyBrowse = persistence.define('my_browse', {
  311. //浏览id
  312. //browse_id: "INTEGER",
  313. //索引编码
  314. index_cd: "TEXT",
  315. //创建时间
  316. add_time: "DATETIME"
  317. });
  318.  
  319. // 我想要的
  320. MyWant = persistence.define('my_want', {
  321. //想要id
  322. //want_id: "INTEGER",
  323. //索引编码
  324. index_cd: "TEXT",
  325. //创建时间
  326. add_time: "DATETIME"
  327. });
  328.  
  329. // 我看过影片
  330. MySeen = persistence.define('my_seen', {
  331. //看过id
  332. //seen_id: "INTEGER",
  333. //索引编码
  334. index_cd: "TEXT",
  335. //创建时间
  336. add_time: "DATETIME"
  337. });
  338.  
  339. // 我已拥有
  340. MyHave = persistence.define('my_have', {
  341. //拥有id
  342. //have_id: "INTEGER",
  343. //索引编码
  344. index_cd: "TEXT",
  345. //创建时间
  346. add_time: "DATETIME"
  347. });
  348.  
  349. MyMovie.index(['index_cd', 'code'], {unique: true});
  350. MyBrowse.index(['index_cd'], {unique: true});
  351. MyWant.index(['index_cd'], {unique: true});
  352. MySeen.index(['index_cd'], {unique: true});
  353. MyHave.index(['index_cd'], {unique: true});
  354. //MyBrowse.hasOne('movie',MyMovie,'myBrowse');
  355.  
  356. persistence.schemaSync();
  357. },
  358. };
  359.  
  360. let main = {
  361. //av信息查询 类
  362. //avsox|avmoo
  363. jav: {
  364. type: 0,
  365. re: /.*movie.*/,
  366. vid: function () {
  367. return $('.header_hobby')[0].nextElementSibling.innerHTML;
  368. },
  369. proc: function () {
  370. //insert_after('#movie-share');
  371. var divE = $("div[class='col-md-3 info']")[0];
  372. $(divE).after(main.cur_tab);
  373. //$(main.cur_tab).before($('#movie-share')[0]);
  374. }
  375. },
  376. javbus: {
  377. type: 0,
  378. re: /bus|dmm/,
  379. vid: function () {
  380. var a = $('.header_hobby')[0].nextElementSibling;
  381. return a ? a.textContent : '';
  382. },
  383. proc: function () {
  384. var divE = $("div[class='col-md-3 info']")[0];
  385. //var p = document.createElement('p');
  386. //p.className = 'hobby';
  387. //divE.parentElement.appendChild(p);
  388. $(divE).after(main.cur_tab);
  389. }
  390. },
  391. javlibrary: {
  392. type: 0,
  393. re: /.*\?v=jav.*/,
  394. vid: function () {
  395. return $('#video_id')[0].getElementsByClassName('text')[0].innerHTML;
  396. },
  397. proc: function () {
  398. //insert_after('#video_info');
  399. //<td style="vertical-align: top;">
  400. //去十八岁警告
  401. setCookie("over18", 18);
  402. $('.socialmedia').remove();
  403. GM_addStyle([
  404. '#video_info{text-align: left;font: 14px Arial;min-width: 230px;max-width: 230px;padding: 0px 0px 0px 0px;}',
  405. '#video_jacket_info {width: 100%;overflow: hidden;}',//table-layout: fixed;
  406. '#coverimg {vertical-align: top;overflow: hidden;max-width: 50%;}',
  407. '#javtext {vertical-align: top;width: 230px;}',
  408. '#video_info td.header {width: 75px;}',
  409. '#video_info td.icon {width: 0px;}',
  410. '#content {padding-top: 0px;}',
  411. ].join(''));
  412.  
  413. var tdE = $("td[style='vertical-align: top;']")[0];
  414. tdE.id = "coverimg";
  415. $("td[style='vertical-align: top;']")[1].id = 'javtext';
  416. $('#leftmenu').remove();
  417. $('#rightcolumn').attr("style", "margin: 0px 0px 0px 0px;width: 100%;padding: initial;");
  418. $(tdE.parentElement).append('<td id="hobby" style="vertical-align: top;width: 100%;"></td>');
  419. $('#hobby').append(main.cur_tab);
  420. }
  421. },
  422. };
  423.  
  424. // 挊
  425. let main_keys = Object.keys(main); //下面的不要出现
  426. main.cur_tab = null;
  427. main.cur_vid = '';
  428.  
  429. // 瀑布流脚本使用类
  430. class Lock {
  431. constructor(d = false) {
  432. this.locked = d;
  433. }
  434.  
  435. lock() {
  436. this.locked = true;
  437. }
  438.  
  439. unlock() {
  440. this.locked = false;
  441. }
  442. }
  443.  
  444. // 第三方脚本调用
  445. var thirdparty = {
  446. // 挊
  447. nong: {
  448. offline_sites: {
  449. 115: {
  450. name: '115离线',
  451. url: 'http://115.com/?tab=offline&mode=wangpan',
  452. enable: true,
  453. },
  454. },
  455. // 挊
  456. search_engines: {
  457. switch_engine: function (i) {
  458. // var index = GM_getValue("search_index",0);
  459. GM_setValue('search_index', i);
  460. return i;
  461. },
  462. cur_engine: function (kw, cb) {
  463. var z = this[GM_getValue('search_index', 0)];
  464. if (!z) {
  465. alert("search engine not found");
  466. }
  467. return z(kw, cb);
  468. },
  469. parse_error: function (a) {
  470. alert("调用搜索引擎错误,可能需要更新,请向作者反馈。i=" + a);
  471. },
  472. full_url: '',
  473. 0: function (kw, cb) {
  474. GM_xmlhttpRequest({
  475. method: 'GET',
  476. url: 'https://btso.pw/search/' + kw,
  477. onload: function (result) {
  478. thirdparty.nong.search_engines.full_url = result.finalUrl;
  479. var doc = Common.parsetext(result.responseText);
  480. if (!doc) {
  481. thirdparty.nong.search_engines.parse_error(GM_getValue('search_index'));
  482. }
  483. var data = [];
  484. var t = doc.getElementsByClassName('data-list')[0];
  485. if (t) {
  486. var a = t.getElementsByTagName('a');
  487. for (var i = 0; i < a.length; i++) {
  488. if (!a[i].className.match('btn')) {
  489. data.push({
  490. 'title': a[i].title,
  491. 'maglink': 'magnet:?xt=urn:btih:' + a[i].outerHTML.replace(/.*hash\//, '').replace(/" .*\n.*\n.*\n.*/, ''),
  492. 'size': a[i].nextElementSibling.textContent,
  493. 'src': a[i].href,
  494. });
  495. }
  496. }
  497. }
  498. cb(result.finalUrl, data);
  499. },
  500. onerror: function (e) {
  501. console.log(e);
  502. }
  503. });
  504. },
  505. 1: function (kw, cb) {
  506. GM_xmlhttpRequest({
  507. method: 'GET',
  508. url: 'http://btdb.to/q/' + kw + '/',
  509. onload: function (result) {
  510. thirdparty.nong.search_engines.full_url = result.finalUrl;
  511. var doc = Common.parsetext(result.responseText);
  512. if (!doc) {
  513. thirdparty.nong.search_engines.parse_error(GM_getValue('search_index'));
  514. }
  515. var data = [];
  516. var elems = doc.getElementsByClassName('item-title');
  517. for (var i = 0; i < elems.length; i++) {
  518. data.push({
  519. 'title': elems[i].firstChild.title,
  520. 'maglink': elems[i].nextElementSibling.firstElementChild.href,
  521. 'size': elems[i].nextElementSibling.children[1].textContent,
  522. 'src': 'https://btdb.to' + elems[i].firstChild.getAttribute('href'),
  523. });
  524. }
  525. console.log(data);
  526. cb(result.finalUrl, data);
  527. },
  528. onerror: function (e) {
  529. console.log(e);
  530. }
  531. });
  532. },
  533. 2: function (kw, cb) {
  534. GM_xmlhttpRequest({
  535. method: "GET",
  536. url: "https://sukebei.nyaa.si/?f=0&c=0_0&q=" + kw,
  537. onload: function (result) {
  538. thirdparty.nong.search_engines.full_url = result.finalUrl;
  539. let doc = Common.parsetext(result.responseText);
  540. if (!doc) {
  541. thirdparty.nong.search_engines.parse_error(GM_getValue('search_index'));
  542. }
  543. let data = [];
  544. let t = doc.querySelectorAll("tr.default,tr.success");
  545. if (t.length !== 0) {
  546. for (let elem of t) {
  547. //debugger;
  548. data.push({
  549. "title": elem.querySelector("td:nth-child(2)>a:nth-child(1)").title,
  550. "maglink": elem.querySelector("td:nth-child(3)>a:nth-last-child(1)").href,
  551. //"torrent_url": "https://nyaa.si" + elem.querySelector("td:nth-child(3)>a:nth-child(1)").href,
  552. "size": elem.querySelector("td:nth-child(4)").textContent,
  553. "src": "https://sukebei.nyaa.si" + elem.querySelector("td:nth-child(2)>a:nth-child(1)").getAttribute('href'),
  554. });
  555. }
  556. }
  557. else {
  558. data.push({
  559. "title": "没有找到磁链接",
  560. "maglink": "",
  561. //"torrent_url": "",
  562. "size": "0",
  563. "src": result.finalUrl,
  564. });
  565. }
  566.  
  567. cb(result.finalUrl, data);
  568. },
  569. onerror: function (e) {
  570. console.error(e);
  571. throw "search error";
  572. }
  573. });
  574. },
  575. 3: function (kw, cb) {
  576. GM_xmlhttpRequest({
  577. method: "POST",
  578. url: "https://cnbtkitty.me/",
  579. data: "keyword=" + kw + "&hidden=true",
  580. headers: {
  581. "Content-Type": "application/x-www-form-urlencoded"
  582. },
  583. onload: function (result) {
  584. thirdparty.nong.search_engines.full_url = result.finalUrl;
  585. let doc = Common.parsetext(result.responseText);
  586. let data = [];
  587. let t = doc.getElementsByClassName("list-con");
  588. if (t) {
  589. for (let elem of t) {
  590. data.push({
  591. "title": elem.querySelector("dt a").textContent,
  592. "maglink": elem.querySelector("dd a").href,
  593. "size": elem.querySelector(".option span:nth-child(3) b").textContent,
  594. "src": elem.querySelector("dt a").href,
  595. });
  596. }
  597. }
  598. else {
  599. data.push({
  600. "title": "没有找到磁链接",
  601. "maglink": "",
  602. "size": "0",
  603. "src": result.finalUrl,
  604. });
  605. }
  606. cb(result.finalUrl, data);
  607. },
  608. onerror: function (e) {
  609. console.error(e);
  610. throw "search error";
  611. }
  612. });
  613. },
  614. 4: function (kw, cb) {
  615. GM_xmlhttpRequest({
  616. method: "GET",
  617. url: "https://www.torrentkitty.tv/search/" + kw,
  618. onload: function (result) {
  619. thirdparty.nong.search_engines.full_url = result.finalUrl;
  620. let doc = Common.parsetext(result.responseText);
  621. let data = [];
  622. let t = doc.querySelectorAll("#archiveResult tr");
  623. if (t) {
  624. t = Array.slice(t, 1, t.length);
  625. for (let elem of t) {
  626. data.push({
  627. "title": elem.querySelector(".name").textContent,
  628. "maglink": elem.querySelector(".action>a:nth-child(2)").href,
  629. "size": elem.querySelector(".size").textContent,
  630. "src": "https://www.torrentkitty.tv" + elem.querySelector(".action>a:nth-child(1)").getAttribute('href'),
  631. });
  632. }
  633. }
  634. else {
  635. data.push({
  636. "title": "没有找到磁链接",
  637. "maglink": "",
  638. "size": "0",
  639. "src": result.finalUrl,
  640. });
  641. }
  642. cb(result.finalUrl, data);
  643. },
  644. onerror: function (e) {
  645. console.error(e);
  646. throw "search error";
  647. }
  648. });
  649. },
  650. 5: function (kw, cb) {
  651. GM_xmlhttpRequest({
  652. method: "POST",
  653. url: "http://btlibrary.xyz",
  654. data: "keyword=" + kw,
  655. headers: {
  656. "Content-Type": "application/x-www-form-urlencoded"
  657. },
  658. onload: function (result) {
  659. thirdparty.nong.search_engines.full_url = result.finalUrl;
  660. let doc = Common.parsetext(result.responseText);
  661. let data = [];
  662. let t = doc.querySelectorAll(".item");
  663. if (t) {
  664. for (let elem of t) {
  665. data.push({
  666. "title": elem.querySelector(".item-title>a").textContent,
  667. "maglink": elem.querySelector(".item-detail>span:nth-child(1)>a").href,
  668. "size": elem.querySelector(".item-detail>span:nth-child(3)>b").textContent,
  669. "src": elem.querySelector(".item-title>a").href,
  670. });
  671. }
  672. }
  673. else {
  674. data.push({
  675. "title": "没有找到磁链接",
  676. "maglink": "",
  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. },
  690. // 挊
  691. magnet_table: {
  692. template: {
  693. create_head: function () {
  694. var a = document.createElement('tr');
  695. a.className = 'jav-nong-row';
  696. a.id = 'jav-nong-head';
  697. var list = [
  698. '标题',
  699. '大小',
  700. '操作',
  701. '离线下载'
  702. ];
  703. for (var i = 0; i < list.length; i++) {
  704. var b = this.head.cloneNode(true);
  705. if (i === 0) {
  706. var select = document.createElement("select");
  707. var ops = ["btso", "btdb", "nyaa.si", "btkitty", "torrentkitty", "btlibrary"];
  708. var cur_index = GM_getValue("search_index", 0);
  709. for (var j = 0; j < ops.length; j++) {
  710. var op = document.createElement("option");
  711. op.value = j.toString();
  712. op.textContent = ops[j];
  713. if (cur_index == j) {
  714. op.setAttribute("selected", "selected");
  715. }
  716. select.appendChild(op);
  717. }
  718. b.removeChild(b.firstChild);
  719. b.appendChild(select);
  720. a.appendChild(b);
  721. continue;
  722. }
  723. b.firstChild.textContent = list[i];
  724. a.appendChild(b);
  725. }
  726. // var select_box = this.create_select_box();
  727. // a.firstChild.appendChild(select_box);
  728.  
  729. return a;
  730. },
  731. create_row: function (data) {
  732. var a = document.createElement('tr');
  733. a.className = 'jav-nong-row';
  734. a.setAttribute('maglink', data.maglink);
  735. var b = document.createElement('td');
  736. var list = [
  737. this.create_info(data.title, data.maglink),
  738. this.create_size(data.size, data.src),
  739. this.create_operation(data.maglink),
  740. this.create_offline()
  741. ];
  742. for (var i = 0; i < list.length; i++) {
  743. var c = b.cloneNode(true);
  744. c.appendChild(list[i]);
  745. a.appendChild(c);
  746. }
  747. return a;
  748. },
  749. create_loading: function () {
  750. var a = document.createElement('tr');
  751. a.className = 'jav-nong-row';
  752. var p = document.createElement('p');
  753. p.textContent = 'Loading';
  754. p.id = 'notice';
  755. a.appendChild(p);
  756. return a;
  757. },
  758. create_info: function (title, maglink) {
  759. var a = this.info.cloneNode(true);
  760. a.firstChild.textContent = title.length < 20 ? title : title.substr(0, 20) + '...';
  761. a.firstChild.href = maglink;
  762. a.title = title;
  763. return a;
  764. },
  765. create_size: function (size, src) {
  766. var a = this.size.cloneNode(true);
  767. a.textContent = size;
  768. a.href = src;
  769. return a;
  770. },
  771. create_operation: function (maglink) {
  772. var a = this.operation.cloneNode(true);
  773. a.firstChild.href = maglink;
  774. return a;
  775. },
  776. create_offline: function () { //有用 hobby
  777. var a = this.offline();
  778. a.className = 'nong-offline';
  779. return a;
  780. },
  781. create_select_box: function () {
  782. var select_box = document.createElement('select');
  783. select_box.id = 'nong-search-select';
  784. select_box.setAttribute('title', '切换搜索结果');
  785. var search_name = GM_getValue('search', default_search_name);
  786. for (var k in thirdparty.nong.search_engines) {
  787. var o = document.createElement('option');
  788. if (k == search_name) {
  789. o.setAttribute('selected', 'selected');
  790. }
  791. o.setAttribute('value', k);
  792. o.textContent = k;
  793. select_box.appendChild(o);
  794. }
  795. return select_box;
  796. },
  797. head: (function () {
  798. var a = document.createElement('th');
  799. var b = document.createElement('a');
  800. a.appendChild(b);
  801. return a;
  802. })(),
  803. info: (function () {
  804. var a = document.createElement('div');
  805. var b = document.createElement('a');
  806. b.textContent = 'name';
  807. b.href = 'src';
  808. a.appendChild(b);
  809. return a;
  810. })(),
  811. size: function () {
  812. var a = document.createElement('a');
  813. a.textContent = 'size';
  814. return a;
  815. }(),
  816. operation: (function () {
  817. var a = document.createElement('div');
  818. var copy = document.createElement('a');
  819. copy.className = 'nong-copy';
  820. copy.textContent = '复制';
  821. a.appendChild(copy);
  822. return a;
  823. })(),
  824. offline: function () {
  825. var a = document.createElement('div');
  826. var b = document.createElement('a');
  827. b.className = 'nong-offline-download';
  828. b.target = '_blank';
  829. //debugger;
  830. for (var k in thirdparty.nong.offline_sites) {
  831. if (thirdparty.nong.offline_sites[k].enable) {
  832. var c = b.cloneNode(true);
  833. c.href = thirdparty.nong.offline_sites[k].url;
  834. c.textContent = thirdparty.nong.offline_sites[k].name;
  835. a.appendChild(c);
  836. }
  837. }
  838. return a;
  839. },
  840. },
  841. create_empty_table: function () { //有用 hobby
  842. var a = document.createElement('table');
  843. a.id = 'nong-table-new';
  844. return a;
  845. },
  846. updata_table: function (src, data, type) {
  847. if (type == 'full') {
  848. var tab = $('#nong-table-new')[0];
  849. tab.removeChild(tab.querySelector("#notice").parentElement);
  850. for (var i = 0; i < data.length; i++) {
  851. tab.appendChild(thirdparty.nong.magnet_table.template.create_row(data[i]));
  852. }
  853. }
  854. // else if(type =='mini'){
  855. // }
  856.  
  857. this.reg_event();
  858. },
  859. full: function (src, data) {
  860. var tab = this.create_empty_table();
  861. tab.appendChild(thirdparty.nong.magnet_table.template.create_head());
  862. // for (var i = 0; i < data.length; i++) {
  863. // tab.appendChild(thirdparty.nong.magnet_table.template.create_row(data[i]))
  864. // }
  865. var loading = thirdparty.nong.magnet_table.template.create_loading();
  866. tab.appendChild(loading);
  867. return tab;
  868. },
  869. handle_event: function (event) {
  870. if (event.target.className == 'nong-copy') {
  871. event.target.innerHTML = '成功';
  872. GM_setClipboard(event.target.href);
  873. setTimeout(function () {
  874. event.target.innerHTML = '复制';
  875. }, 1000);
  876. event.preventDefault(); //阻止跳转
  877. }
  878. else if (event.target.className == 'nong-offline-download') {
  879. var maglink = event.target.parentElement.parentElement.getAttribute('maglink') || event.target.parentElement.parentElement.parentElement.getAttribute('maglink');
  880. GM_setValue('magnet', maglink);
  881.  
  882. var token_url = 'http://115.com/?ct=offline&ac=space&_='; //获取115 token接口
  883. GM_xmlhttpRequest({
  884. method: 'GET',
  885. url: token_url + new Date().getTime(),
  886. onload: function (responseDetails) {
  887. if (responseDetails.responseText.indexOf('html') >= 0) {
  888. //未登录处理
  889. Common.notifiy("115还没有登录",
  890. '请先登录115账户后,再离线下载!',
  891. icon,
  892. 'http://115.com/?mode=login'
  893. );
  894. return false;
  895. }
  896. var sign115 = JSON.parse(responseDetails.response).sign;
  897. var time115 = JSON.parse(responseDetails.response).time;
  898. console.log("uid=" + jav_userID + " sign:" + sign115 + " time:" + time115);
  899. console.log("rsp:" + responseDetails.response);
  900. GM_xmlhttpRequest({
  901. method: 'POST',
  902. url: 'http://115.com/web/lixian/?ct=lixian&ac=add_task_url', //添加115离线任务接口
  903. headers: {
  904. "Content-Type": "application/x-www-form-urlencoded"
  905. },
  906. data: "url=" + encodeURIComponent(maglink) + "&uid=" + jav_userID + "&sign=" + sign115 + "&time=" + time115, //uid=1034119 ,hobby的
  907. onload: function (responseDetails) {
  908. var lxRs = JSON.parse(responseDetails.responseText); //离线结果
  909. if (lxRs.state) {
  910. //离线任务添加成功
  911. Common.notifiy("115老司机自动开车",
  912. '离线任务添加成功',
  913. icon,
  914. 'http://115.com/?tab=offline&mode=wangpan'
  915. );
  916. }
  917. else {
  918. //离线任务添加失败
  919. if (lxRs.errcode == '911') {
  920. lxRs.error_msg = '你的帐号使用异常,需要在线手工重新验证即可正常使用。';
  921. }
  922. Common.notifiy("失败了",
  923. '请重新打开115,' + lxRs.error_msg,
  924. icon,
  925. 'http://115.com/?tab=offline&mode=wangpan'
  926. );
  927. }
  928. console.log("sign:" + sign115 + " time:" + time115);
  929. console.log("磁链:" + maglink + " 下载结果:" + lxRs.state + " 原因:" + lxRs.error_msg);
  930. console.log("rsp:" + responseDetails.response);
  931. }
  932. });
  933. }
  934. });
  935. event.preventDefault(); //阻止跳转
  936. }
  937. },
  938. reg_event: function () { // target 处理 更精准
  939. var list = [
  940. '.nong-copy',
  941. '.nong-offline-download'
  942. ];
  943. for (var i = 0; i < list.length; i++) {
  944. var a = document.querySelectorAll(list[i]);
  945. for (var u = 0; u < a.length; u++) {
  946. a[u].addEventListener('click', this.handle_event, false);
  947. }
  948. }
  949. // var b = document.querySelectorAll('#nong-search-select')[0];
  950. // b.addEventListener('change', this.handle_event, false);
  951.  
  952. },
  953. },
  954. // 挊
  955. searchMagnetRun: function () {
  956. for (var i = 0; i < main_keys.length; i++) {
  957. var v = main[main_keys[i]];
  958.  
  959. //for javlibrary
  960. if ($("#adultwarningprompt")[0] !== null) {
  961. //$("#adultwarningprompt input")[0].click();
  962. }
  963.  
  964. if (v.re.test(location.href)) {
  965. if (v.type === 0) {
  966. try {
  967. main.cur_vid = v.vid();
  968. }
  969. catch (e) {
  970. main.cur_vid = '';
  971. }
  972. if (main.cur_vid) {
  973. GM_addStyle([
  974. '#nong-table-new{margin:10px auto;color:#666 !important;font-size:13px;text-align:center;background-color: #F2F2F2;}',
  975. '#nong-table-new th,#nong-table-new td{text-align: center;height:30px;background-color: #FFF;padding:0 1em 0;border: 1px solid #EFEFEF;}',
  976. '.jav-nong-row{text-align: center;height:30px;background-color: #FFF;padding:0 1em 0;border: 1px solid #EFEFEF;}',
  977. '.nong-copy{color:#08c !important;}',
  978. '.nong-offline{text-align: center;}',
  979. '#jav-nong-head a {margin-right: 5px;}',
  980. '.nong-offline-download{color: rgb(0, 180, 30) !important; margin-right: 4px !important;}',
  981. '.nong-offline-download:hover{color:red !important;}',
  982.  
  983. ].join(''));
  984. main.cur_tab = thirdparty.nong.magnet_table.full();
  985. console.log('挊的番号:', main.cur_vid);
  986. v.proc();
  987.  
  988. // console.log(main.cur_tab)
  989. let t = $('#jav-nong-head')[0].firstChild;
  990. t.firstChild.addEventListener('change', function (e) {
  991. console.log(e.target.value);
  992. GM_setValue('search_index', e.target.value);
  993. let s = $('#nong-table-new')[0];
  994. s.parentElement.removeChild(s);
  995. thirdparty.nong.searchMagnetRun();
  996. });
  997.  
  998. thirdparty.nong.search_engines.cur_engine(main.cur_vid, function (src, data) {
  999. if (data.length === 0) {
  1000. $('#nong-table-new')[0].querySelectorAll('#notice')[0].textContent = 'No search result';
  1001. }
  1002. else {
  1003. thirdparty.nong.magnet_table.updata_table(src, data, 'full');
  1004. /*display search url*/
  1005. var y = $('#jav-nong-head th')[1].firstChild;
  1006. y.href = thirdparty.nong.search_engines.full_url;
  1007. }
  1008. });
  1009. }
  1010. }
  1011. break;
  1012. }
  1013. }
  1014. },
  1015. },
  1016. // 登录115执行脚本,自动离线下载准备步骤
  1017. login115Run: function () {
  1018. jav_userID = GM_getValue('jav_user_id', 0); //115用户ID缓存
  1019. //获取115ID
  1020. if (jav_userID === 0) {
  1021. if (location.host.indexOf('115.com') >= 0) {
  1022. if (typeof (window.wrappedJSObject.user_id) != 'undefined') {
  1023. jav_userID = window.wrappedJSObject.user_id;
  1024. GM_setValue('jav_user_id', jav_userID);
  1025. alert('115登陆成功!');
  1026. return;
  1027. }
  1028. } else {
  1029. //alert('请先登录115账户!');
  1030. Common.notifiy("115还没有登录",
  1031. '请先登录115账户后,再离线下载!',
  1032. icon,
  1033. 'http://115.com/?mode=login'
  1034. );
  1035. GM_setValue('jav_user_id', 0);
  1036. }
  1037. }
  1038.  
  1039. if (location.host.indexOf('115.com') >= 0) {
  1040. /*if(location.href.indexOf('#115helper') < 0)
  1041. {
  1042. console.log("jav老司机:115.com, 不初始化.");
  1043. return false;
  1044. }*/
  1045. console.log('jav老司机:115.com,尝试获取userid.');
  1046. jav_userID = GM_getValue('jav_user_id', 0);
  1047. //debugger;
  1048. if (jav_userID !== 0) {
  1049. console.log("jav老司机: 115账号:" + jav_userID + ",无需初始化.");
  1050. return false;
  1051. }
  1052. jav_userID = $.cookie("OOFL");
  1053. console.log("jav老司机: 115账号:" + jav_userID);
  1054. if (!jav_userID) {
  1055. console.log("jav老司机: 尚未登录115账号");
  1056. return false;
  1057. } else {
  1058. console.log("jav老司机: 初始化成功");
  1059. Common.notifiy('老司机自动开车', '登陆初始化成功,赶紧上车把!', icon, "");
  1060. GM_setValue('jav_user_id', jav_userID);
  1061. }
  1062. return false;
  1063. }
  1064. },
  1065. // 瀑布流脚本
  1066. waterfall: (function () {
  1067. function waterfall(selectorcfg = {}) {
  1068. this.lock = new Lock();
  1069. this.baseURI = this.getBaseURI();
  1070. this.selector = {
  1071. next: 'a.next',
  1072. item: '',
  1073. cont: '', //container
  1074. pagi: '.pagination',
  1075. };
  1076. Object.assign(this.selector, selectorcfg);
  1077. this.pagegen = this.fetchSync(location.href);
  1078. this.anchor = $(this.selector.pagi)[0];
  1079. this._count = 0;
  1080. this._1func = function (cont, elems) {
  1081. cont.empty().append(elems);
  1082. };
  1083. this._2func = function (cont, elems) {
  1084. cont.append(elems);
  1085. };
  1086. this._3func = function (elems) {
  1087. };
  1088.  
  1089. if ($(this.selector.item).length) {
  1090. document.addEventListener('scroll', this.scroll.bind(this));
  1091. document.addEventListener('wheel', this.wheel.bind(this));
  1092. this.appendElems(this._1func);
  1093. }
  1094. }
  1095.  
  1096. waterfall.prototype.getBaseURI = function () {
  1097. let _ = location;
  1098. return `${_.protocol}//${_.hostname}${(_.port && `:${_.port}`)}`;
  1099. };
  1100. waterfall.prototype.getNextURL = function (href) {
  1101. let a = document.createElement('a');
  1102. a.href = href;
  1103. return `${this.baseURI}${a.pathname}${a.search}`;
  1104. };
  1105. // 瀑布流脚本
  1106. waterfall.prototype.fetchURL = function (url) {
  1107. console.log(`fetchUrl = ${url}`);
  1108. const fetchwithcookie = fetch(url, {credentials: 'same-origin'});
  1109. return fetchwithcookie.then(response => response.text())
  1110. .then(html => new DOMParser().parseFromString(html, 'text/html'))
  1111. .then(doc => {
  1112. let $doc = $(doc);
  1113. let href = $doc.find(this.selector.next).attr('href');
  1114. let nextURL = href ? this.getNextURL(href) : undefined;
  1115. let elems = $doc.find(this.selector.item);
  1116. return {
  1117. nextURL,
  1118. elems
  1119. };
  1120. });
  1121. };
  1122. // 瀑布流脚本
  1123. waterfall.prototype.fetchSync = function* (urli) {
  1124. let url = urli;
  1125. do {
  1126. yield new Promise((resolve, reject) => {
  1127. if (this.lock.locked) {
  1128. reject();
  1129. }
  1130. else {
  1131. this.lock.lock();
  1132. resolve();
  1133. }
  1134. }).then(() => {
  1135. return this.fetchURL(url).then(info => {
  1136. url = info.nextURL;
  1137. return info.elems;
  1138. })
  1139. ;
  1140. }).then(elems => {
  1141. this.lock.unlock();
  1142. return elems;
  1143. }).catch((err) => {
  1144. // Locked!
  1145. }
  1146. )
  1147. ;
  1148. } while (url);
  1149. };
  1150. // 瀑布流脚本
  1151. waterfall.prototype.appendElems = function () {
  1152. let nextpage = this.pagegen.next();
  1153. if (!nextpage.done) {
  1154. nextpage.value.then(elems => {
  1155. const cb = (this._count === 0) ? this._1func : this._2func;
  1156. cb($(this.selector.cont), elems);
  1157. this._count += 1;
  1158. // hobby mod script
  1159. this._3func(elems);
  1160. })
  1161. ;
  1162. }
  1163. return nextpage.done;
  1164. };
  1165. // 瀑布流脚本
  1166. waterfall.prototype.end = function () {
  1167. console.info('The End');
  1168. document.removeEventListener('scroll', this.scroll.bind(this));
  1169. document.removeEventListener('wheel', this.wheel.bind(this));
  1170. let $end = $(`<h1>The End</h1>`)
  1171. $(this.anchor).replaceWith($end);
  1172. };
  1173. waterfall.prototype.reachBottom = function (elem, limit) {
  1174. return (elem.getBoundingClientRect().top - $(window).height()) < limit;
  1175. };
  1176.  
  1177. waterfall.prototype.scroll = function () {
  1178. if (this.reachBottom(this.anchor, 500) && this.appendElems(this._2func)) {
  1179. this.end();
  1180. }
  1181. };
  1182.  
  1183. waterfall.prototype.wheel = function () {
  1184. if (this.reachBottom(this.anchor, 1000) && this.appendElems(this._2func)) {
  1185. this.end();
  1186. }
  1187. };
  1188. waterfall.prototype.setFirstCallback = function (f) {
  1189. this._1func = f;
  1190. };
  1191. waterfall.prototype.setSecondCallback = function (f) {
  1192. this._2func = f;
  1193. };
  1194. waterfall.prototype.setThirdCallback = function (f) {
  1195. this._3func = f;
  1196. };
  1197.  
  1198. return waterfall;
  1199. })(),
  1200. // 瀑布流脚本
  1201. waterfallScrollInit: function () {
  1202. var w = new thirdparty.waterfall({});
  1203. // javbus.com、avmo.pw、avso.pw
  1204. var $pages = $('div#waterfall div.item');
  1205. if ($pages.length) {
  1206. // javbus.com
  1207. if ($('a#next').length) {
  1208. w = new thirdparty.waterfall({
  1209. next: 'a#next',
  1210. item: 'div#waterfall div.item',
  1211. cont: '#waterfall',
  1212. pagi: '.pagination-lg',
  1213. });
  1214. }
  1215. //avmo.pw、avso.pw
  1216. if ($('a[name="nextpage"]').length) {
  1217. w = new thirdparty.waterfall({
  1218. next: 'a[name="nextpage"]',//nextpage
  1219. item: 'div#waterfall div.item',
  1220. cont: '#waterfall',
  1221. pagi: '.pagination',
  1222. });
  1223. }
  1224. }
  1225.  
  1226. // javlibrary
  1227. var $pages2 = $('div.videos div.video');
  1228. if ($pages2.length) {
  1229. GM_addStyle([
  1230. '.videothumblist .videos .video {height: 265px;padding: 0px;margin: 4px;}',
  1231. ].join(''));
  1232. $pages2[0].parentElement.id = "waterfall";
  1233. w = new thirdparty.waterfall({
  1234. next: 'a[class="page next"]',
  1235. item: 'div.videos div.video',
  1236. cont: '#waterfall',
  1237. pagi: '.page_selector',
  1238. });
  1239. }
  1240.  
  1241. w.setSecondCallback(function (cont, elems) {
  1242. if (location.pathname.includes('/star/')) {
  1243. cont.append(elems.slice(1));
  1244. } else {
  1245. cont.append(elems);
  1246. }
  1247. });
  1248.  
  1249. w.setThirdCallback(function (elems) {
  1250. // hobby mod script
  1251. function filerMonth(indexCd_id, dateString) {
  1252. //过滤最新X月份的影片
  1253. if ($(indexCd_id).context.URL.indexOf("bestrated.php?delete") > 0) {
  1254. if ($(indexCd_id).context.URL.indexOf("bestrated.php?deleteOneMonthAway") > 0 && !Common.isLastXMonth(dateString, 1)) {
  1255. $(indexCd_id).remove();
  1256. }
  1257. else if ($(indexCd_id).context.URL.indexOf("bestrated.php?deleteTwoMonthAway") > 0 && !Common.isLastXMonth(dateString, 2)) {
  1258. $(indexCd_id).remove();
  1259. }
  1260. }
  1261. };
  1262.  
  1263. function filerScore(indexCd_id, pingfengString) {
  1264. //过滤X评分以下的影片
  1265. //if(vid == 'javlikq7qu')debugger;
  1266. if ($(indexCd_id).context.URL.indexOf("?delete") > 0) {
  1267. if ($(indexCd_id).context.URL.indexOf("delete8down") > 0 && Number(pingfengString.replace('(', '').replace(')', '')) <= 8) {
  1268. //debugger;
  1269. $(indexCd_id).remove();
  1270. }
  1271. else if ($(indexCd_id).context.URL.indexOf("delete9down") > 0 && Number(pingfengString.replace('(', '').replace(')', '')) <= 9) {
  1272. $(indexCd_id).remove();
  1273. }
  1274. }
  1275. };
  1276.  
  1277. function setbgcolor(indexCd_id, dateString) {
  1278. // 如果是最近两个月份的影片标上背景色
  1279. if ($(indexCd_id).context.URL.indexOf("bestrated") > 0 && Common.isLastXMonth(dateString, 2)) {
  1280. //$(indexCd_id).css("background-color", "blanchedalmond");
  1281. $('div[style="color: red;"]', $(indexCd_id)).css("background-color", "yellow");
  1282. //debugger;
  1283. }
  1284. };
  1285.  
  1286. if (document.title.search(/JAVLibrary/) > 0 && elems) {
  1287. for (let i = 0; i < elems.length; i++) {
  1288. let _vid = $(elems[i]).attr("id").replace('vid_', '');//vid_javlikd42y
  1289. // 给列表中的影片添加鼠标点击事件
  1290. $("a", $("#vid_" + _vid)).first().mousedown(function (event) {
  1291. // 判断鼠标左键或中间才执行
  1292. if (event.button < 2) {
  1293. // 设置点击后填充新的背景色peachpuff
  1294. $("#vid_" + _vid).css("background-color", "peachpuff");
  1295. }
  1296. });
  1297.  
  1298. // 查找影片是否存在我浏览过的表中
  1299. MyBrowse.findBy(persistence, null, 'index_cd', _vid, function (findObj) {
  1300. //debugger;
  1301. if (findObj) {//存在
  1302. //debugger;
  1303. let indexCd_id = "#vid_" + findObj.index_cd;
  1304. if ($(indexCd_id).context.URL.indexOf("bestrated.php?filterMyBrowse") > 0) {
  1305. $(indexCd_id).remove();
  1306. }
  1307. else {
  1308. // 查找影片是否存在我的影片资料表中
  1309. MyMovie.findBy(persistence, null, 'index_cd', findObj.index_cd, function (findObj) {
  1310. if (findObj) {//存在
  1311. let indexCd_id = "#vid_" + findObj.index_cd;
  1312. $(indexCd_id).css("background-color", "peachpuff");//hotpink,khaki,indianred,peachpuff
  1313. $(indexCd_id).children("a").append("<div class='id'style='color: red;'>" + findObj.release_date + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + findObj.score + "</div>");
  1314. $(indexCd_id).children("a").attr("release_date", findObj.release_date);
  1315.  
  1316. let r = Math.random() / 100;
  1317. let s = 0;
  1318. if (findObj.score.replace(/[\\(\\)]/g, "") != '') {
  1319. s = r + parseFloat(findObj.score.replace(/[\\(\\)]/g, ""));
  1320. }
  1321. else {
  1322. s = 0 + r;
  1323. }
  1324. $(indexCd_id).children("a").attr("score", s);
  1325.  
  1326. setbgcolor(indexCd_id, findObj.release_date);
  1327. filerMonth(indexCd_id, findObj.release_date);
  1328. filerScore(indexCd_id, findObj.score);
  1329. }
  1330. else {//不存在
  1331. // 加入影片资料到表中
  1332. //debugger;
  1333. addMovie(_vid);
  1334. persistence.flush();
  1335. }
  1336. });
  1337. }
  1338. }
  1339. else {//不存在
  1340. //console.log(`vid = ${_vid}`);
  1341. //debugger;
  1342. //异步请求调用内页详情的访问地址
  1343. //debugger;
  1344. GM_xmlhttpRequest({
  1345. method: "GET",
  1346. //内页地址
  1347. url: location.origin + "/cn/?v=" + _vid,
  1348. onload: function (result) {
  1349. let vid = result.finalUrl.split("=")[1];//例如:http://www.j12lib.com/cn/?v=javlikd42a
  1350. let bodyStr = result.responseText;
  1351. let date_idx = bodyStr.search(/"video_date" class="item"/);//<span class="score">(9.70)</span>
  1352. let yixieBody = bodyStr.substring(date_idx, bodyStr.search(/"video_genres"/));
  1353. let dateString = yixieBody.substring(yixieBody.indexOf('video_date') + 92, yixieBody.indexOf('video_date') + 102);
  1354. let pingfengString = "";
  1355. if (yixieBody.indexOf('score">') > 0) {
  1356. pingfengString = yixieBody.substring(yixieBody.indexOf('score">') + 7, yixieBody.indexOf('score">') + 14).replace('</span>', '').replace('<', '');
  1357. }
  1358. let indexCd_id = "#vid_" + vid;
  1359. $(indexCd_id).children("a").append("<div class='id'style='color: red;'>" + dateString + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + pingfengString + "</div>");
  1360.  
  1361. $(indexCd_id).children("a").attr("release_date", dateString);
  1362.  
  1363. let r = Math.random() / 100;
  1364. let s = 0;
  1365. if (pingfengString.replace(/[\\(\\)]/g, "") != '') {
  1366. s = r + parseFloat(pingfengString.replace(/[\\(\\)]/g, ""));
  1367. }
  1368. else {
  1369. s = 0 + r;
  1370. }
  1371. $(indexCd_id).children("a").attr("score", s);
  1372.  
  1373. setbgcolor(indexCd_id, dateString);
  1374. filerMonth(indexCd_id, dateString);
  1375. filerScore(indexCd_id, pingfengString);
  1376. },
  1377. onerror: function (e) {
  1378. console.log(e);
  1379. }
  1380. });//end GM_xmlhttpRequest
  1381. }
  1382. });
  1383.  
  1384. }
  1385. }
  1386. });
  1387. // javbus.com、avmo.pw、avso.pw 样式
  1388. GM_addStyle([
  1389. '#waterfall {height: initial !important;width: initial !important;display: flex;flex-direction: row;flex-wrap: wrap;}',
  1390. '#waterfall .item.item {position: relative !important;top: initial !important;left: initial !important;float: none;flex: 20%;}',
  1391. '#waterfall .movie-box,#waterfall .avatar-box {width: initial !important;display: flex;}',
  1392. '#waterfall .movie-box .photo-frame {overflow: visible;}',
  1393. ].join(''));
  1394. },
  1395. };
  1396.  
  1397. function loadData(pageName, func) {
  1398. var loadPageNumData = function (pageName, PageNum, func) {
  1399. console.log("打开链接url:" + location.origin + "/cn/" + pageName + ".php?&sort=added&page=" + PageNum);
  1400. // 浏览器对同一域名进行请求的最大并发连接数:chrome为6
  1401. GM_xmlhttpRequest({
  1402. method: "GET",
  1403. url: location.origin + "/cn/" + pageName + ".php?&sort=added&page=" + PageNum,
  1404. onload: function (result) {
  1405. let doc = result.responseText;
  1406. let docArr = doc.split("的影片: ");
  1407. //debugger;
  1408. let totalNum = parseInt(docArr[1].substring(0, docArr[1].search(/<\/div/)));
  1409. //设置初始化总页数
  1410. GM_setValue(pageName + "_pageNum", parseInt((totalNum + 19) / 20));
  1411.  
  1412. //GM_setValue(pageName + "_next", true);
  1413.  
  1414. let tableText = doc.substring(doc.search(/<table class="videotextlist">/), doc.search(/<table style="width: 95%; margin: 10px auto;">/));
  1415. //<table class="videotextlist"> //<table style="width: 95%; margin: 10px auto;">
  1416. let $movList = $(Common.parsetext(tableText)).find("tr");
  1417.  
  1418. let indexArrStr = "0";
  1419. let timeArrStr = "0";
  1420. var myBrowseJson = "";
  1421.  
  1422. for (let i = 1; i < $movList.length; i++) {
  1423. let movie = $movList.get(i);
  1424. let $aEle = $($(movie).children("td.title").find("a").get(0));
  1425. // 索引编码
  1426. let index_cd = $aEle.attr("href").split("=")[1];
  1427.  
  1428. // 创建时间
  1429. let add_time = $($(movie).children("td").get(2)).text();
  1430.  
  1431. indexArrStr = indexArrStr + index_cd + ',';
  1432. timeArrStr = timeArrStr + add_time + "|";
  1433. myBrowseJson = myBrowseJson + '{"index_cd":"' + index_cd + '","add_time":"' + add_time + '"},';
  1434. }
  1435.  
  1436. // debugger;
  1437. GM_setValue(pageName + "_myBrowseJson" + result.finalUrl.split("page=")[1], myBrowseJson);
  1438. //GM_setValue(pageName + "_indexArr" + result.finalUrl.split("page=")[1], indexArrStr);
  1439. //GM_setValue(pageName + "_timeArr" + result.finalUrl.split("page=")[1], timeArrStr);
  1440.  
  1441. if (PageNum === 1) {
  1442. func();
  1443. }
  1444. },
  1445. onerror: function (e) {
  1446. console.log('打开我想要的页面出现错误');
  1447. }
  1448. });
  1449. }
  1450.  
  1451. loadPageNumData(pageName, 1, function () {
  1452. for (let i = 2; i < GM_getValue(pageName + "_pageNum") + 1; i++) {
  1453. // 每读取6页数据暂停一些时间
  1454. let j = parseInt(i / 6);
  1455. console.log("j=" + j);
  1456.  
  1457. setTimeout(function () {
  1458. loadPageNumData(pageName, i, function () {
  1459. });
  1460. }, j * 500);
  1461.  
  1462.  
  1463. if (i == GM_getValue(pageName + "_pageNum")) {
  1464. setTimeout(function () {
  1465. console.log("parseInt(i / 6):" + parseInt(i / 6));
  1466. func();
  1467. }, parseInt(i / 6) * 500);
  1468. }
  1469.  
  1470. }
  1471. });
  1472. }
  1473.  
  1474. /**
  1475. *
  1476. * @param pageName
  1477. */
  1478. function mergeJson(pageName) {
  1479. // 循环执行,每次延迟执行
  1480. var s1 = setInterval(function () {
  1481. var p = GM_getValue(pageName + "_pageNum");
  1482. if (p > 0) {
  1483. var i = 1;
  1484. GM_setValue(pageName + "_myBrowseJsonAll", "");
  1485. var s2 = setInterval(function () {
  1486. let tempJson = GM_getValue(pageName + "_myBrowseJson" + i);
  1487. //console.log("i = " + i )
  1488. if (tempJson && tempJson !== "") {
  1489. GM_setValue(pageName + "_myBrowseJsonAll", GM_getValue(pageName + "_myBrowseJsonAll") + tempJson);
  1490. if (i < p) {
  1491. i++;
  1492. }
  1493. else {
  1494. //停止s2循环
  1495. //console.log(pageName + "Json:" + GM_getValue(pageName + "_myBrowseJsonAll"));
  1496. console.log(pageName + "doNum:" + (GM_getValue("doNum") + 1));
  1497. GM_setValue("doNum", GM_getValue("doNum") + 1);
  1498. clearInterval(s2);
  1499. }
  1500. }
  1501. }, 50);
  1502. //停止s1循环
  1503. clearInterval(s1);
  1504. }
  1505. }, 100);
  1506. }
  1507.  
  1508. /**
  1509. * JSON数组去重
  1510. * @param: [array] json Array
  1511. * @param: [string] 唯一的key名,根据此键名进行去重
  1512. */
  1513. function uniqueArray(array, key, func) {
  1514. var result = [array[0]];
  1515. for (var i = 1; i < array.length; i++) {
  1516. var item = array[i];
  1517. var repeat = false;
  1518. for (var j = 0; j < result.length; j++) {
  1519. if (item[key] == result[j][key]) {
  1520. func(item, result[j]);
  1521. repeat = true;
  1522. break;
  1523. }
  1524. }
  1525. if (!repeat) {
  1526. result.push(item);
  1527. }
  1528. }
  1529. return result;
  1530. }
  1531.  
  1532. function addJsonsToDB(hasDo, jsons, func, callback) {
  1533. if (!hasDo) {
  1534. for (let i = 0; i < jsons.length; i++) {
  1535. let jsonObj = jsons[i];
  1536. let abc = func();
  1537. abc.index_cd = jsonObj.index_cd;
  1538. abc.add_time = jsonObj.add_time;
  1539. persistence.add(abc);
  1540. //persistence.flush(); 出现my_browse插入不了数据的情况,然后注释了。
  1541. //debugger;
  1542. }
  1543. //debugger;
  1544. }
  1545. persistence.flush(callback);
  1546. }
  1547.  
  1548. function addMovie(index_cd) {
  1549. var index_cc = index_cd;
  1550. GM_xmlhttpRequest({
  1551. method: "GET",
  1552. url: location.origin + "/cn/?v=" + index_cd,
  1553. onload: function (result) {
  1554. let doc = result.responseText;
  1555.  
  1556. let movie_name = doc.substring(doc.search(/<title>/) + 7, doc.search(/ - JAVLibrary<\/title>/));
  1557. let movie_info = doc.substring(doc.search(/<table id="video_jacket_info">/), doc.search(/<div id="video_favorite_edit" class="">/));
  1558. movie_info = movie_info.replace("src", "hobbysrc");
  1559. let $doc = $(Common.parsetext(movie_info));
  1560.  
  1561. let movie = new MyMovie();
  1562. movie.index_cd = index_cc;
  1563. //debugger;
  1564. movie.index_cd = result.finalUrl.split("v=")[1];
  1565. movie.code = $('.header', $doc)[0].nextElementSibling.textContent;
  1566. movie.release_date = $('#video_date .text', $doc).text();
  1567. movie.duration = $('#video_length .text', $doc).text();
  1568. movie.director = $('#video_director .text', $doc).text();
  1569. movie.maker = $('#video_maker .text', $doc).text();
  1570. movie.score = $('#video_review .text .score', $doc).text();
  1571. movie.actor = $('#video_cast .text', $doc).text();
  1572. movie.cover_img_url = $('#video_jacket_img', $doc).attr("hobbysrc").replace("//", "");
  1573. movie.thumbnail_url = movie.cover_img_url.replace("pl", "ps");
  1574. movie.movie_name = movie_name;
  1575. movie.publisher = $('#video_label .text a', $doc).text();
  1576. movie.add_time = (new Date()).Format("yyyy-MM-dd hh:mm:ss");
  1577.  
  1578. let myBrowseJsonArray = JSON.parse(GM_getValue("myBrowseAll"));
  1579. let jsonObj = myBrowseJsonArray.filter((p) => {
  1580. return p.index_cd == result.finalUrl.split("v=")[1];
  1581. });
  1582. //debugger;
  1583. movie.add_time = jsonObj[0].add_time;
  1584. persistence.add(movie);
  1585. //persistence.flush();
  1586. GM_setValue("addMovieNum", GM_getValue("addMovieNum") + 1);
  1587. console.log("addmovieNum:" + (GM_getValue("addMovieNum") + 1));
  1588. },
  1589. onerror: function (e) {
  1590. console.log('出现错误');
  1591. }
  1592. });
  1593. }
  1594.  
  1595. /**
  1596. * javbus详情页磁链列表增加复制、115离线快捷键功能函数
  1597. */
  1598. function javbusUs() {
  1599. $('#magnet-table tbody tr td[colspan="4"]').attr("colspan","5");
  1600. let tr_array = $('#magnet-table tr[height="35px"]');
  1601.  
  1602. for (var i = 0; i < tr_array.length; i++) {
  1603. let trEle = tr_array[i];
  1604. //debugger;
  1605. let magnetUrl = $(trEle).find("td a")[0].href;
  1606. $(trEle).append("<td style='text-align:center;'><div><a class='nong-copy' href='" + magnetUrl + "'>复制</a></div></td>");
  1607. $(trEle).append("<td><div class='nong-offline'><a class='nong-offline-download' target='_blank' href='http://115.com/?tab=offline&amp;mode=wangpan'>115离线</a></div></td>");
  1608. //TODO
  1609. $(trEle).attr("maglink", magnetUrl);
  1610. $(trEle).find(".nong-copy")[0].addEventListener('click', thirdparty.nong.magnet_table.handle_event, false);
  1611. $(trEle).find(".nong-offline-download")[0].addEventListener('click', thirdparty.nong.magnet_table.handle_event, false);
  1612. //.addEventListener('click', this.handle_event, false);
  1613. }
  1614. }
  1615.  
  1616. function mainRun() {
  1617. if (location.host.indexOf('115.com') >= 0) {
  1618. thirdparty.login115Run();
  1619. }
  1620.  
  1621. if ((/(JAVLibrary|JavBus|AVMOO|AVSOX)/g).test(document.title) || $("footer:contains('JavBus')").length){
  1622.  
  1623. GM_addStyle([
  1624. '.min {width:66px;min-height: 233px;height:auto;cursor: pointer;}',
  1625. '.container {width: 100%;float: left;}',
  1626. '.col-md-3 {float: left;max-width: 260px;}',
  1627. '.col-md-9 {width: inherit;}',
  1628. '.footer {padding: 20px 0;background: #1d1a18;float: left;}',
  1629. '#nong-table-new {margin: initial !important;important;color: #666 !important;font-size: 13px;text-align: center;background-color: #F2F2F2;float: left;}',
  1630. '.header_hobby {font-weight: bold;text-align: right;width: 75px;}',
  1631. ].join(''));
  1632.  
  1633. if (document.title.search(/JAVLibrary/) > 0) {
  1634. if ((/(bestrated|newrelease|vl_update|mostwanted|vl_star|vl_genre)/g).test(document.URL)) {
  1635.  
  1636. let a1 = document.createElement('a');
  1637. let a2 = document.createElement('a');
  1638. $(a1).append('&nbsp;&nbsp;按评分排序');
  1639. $(a1).css({
  1640. "color": "blue",
  1641. "font": "bold 12px monospace"
  1642. });
  1643. $(a1).attr("href", "#");
  1644. $(a1).click(function () {
  1645. let div_array = $("div.videos div.video");
  1646. div_array.sort(function (a, b) {
  1647. //debugger;
  1648. let a_score = parseFloat($(a).children("a").attr("score"));
  1649. let b_score = parseFloat($(b).children("a").attr("score"));
  1650. if (a_score > b_score) {
  1651. return -1;
  1652. }
  1653. else if (a_score === b_score) {
  1654. return 0;
  1655. }
  1656. else {
  1657. return 1;
  1658. }
  1659. });
  1660.  
  1661. // 删除Dom列表数据关系,重新添加排序数据
  1662. div_array.detach().appendTo("#waterfall");
  1663.  
  1664. });
  1665.  
  1666. $(a2).append('&nbsp;&nbsp;按时间排序');
  1667. $(a2).css({
  1668. "color": "blue",
  1669. "font": "bold 12px monospace"
  1670. });
  1671. $(a2).attr("href", "#");
  1672. $(a2).click(function () {
  1673. let div_array = $("div.videos div.video");
  1674. //debugger;
  1675. div_array.sort(function (a, b) {
  1676. //debugger;
  1677. let a_time = new Date($(a).children("a").attr("release_date").replace(/-/g, "\/")).getTime();
  1678. let b_time = new Date($(b).children("a").attr("release_date").replace(/-/g, "\/")).getTime();
  1679. let a_score = parseFloat($(a).children("a").attr("score"));
  1680. let b_score = parseFloat($(b).children("a").attr("score"));
  1681. if (a_time > b_time) {
  1682. return -1;
  1683. }
  1684. else if (a_time === b_time) {
  1685. return (a_score > b_score) ? -1 : 1;
  1686. }
  1687. else {
  1688. return 1;
  1689. }
  1690. });
  1691.  
  1692. // 删除Dom列表数据关系,重新添加排序数据
  1693. div_array.detach().appendTo("#waterfall");
  1694.  
  1695. });
  1696. $(".left select").after($(a2));
  1697. $(".left select").after($(a1));
  1698. }
  1699.  
  1700.  
  1701. if (document.URL.indexOf("bestrated") > 0) {
  1702. $(".displaymode .right").prepend("<a href='/cn/vl_bestrated.php?deleteTwoMonthAway' style='color: red;'>只看近两月份&nbsp;&nbsp;</a>");
  1703. $(".displaymode .right").prepend("<a href='/cn/vl_bestrated.php?deleteOneMonthAway' style='color: red;'>只看当前月份&nbsp;&nbsp;</a>");
  1704. $(".displaymode .right").prepend("<a href='/cn/vl_bestrated.php?filterMyBrowse' style='color: red;'>不看我阅览过(上个月)&nbsp;&nbsp;</a>");
  1705. $(".displaymode .right").prepend("<a href='/cn/vl_bestrated.php?filterMyBrowse&mode=2' style='color: red;'>不看我阅览过(全部)&nbsp;&nbsp;</a>");
  1706. //<a href="/cn/vl_bestrated.php?delete" style="color: red;">只显示最近发行的&nbsp;&nbsp;</a>
  1707. //todo
  1708.  
  1709. }
  1710. else if (document.URL.indexOf("vl_newrelease") > 0 || document.URL.indexOf("vl_update") > 0 || document.URL.indexOf("vl_genre") > 0) {
  1711. debugger;
  1712. $(".displaymode .right").prepend("<a href='" + document.location.origin + document.location.pathname
  1713. + "?delete9down" + document.location.search.replace('?', '&') + "' style='color: red;'>只看9分以上&nbsp;&nbsp;</a>");
  1714. $(".displaymode .right").prepend("<a href='" + document.location.origin + document.location.pathname
  1715. + "?delete8down" + document.location.search.replace('?', '&') + "' style='color: red;'>只看8分以上&nbsp;&nbsp;</a>");
  1716. //<a href="/cn/vl_bestrated.php?delete" style="color: red;">只显示最近发行的&nbsp;&nbsp;</a>
  1717. //todo
  1718. }
  1719.  
  1720. //重置数据库
  1721. // persistence.reset();
  1722. // persistence.schemaSync();
  1723.  
  1724. //debugger;
  1725. //数据库初始化 start01
  1726. JavWebSql.DBinit();
  1727. persistence.flush();
  1728. //end01 cpu忽略
  1729.  
  1730. //a href="myaccount.php"
  1731. if ($('a[href="myaccount.php"]').length) {
  1732. // 已经登录
  1733. // 从未同步过,同步云数据到本地数据库
  1734. let isSync = GM_getValue(location.host + "_doDataSyncStepAll", false);
  1735.  
  1736. console.log(location.href + "是否从未同步过:" + !isSync);
  1737. if (!isSync) {
  1738. // 立即下载数据
  1739. GM_setValue("mv_wanted_pageNum", 0);
  1740. GM_setValue("mv_wanted_pageNum", 0);
  1741. GM_setValue("mv_wanted_pageNum", 0);
  1742.  
  1743. //debugger;
  1744. //start02
  1745. loadData("mv_wanted", function () {
  1746. loadData("mv_watched", function () {
  1747. loadData("mv_owned", function () {
  1748. //end02 cpu最高20
  1749. //debugger;
  1750. //start03
  1751. GM_setValue("doNum", 0);
  1752. mergeJson("mv_wanted");
  1753. mergeJson("mv_watched");
  1754. mergeJson("mv_owned");
  1755. //end03 cpu忽略
  1756. //debugger;
  1757. var s3 = setInterval(function () {
  1758. let n = GM_getValue("doNum");
  1759. if (n === 3) {
  1760. let j1 = GM_getValue("mv_wanted_myBrowseJsonAll");
  1761. let j2 = GM_getValue("mv_watched_myBrowseJsonAll");
  1762. let j3 = GM_getValue("mv_owned_myBrowseJsonAll");
  1763. let mv_owned_myBrowseJsonAll = j3.substring(0, j3.length - 1);
  1764. let myBrowseAll = j1 + j2 + mv_owned_myBrowseJsonAll;
  1765.  
  1766.  
  1767. var myBrowseArray = JSON.parse("[" + myBrowseAll + "]");
  1768. var myWantArray = JSON.parse("[" + j1.substring(0, j1.length - 1) + "]");
  1769. var mySeenArray = JSON.parse("[" + j2.substring(0, j2.length - 1) + "]");
  1770. var myHaveArray = JSON.parse("[" + mv_owned_myBrowseJsonAll + "]");
  1771.  
  1772.  
  1773. //debugger;
  1774. myBrowseArray = uniqueArray(myBrowseArray, "index_cd", function (item, resultObj) {
  1775. if (item["add_time"] < resultObj["add_time"]) {
  1776. resultObj["add_time"] = item["add_time"];
  1777. }
  1778. });
  1779.  
  1780. GM_setValue("myBrowseAll", JSON.stringify(myBrowseArray));
  1781. //console.log(myBrowseArray);
  1782.  
  1783. var hasStepOne = GM_getValue(location.host + "_stepOne", false);
  1784. var startTime = new Date();
  1785. //debugger;
  1786. addJsonsToDB(hasStepOne, myBrowseArray, function () {
  1787. return new MyBrowse();
  1788. }, function () {
  1789. //debugger;
  1790. addJsonsToDB(hasStepOne, myWantArray, function () {
  1791. return new MyWant();
  1792. }, function () {
  1793. //debugger;
  1794. addJsonsToDB(hasStepOne, mySeenArray, function () {
  1795. return new MySeen();
  1796. }, function () {
  1797. //debugger;
  1798. addJsonsToDB(hasStepOne, myHaveArray, function () {
  1799. return new MyHave();
  1800. }, function () {
  1801. //debugger;
  1802. GM_setValue(location.host + "_stepOne", true);
  1803. let b = GM_getValue(location.host + "_stepTwo", false);
  1804. if (!b) {
  1805. GM_setValue("addMovieNum", 0);
  1806. for (let i = 0; i < myBrowseArray.length; i++) {
  1807. //console.log("aaaa:" + (GM_getValue("stepTwoNum", 1) == 1) + " bbbb:" + (i >= GM_getValue("stepTwoNum", 1)));
  1808. if ((GM_getValue(location.host + "_stepTwoNum", 1) == 1) || (i >= GM_getValue(location.host + "_stepTwoNum", 1))) {
  1809. //debugger;
  1810. let jsonObj = myBrowseArray[i];
  1811. addMovie(jsonObj.index_cd);
  1812. }
  1813. else {
  1814. GM_setValue("addMovieNum", i + 1);
  1815. }
  1816. }
  1817.  
  1818. // persistence.flush(function () {
  1819. // GM_setValue("stepTwoNum", GM_getValue("addMovieNum", 0));
  1820. // });
  1821.  
  1822. //console.log("time:" + (new Date() - startTime));
  1823.  
  1824. var s4 = setInterval(function () {
  1825. let num = GM_getValue("addMovieNum", 0);
  1826. let stepTwoNum = GM_getValue(location.host + "_stepTwoNum", 1);
  1827. //console.log("i = " + num)
  1828. if (num === myBrowseArray.length) {
  1829. persistence.flush(function () {
  1830. GM_setValue(location.host + "_stepTwo", true);
  1831. GM_setValue(location.host + "_doDataSyncStepAll", true);
  1832. console.log("time:" + (new Date() - startTime));
  1833. });
  1834. clearInterval(s4);
  1835. }
  1836. //console.log("1111:" + (num > stepTwoNum) + " 22222:" + ((num <= 50) || (num % stepTwoNum >= 50)));
  1837. //debugger;
  1838. // 没超过50个数据,持久化一次
  1839. if (num >= stepTwoNum && ((num - stepTwoNum) >= 600)) {
  1840. persistence.flush(function () {
  1841. GM_setValue(location.host + "_stepTwoNum", num);
  1842. })
  1843. }
  1844. }, 150);
  1845. }
  1846. });
  1847. });
  1848. });
  1849. });
  1850. clearInterval(s3);
  1851. }
  1852. }, 300)
  1853. });
  1854. });
  1855. });
  1856.  
  1857.  
  1858. }
  1859.  
  1860.  
  1861. // 增加同步数据到本地的触发按钮
  1862. }
  1863. }
  1864.  
  1865.  
  1866. //获取所有番号影片链接的a元素
  1867. var a_array = $("div[class='item'] a");
  1868. for (var index = 0; index < a_array.length; index++) {
  1869. var aEle = a_array[index];
  1870. $(aEle).attr("target", "_blank");
  1871. }
  1872.  
  1873.  
  1874. //var AVID = "";
  1875. //获取番号影片详情页的番号 例如:https://www.javbus.com/CHN-141 || ttp://www.javlibrary.com/cn/?v=javlilzo4e
  1876. if ($('.header').length) {
  1877. let AVID = $('.header')[0].nextElementSibling.textContent;
  1878.  
  1879. window.onload = function () {
  1880. $('iframe').remove();
  1881. };
  1882. $($('.header')[0]).attr("class", "header_hobby");
  1883.  
  1884. // 只支持javlibray处理已阅影片
  1885. if (document.title.search(/JAVLibrary/) > 0) {
  1886. let movie = new MyMovie();
  1887.  
  1888. let vid = location.search.split("=")[1];
  1889.  
  1890. movie.index_cd = vid;
  1891. movie.code = AVID;
  1892. movie.release_date = $('#video_date .text').text();
  1893. movie.duration = $('#video_length .text').text();
  1894. movie.director = $('#video_director .text').text();
  1895. movie.maker = $('#video_maker .text').text();
  1896. movie.score = $('#video_review .text .score').text();
  1897. movie.actor = $('#video_cast .text').text();
  1898. movie.cover_img_url = $('#video_jacket_img').attr("src");
  1899. movie.thumbnail_url = movie.cover_img_url.replace("pl", "ps");
  1900. movie.movie_name = $('#video_title a').text();
  1901. movie.publisher = $('#video_label .text a').text();
  1902. movie.add_time = (new Date()).Format("yyyy-MM-dd hh:mm:ss");
  1903.  
  1904. //查找是否存在此番号数据
  1905. MyMovie.findBy(persistence, null, 'code', AVID, function (findObj) {
  1906. let my_borwse = new MyBrowse();
  1907. if (!findObj) {//不存在
  1908. persistence.add(movie);
  1909.  
  1910. my_borwse.index_cd = movie.index_cd;
  1911. my_borwse.add_time = (new Date()).Format("yyyy-MM-dd hh:mm:ss");
  1912. persistence.add(my_borwse);
  1913. persistence.flush();
  1914. }
  1915. else {//存在
  1916. movie.movie_id = findObj.movie_id;
  1917. movie.add_time = findObj.add_time;
  1918. persistence.remove(findObj);
  1919. persistence.add(movie);
  1920.  
  1921. MyBrowse.findBy(persistence, null, 'index_cd', movie.index_cd, function (findObj) {
  1922. my_borwse.index_cd = movie.index_cd;
  1923. my_borwse.add_time = (new Date()).Format("yyyy-MM-dd hh:mm:ss");
  1924. if (findObj) {//存在
  1925. persistence.remove(findObj);
  1926. }
  1927. persistence.add(my_borwse);
  1928. persistence.flush();
  1929. });
  1930.  
  1931. }
  1932.  
  1933. });
  1934. }
  1935.  
  1936. //debugger;
  1937. console.log("番号输出:" + AVID);
  1938. //console.log("时间000000:"+ new Date().getTime());
  1939. Common.addAvImg(AVID, function ($img) {
  1940. //https://www.javbus.com/CHN-141
  1941. var divEle = $("div[class='col-md-3 info']")[0];
  1942. $(divEle).attr("id", "video_info");
  1943. if (divEle) {
  1944. $(divEle.parentElement).append($img);
  1945. $img.click(function () {
  1946. $(this).toggleClass('min');
  1947. if ($(this).attr("class")) {
  1948. this.parentElement.parentElement.scrollIntoView();
  1949. }
  1950. });
  1951. }
  1952. // http://www.javlibrary.com/cn/?v=javlilzo4e
  1953. divEle = $("div[id='video_favorite_edit']")[0];
  1954. if (divEle) {
  1955. $img.attr("style", "cursor: pointer;");
  1956. $(divEle).after($img);
  1957. $img.click(function () {
  1958. $(this).toggleClass('min');
  1959. if ($(this).attr("class")) {
  1960. this.parentElement.parentElement.scrollIntoView();
  1961. }
  1962. });
  1963. }
  1964. });
  1965.  
  1966.  
  1967. // 修改javbus磁链列表头,增加两列
  1968. $('#magnet-table tbody tr').append('<td style="text-align:center;white-space:nowrap">操作</td><td style="text-align:center;white-space:nowrap">离线下载</td>');
  1969. // 先执行一次,针对已经提前加载出磁链列表结果时有效
  1970. javbusUs();
  1971. // 针对为提前加载出磁链列表结果,通过dom元素是否改变事件来判断是否执行功能。
  1972. $('#magnet-table').on("DOMNodeInserted",function () {
  1973. // 触发后关闭监听事件
  1974. $('#magnet-table').off();
  1975. javbusUs();
  1976. });
  1977. }
  1978.  
  1979.  
  1980.  
  1981. // 挊
  1982. if (GM_getValue('search_index', null) === null) {
  1983. GM_setValue('search_index', 0);
  1984. }
  1985. thirdparty.nong.searchMagnetRun();
  1986.  
  1987. // 瀑布流脚本
  1988. thirdparty.waterfallScrollInit();
  1989. }
  1990. }
  1991.  
  1992. mainRun();
  1993. })();