Sleazy Fork is available in English.

JAV老司机

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

As of 28/12/2018. See the latest version.

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