Sleazy Fork is available in English.

JAV老司机(磁链排序优化版)

因原作者脚本很长一段时间没有更新,目前也暂时尚未与原作者取得联系,故临时将增加了一个按磁链资源大小排序的版本发布上来,有任何疑问欢迎联系

  1. // ==UserScript==
  2. // @name JAV老司机(磁链排序优化版)
  3. // @namespace https://sleazyfork.org/zh-CN/users/1071071
  4. // @version 3.8.4
  5. // @supportURL https://sleazyfork.org/zh-CN/scripts/1071071/feedback
  6. // @source https://github.com/hobbyfang/javOldDriver
  7. // @description 因原作者脚本很长一段时间没有更新,目前也暂时尚未与原作者取得联系,故临时将增加了一个按磁链资源大小排序的版本发布上来,有任何疑问欢迎联系
  8. // @author slslsl
  9.  
  10. // @require https://cdn.bootcdn.net/ajax/libs/jquery/2.2.4/jquery.min.js
  11. // @require https://cdn.bootcdn.net/ajax/libs/lovefield/2.1.12/lovefield.min.js
  12. // @require https://cdn.bootcdn.net/ajax/libs/sweetalert2/9.17.4/sweetalert2.all.min.js
  13.  
  14. // javlib主要有码jav资源、排行榜、点评
  15. // @include *://*javlibrary.com/*
  16. // @include *://*javlib.com/*
  17. // @include *://*.y62x.com/*
  18.  
  19. // javbus有无码jav资源、论坛
  20. // @include *://*javbus.com/*
  21. // @include *://www.*bus*/*
  22. // @include *://www.*javsee*/*
  23. // @include *://www.*seejav*/*
  24.  
  25. // onejav有FC2资源、排行榜
  26. // @include *://*onejav.com/*
  27.  
  28. // avsox有无码jav资源,含FC2 tellme.pw/avsox
  29. // @include *://*avsox.*/*
  30.  
  31. // jav321有素人资源、排行榜
  32. // @include *://*jav321.com/video/*
  33.  
  34. // javdb有各资源排行榜,但部分需付费 javdb.com
  35. // @include *://*javdb*.com/*
  36.  
  37. // @include *://*javstore.*/*
  38. // @include *://*avmoo.*/*
  39. // @include ://tellme.pw/avmoo
  40. // @include *://115.com/*
  41. // @include *://*.quark.cn/list*
  42. // @include *://www.*dmm*/*
  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_deleteValue
  50. // @grant GM_notification
  51. // @grant GM_setClipboard
  52. // @grant GM_getResourceURL
  53. // @grant GM_registerMenuCommand
  54. // @grant GM_info
  55. // @grant GM_openInTab
  56.  
  57. // @connect *
  58. // @copyright hobby 2016-12-18
  59. // @license GPL-3.0
  60. // @compatible chrome V52+ & Tampermonkey
  61.  
  62. // 大陆用户推荐Chrome(V52+) + Tampermonkey(必须扩展) + Clash/V2ray(代理) + Proxy SwitchyOmega(扩展)的环境下配合使用。
  63. // 上车请使用chrome浏览器,其他浏览器的问题本人不支持发现和修复相关问题。
  64.  
  65. // 注意:2.0在每个版本号更新后,javlibrary每个不同域名站点在登录javlibrary的情况下,都会分别首次运行此脚本。
  66. // 根据电脑性能及访问网速情况不同,正常能在1分钟以内(以5000个车牌量为例)缓存个人数据到本地浏览器中.
  67. // 此目的用于过滤个人已阅览过的内容提供快速判断,目前个人图书馆账号的想要、看过、拥有及最新浏览过的番号为已阅数据依据。
  68. // 目前在同步过程中如果浏览器当前页面不在javlibrary站点或者浏览器在后台,同步会被暂停或中止,需注意.
  69. // 如果不登录javlibrary或同版本号已经同步过,就不会运行同步,那么则无此影响.
  70.  
  71. // 油猴脚本技术交流:https://t.me/+TgfN6vLVRew7aMWt
  72.  
  73. // v3.8.4 增加下载列表按磁链大小排序功能。
  74. // v3.8.3 修复javstore22年12月番号视频内容预览大图改版前后的图片获取及显示兼容问题。解决获取dmm评价数据受18岁询问限制。
  75. // v3.8.2 修复javstore番号页图片显示问题,修复javstore备用预览图失效的问题。
  76. // v3.8.1 javlib、javbus、javdb新增了VR菜单入口,javbus新增了FC2菜单跳转,javdb修改了FC2菜单内容(需登录)。修复了已知问题。
  77. // v3.8.0 增加各Jav站点番号浏览记录缓存。增加javbus、javdb列表阅览番号标色。增加夸克在线播放的关联入口,夸克在线播放页排版调整。
  78. // 优化dmm评分数据获取,多数番号突破dmm地区访问限制。代码调整优化。修复了已知问题。
  79.  
  80. // v3.7.1 再优化blogjav预览图获取方式,优化预览图加载时间。修复了已知问题。
  81. // v3.7.0 增加javdb列表的JAV评分排序、屏蔽指定评分人数功能。优化blogjav预览图获取方式。
  82.  
  83. // v3.6.0 原番号页面增加dmm、javdb评分展示及在线播放跳转、JAV跳转,增加javstore番号页改造,增加javdb瀑布流及列表增加JAV跳转和排版优化。
  84. // 原javlib番号页面自带预览图可点击查看,onejav列表简单优化,其他已知bug修复,部分代码优化。
  85.  
  86. // v3.5.2 修复部分地区无法访问脚本依赖库问题,重新梳理匹配脚本域名作用地址。
  87. // v3.5.1 修复javdb站源的磁力搜索,增加jav磁链地址的修改入口。
  88. // v3.5.0 图书馆jav列表“按评分排序”升级为“按【VR】+评分排序”,VR标题增加背景颜色区分。
  89. // v3.4.0 针对JVR影片查找资源的需求,结合javlib站的进阶搜寻中多重搜寻来过滤VR资源,增加了javdb站做为jav磁链接下载来源。
  90. // 修复了预览图失效的问题。
  91. // v3.3.3 预览图备用站更换成javstore。
  92. // v3.3.0 新增图书馆浏览时根据115在线播放来同步图书馆的已拥有功能(建议登录,不然会弹窗提示)。
  93. // v3.2.0 新增javarchive站的预览图做备用,当blogjav预览图无法正常读取时使用。
  94. // 优化图书馆缓存个人数据的同步效率(60秒内可完成)。优化图书馆站点瀑布流列表排版。修复了部分115在线播放查找识别问题。
  95. // v3.1.7 增加脚本设置功能,支持磁链地址失效可自己更换。更新最新磁链地址。
  96. // v3.1.6 更换失效的磁链地址。另btdig,nayy,torrentkitty站点需科学上网,其中btdig还需手工验证非机器访问。
  97. // v3.1.5 增加过滤评分及排序时排除10分的番号,更换失效的磁链地址。
  98. // v3.1.0 优化javbus/avmoo/avsox瀑布流排版。
  99. // v3.0.0 增加115在线播放的关联入口。同时本代码重新梳理及优化。
  100.  
  101. // v2.3.0 增加jav321网站内容排版的支持,增加查找已登录115网盘是否拥有当前番号显示。
  102. // v2.2.0 增加onejav网站内容排版的支持,热门Jav预览搜集更省时省力。更换两个磁链资源新地址。
  103. // v2.1.5 增加点击番号完成复制功能。
  104. // v2.1.3 增加btdigg磁链资源站点。修复了已知问题。
  105. // v2.1.1 增加jav站点瀑布流控制按钮功能。
  106. // v2.1.0 增加javbus站内磁链列表的复制、115离线的快捷键功能。
  107.  
  108. // v2.0.7 增加一种情况Jav列表排序功能支持(仅javlib)。
  109. // v2.0.5 增加Jav列表“按评分排序”、“按时间排序”功能(仅javlib),及更新Jav站点域名。
  110. // v2.0.0 增加自动同步个人数据缓存到本地,jav列表能识别个人已阅览过的内容(需登录javlibray),针对javlibrary的高评价栏目,增加过滤"不看我阅览过"功能。
  111.  
  112. // v1.2.0 针对javlibrary的高评价栏目,增加过滤“只看当前月份”、“只看近两月份”功能。另默认此栏目近两月份的内容增加背景颜色区分。
  113. // v1.2.0 更新了合成“挊”脚本的更多网站的支持,感谢作者thunderhit,同时修复原脚本部分网站功能失效问题。
  114. // v1.1.0 优化更新了JAV列表无限滚动自动加载的代码,增加JAV列表中显示"发行日期"和"评分"的排版,以及修复了已知问题。
  115. // v1.0.3 优化了高清预览大图的获取。
  116. // v1.0.2 优化了javlibrary排版,做了最低分辨率1280x800的排版适配调整,及修复了已知问题。
  117. // v1.0.0 支持javlibrary.com、javbus.com、avmo.pw、avso.pw等老司机站点,第一版发布。
  118.  
  119. // ==/UserScript==
  120. /* jshint -W097 */
  121. (function () {
  122. 'use strict';
  123. const EMPTY_IMAGE_DATA = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAB4CAMAAABsOSjPAAAAn1BMVEUAAAD/lgD/x3f/zoj/nRH/3Kr/+e7/sD//68z/1Zj/qzP/skT/uVX/9eX/pCL/oh3/wGb/8d3/4LL/5Lv/2aL/tUv/kAD/0o//9uj/v2L/mQn//vv//Pf/rjf/+vL/1pn/2pT/mAX/kwD/+/X/9OH/4rb/qzD/qSX/mAH/6sn/6cL/26f/y4D/nxr/vV7/uU//wnH/7tb/1YX/wEL/nypWdfcGAAAAAXRSTlMAQObYZgAABOdJREFUeNrs2F1TgkAYhmGeRMRWLbDlS5BAUPysqf7/b6sYt600dQ8a3nW4T3Teo2uWHRYw2tquMOiU5mhDl64ADR36jdZhsVv0X7XoFn2iFt2iT9Si/wG93AxY73Q8fLAooW2GizI7MRm0j4tLCiJoBTPyN4sE2s6h0o4EmkMprySAXmaK6CcC6A0UG1nNowdQLFo2j2aQmTxMKpyrbB7dk5rd54VfLXAmlxI6NOqKrUZocygOG43QXEycSB90KCZTUx90Mvk6bvRBV+P95F6jPY1RUQ9SrW55uPOdqR3id3kUEUYDkZkdmu8da731KrLoI3mPxkfDV486Ovthrps800aPUrs7l2ZR6uV00XPrc2GZMMtWC7Lo26Aez7gwyyxGFJ0MxWHOhVlmlW7pugE1dL03hPpl/y/wA2KfxX6gk++62cSoixkShxba9fuywjgsfgKwHZNCHyuYfVtvjjqfOHqdSWHMsG8XU0Z3I6Av98ZXi5vOR5uNQxDtVoBQzzhk+f63Sw+9juQenjKiz9Pj/oNsnQ4qYeNpZ0H1JYBBsWzVPPoZim2L5tElFOsRuOXFc6iVEkAbXSiVTCigjRAKmTaNE/G9nfNtbRsGwnjudBKW5Gk2ZtCtsJcb7N2+/5ebHv1JXROEkkFxih6IkSr57ufrnaQ2Ia93UP/4c5pt3Ar16dvfE509XpT/Hb62FX593852YHp9+dLWz3MfTfc686cQbmpAD+iGBvSAbmhAD+iGBvSAbmhAD+iGBvSAbuhjoDdKErYPmDSBttISWRvzhJI899m1tDShFRW5B6AnomBqSzXn3fWWANPchDbMMxF74segq3khf/h3X3g3b+Ek02V3aUFX+2QuD2l9e6vFH35VimjaQaPTr7mVHtW+XB6TAXRO5uVgRP8fNPdCM81WyCsp0dOeiBaDGY4o28GgqB00C7l8s5RhHx8iUFK4BW0dkdMpoyY493E4TJ5ydFUgCoFUL/RMQkViriXKGKgIS26pN2ht4a1Az7WkpZg5FuIGs8XBlrocp2uC59LNsv3QlO/2uH9DgwEINws7kmSdWWqZAE7jQRSMlGGPJULzgnv0EVqn1W9B6WP2CqcuuaJkZioOSN8BHVZHHoZtZIELXEL8cQ7JQrIiVXgPfXGYBCOeJKWGOmYEoANHpUBbuPKANrUFCy6aVWkJNdIPzYBzIArx4hBPQJucDj72HYVdduThtMXQpsjF4SVX0RFaJ9LqJLl0FTqatQgDPNdlowNaXyPtk5EKyPl2kzyuggdBytj96pGjKiTLFdqRugFt3kFzju+a/Sm0MnTOvP5IAzVlAeotxF6YLlYigaDAHfh8gpw8rhU6Q0U5pIdGKekMvd2ABqCCWcYMC9S5ACAxVS38diEaR1kqBwoGcImvrAAbUC7J2ny/eVtAgw1yZUjfgjZCZXE3lOUL9BxdrVIdNKEnKuIYX1egLZy4sphMBq0ggAB13bprOCu1zwsWCqORHmiXM8hSn9HCZ/aspdC000Nx1npZGVXFKl0AwmwvVuU5a4lcXgOqlLqy8ARUZnUcgnjXMdcjiI4ty7q4W9kWHjXx2oDul+rdiU/yR4C28SV9B5SzQJtr0nfoLNDlIOFNz9zTQKfi031TzwN9hwb0gG5oQA/oDxR9iq80ehI9PfQT6amhh4Y+k/4BYXA+w/0JM4sAAAAASUVORK5CYII=';
  124. const JAVDB_ITEM_SELECTOR = '.movie-list.v.cols-4.vcols-8 .item, .movie-list.v.cols-4.vcols-5 .item, .movie-list.h.cols-4.vcols-8 .item, .movie-list.h.cols-4.vcols-5 .item';
  125. const BTSOW_DOMAIN = 'btsow.beauty';
  126. const JAVDB_DOMAIN = 'javdb007.com';
  127. const TORRENTKITTY_DOMAIN = 'www.torrentkitty.live';
  128. // 115用户ID
  129. let jav_userID = GM_getValue('jav_user_id', 0);
  130. // icon图标
  131. let icon = GM_getResourceURL('icon');
  132. // 瀑布流状态:1:开启、0:关闭
  133. let waterfallScrollStatus = GM_getValue('scroll_status', 1);
  134. // 当前网页域名
  135. let domain = location.host;
  136. // 数据库
  137. let javDb;
  138. // 表
  139. let myMovie;
  140.  
  141. /**
  142. * 对Date的扩展,将 Date 转化为指定格式的String
  143. * 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,/';
  144. * 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
  145. * 例子:(new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423f
  146. * (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
  147. * @param {string} fmt 日期格式
  148. * @returns {void | string} 格式化后的日期字符串
  149. */
  150. Date.prototype.Format = function (fmt) { //author: meizz
  151. var o = {
  152. "M+": this.getMonth() + 1, //月份
  153. "d+": this.getDate(), //日
  154. "h+": this.getHours(), //小时
  155. "m+": this.getMinutes(), //分
  156. "s+": this.getSeconds(), //秒
  157. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  158. "S": this.getMilliseconds() //毫秒
  159. };
  160. if (/(y+)/.test(fmt))
  161. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  162. for (var k in o)
  163. if (new RegExp("(" + k + ")").test(fmt))
  164. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  165. return fmt;
  166. };
  167.  
  168. /**
  169. * 多线程异步队列 依赖 jQuery 1.8+
  170. * @param {Number} n 正整数, 线程数量
  171. */
  172. function Queue(n) {
  173. n = parseInt(n, 10);
  174. return new Queue.prototype.init((n && n > 0) ? n : 1)
  175. }
  176.  
  177. Queue.prototype = {
  178. init: function (n) {
  179. this.threads = [];
  180. this.taskList = [];
  181. while (n--) {
  182. this.threads.push(new this.Thread)
  183. }
  184. },
  185. /**
  186. * @param {Function} callback promise对象done时的回调函数,它的返回值必须是一个promise对象
  187. */
  188. push: function (callback) {
  189. if (typeof callback !== 'function') return;
  190. var index = this.indexOfIdle();
  191. if (index != -1) {
  192. this.threads[index].idle(callback);
  193. //try { console.log('Thread-' + (index+1) + ' accept the task!') } catch (e) {}
  194. } else {
  195. this.taskList.push(callback);
  196. for (var i = 0, l = this.threads.length; i < l; i++) {
  197. ((thread, self, id) => {
  198. thread.idle(() => {
  199. if (self.taskList.length > 0) {
  200. //try { console.log('Thread-' + (id+1) + ' accept the task!') } catch (e) {}
  201. let promise = self.taskList.shift()(); // 正确的返回值应该是一个promise对象
  202. return promise.promise ? promise : $.Deferred().resolve().promise();
  203. } else {
  204. return $.Deferred().resolve().promise();
  205. }
  206. })
  207. })(this.threads[i], this, i);
  208.  
  209. }
  210. }
  211. },
  212. indexOfIdle: function () {
  213. var threads = this.threads,
  214. thread = null,
  215. index = -1;
  216. for (var i = 0, l = threads.length; i < l; i++) {
  217. thread = threads[i];
  218. if (thread.promise.state() === 'resolved') {
  219. index = i;
  220. break;
  221. }
  222. }
  223. return index;
  224. },
  225. Thread: function () {
  226. this.promise = $.Deferred().resolve().promise();
  227. this.idle = (callback) => {
  228. this.promise = this.promise.then(callback)
  229. }
  230. }
  231. };
  232. Queue.prototype.init.prototype = Queue.prototype;
  233.  
  234. /**
  235. * 公用类
  236. */
  237. class Common {
  238. static init() {
  239. // 是否新版本
  240. let isNewVersion = Common.compareVersions(GM_info.script.version, GM_getValue("javOldDriver_version", "0.0.1"));
  241.  
  242. // 磁链访问地址初始化
  243. if (isNewVersion || GM_getValue('btsow_url', undefined) === undefined) {
  244. GM_setValue('btsow_url', BTSOW_DOMAIN);
  245. }
  246. if (isNewVersion || GM_getValue('btdig_url', undefined) === undefined) {
  247. GM_setValue('btdig_url', 'www.btdig.com');
  248. }
  249. if (isNewVersion || GM_getValue('nyaa_url', undefined) === undefined) {
  250. GM_setValue('nyaa_url', 'sukebei.nyaa.si');
  251. }
  252. if (isNewVersion || GM_getValue('torrentkitty_url', undefined) === undefined) {
  253. GM_setValue('torrentkitty_url', TORRENTKITTY_DOMAIN);
  254. }
  255. if (isNewVersion || GM_getValue('javdb_url', undefined) === undefined) {
  256. GM_setValue('javdb_url', JAVDB_DOMAIN);
  257. }
  258. if (isNewVersion || GM_getValue('javlib_url', undefined) === undefined) {
  259. GM_setValue('javlib_url', 'www.javlibrary.com');
  260. }
  261. if (isNewVersion || GM_getValue('javbus_url', undefined) === undefined) {
  262. GM_setValue('javbus_url', 'www.javbus.com');
  263. }
  264. if (isNewVersion || GM_getValue('avsox_url', undefined) === undefined) {
  265. GM_setValue('avsox_url', 'avsox.click');
  266. }
  267. GM_setValue("javOldDriver_version", GM_info.script.version);
  268.  
  269. GM_registerMenuCommand('设置', () => { Common.openSystemConfig() });
  270. }
  271.  
  272. static openSystemConfig() {
  273. let scroll_true = '';
  274. if (GM_getValue('scroll_status', 1) !== 0) {
  275. GM_setValue('scroll_status', 1);
  276. scroll_true = "checked";
  277. }
  278.  
  279. let dom = `<div>
  280. <label class="tm-setting">jav各站开启瀑布流(自动加载下一页)<input type="checkbox" id="scroll_true" ${scroll_true} class="tm-checkbox"></label>
  281. <label class="tm-setting">javdb网址<input type="text" id="javdb_url" class="tm-text" value="${GM_getValue('javdb_url')}"></label>
  282. <label class="tm-setting">btsow网址<input type="text" id="btsow_url" class="tm-text" value="${GM_getValue('btsow_url')}"></label>
  283. <label class="tm-setting">btdig网址<input type="text" id="btdig_url" class="tm-text" value="${GM_getValue('btdig_url')}"></label>
  284. <label class="tm-setting">nyaa网址<input type="text" id="nyaa_url" class="tm-text" value="${GM_getValue('nyaa_url')}"></label>
  285. <label class="tm-setting">torrentkitty网址<input type="text" id="torrentkitty_url" class="tm-text" value="${GM_getValue('torrentkitty_url')}"></label>
  286. <label class="tm-setting">javlib网址<input type="text" id="javlib_url" class="tm-text" value="${GM_getValue('javlib_url')}"></label>
  287. <label class="tm-setting">javbus网址<input type="text" id="javbus_url" class="tm-text" value="${GM_getValue('javbus_url')}"></label>
  288. <label class="tm-setting">avsox网址<input type="text" id="avsox_url" class="tm-text" value="${GM_getValue('avsox_url')}"></label>
  289. </div>`;
  290. let $dom = $(dom);
  291. Swal.fire({
  292. title: '脚本设置',
  293. html: $dom[0],
  294. confirmButtonText: '保存'
  295. }).then((result) => {
  296. if (result.value) {
  297. if ($('#scroll_true')[0].checked) {
  298. GM_setValue('scroll_status', 1);
  299. } else {
  300. GM_setValue('scroll_status', 0);
  301. }
  302. GM_setValue('btsow_url', $('#btsow_url').val());
  303. GM_setValue('btdig_url', $('#btdig_url').val());
  304. GM_setValue('nyaa_url', $('#nyaa_url').val());
  305. GM_setValue('torrentkitty_url', $('#torrentkitty_url').val());
  306. GM_setValue('javdb_url', $('#javdb_url').val());
  307. GM_setValue('javlib_url', $('#javlib_url').val());
  308. GM_setValue('javbus_url', $('#javbus_url').val());
  309. GM_setValue('avsox_url', $('#avsox_url').val());
  310. history.go(0);
  311. }
  312. })
  313. }
  314. /**
  315. * 版本号比较方法
  316. * 传入两个字符串,当前版本号:curV;比较版本号:reqV
  317. * @param {string} curV 当前版本号
  318. * @param {string} reqV 比较版本号
  319. * @returns {boolean} 调用方法举例:compare("3.1.10","3.1.9"),将返回true
  320. */
  321. static compareVersions(curV, reqV) {
  322. if (curV && reqV) {
  323. //将两个版本号拆成数字
  324. var arr1 = curV.split('.'),
  325. arr2 = reqV.split('.');
  326. var minLength = Math.min(arr1.length, arr2.length),
  327. position = 0,
  328. diff = 0;
  329. //依次比较版本号每一位大小,当对比得出结果后跳出循环(后文有简单介绍)
  330. while (position < minLength && ((diff = parseInt(arr1[position]) - parseInt(arr2[position])) == 0)) {
  331. position++;
  332. }
  333. diff = (diff != 0) ? diff : (arr1.length - arr2.length);
  334. //若curV大于reqV,则返回true
  335. return diff > 0;
  336. } else {
  337. //输入为空
  338. console.log("版本号不能为空");
  339. return false;
  340. }
  341. }
  342. /**
  343. * 设置cookie
  344. * @param {string} cname 名字
  345. * @param {string} cvalue 值
  346. */
  347. static setCookie(cname, cvalue) {
  348. let d = new Date();
  349. d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
  350. let expires = "expires=" + d.toUTCString();
  351. document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
  352. }
  353. /**
  354. * html文本转换为Document对象 https://jsperf.com/domparser-vs-createelement-innerhtml/3
  355. * @param {string} text
  356. * @returns {Document}
  357. */
  358. static parsetext(text) {
  359. try {
  360. let doc = document.implementation.createHTMLDocument('');
  361. doc.documentElement.innerHTML = text;
  362. return doc;
  363. } catch (e) {
  364. alert('parse error');
  365. }
  366. }
  367.  
  368. /**
  369. * 判断日期是否最近X个月份的日期
  370. * @param {String} DateStr 日期
  371. * @param {Number} MonthNum 月数(X)
  372. * @returns {boolean}
  373. */
  374. static isLastXMonth(DateStr, MonthNum) {
  375. let now = new Date(); //当前日期
  376. let compDate = new Date(DateStr);
  377. let m2 = now.getFullYear() * 12 + now.getMonth();
  378. let m1 = compDate.getFullYear() * 12 + compDate.getMonth();
  379. if ((m2 - m1) < MonthNum) {
  380. return true;
  381. }
  382. return false;
  383. }
  384.  
  385. /**
  386. * 方法: 通用chrome通知
  387. * @param {string} title
  388. * @param {string} body
  389. * @param {string} icon
  390. * @param {string} click_url
  391. */
  392. static notifiy(title, body, icon, click_url) {
  393. var notificationDetails = {
  394. text: body,
  395. title: title,
  396. timeout: 3000,
  397. image: icon,
  398. onclick: () => {
  399. window.open(click_url);
  400. }
  401. };
  402. GM_notification(notificationDetails);
  403. }
  404.  
  405. /**
  406. * 发起网络请求
  407. * @param {string} url 对象参数
  408. * @param {string} referrer
  409. * @param {number} timeoutInt 超时毫秒数
  410. * @returns {Promise}
  411. */
  412. static request(url, referrerStr, timeoutInt) {
  413. return new Promise((resolve, reject) => {
  414. console.log(`发起网址请求:${url}`);
  415. GM_xmlhttpRequest({
  416. url,
  417. method: 'GET',
  418. headers: {
  419. "Cache-Control": "no-cache",
  420. referrer: referrerStr
  421. },
  422. timeout: timeoutInt > 0 ? timeoutInt : 20000,
  423. onload: response => { //console.log(url + " reqTime:" + (new Date() - time1));
  424. response.loadstuts = true;
  425. resolve(response);
  426. },
  427. onabort: response => {
  428. console.log(url + " abort");
  429. response.loadstuts = false;
  430. resolve(response);
  431. },
  432. onerror: response => {
  433. console.log(url + " error");
  434. console.log(response);
  435. response.loadstuts = false;
  436. resolve(response);
  437. },
  438. ontimeout: response => {
  439. console.log(`${url} ${timeoutInt > 0 ? timeoutInt : 20000}ms timeout`);
  440. response.loadstuts = false;
  441. response.finalUrl = url;
  442. resolve(response);
  443. },
  444. });
  445. });
  446. }
  447.  
  448. /**
  449. * 发起网络请求
  450. * @param {*} details 对象参数
  451. * @returns {Promise}
  452. */
  453. static requestGM_XHR(details) {
  454. return new Promise((resolve, reject) => {
  455. console.log(`发起网址请求:${details.url}`);
  456. let req = GM_xmlhttpRequest({
  457. method: details.method ? details.method : "GET",
  458. url: details.url,
  459. headers: details.headers,
  460. timeout: details.timeout > 0 ? details.timeout : 20000,
  461. onprogress: rsp => {
  462. if (details.onprogress && details.onprogress(rsp)) {
  463. resolve(rsp);
  464. req.abort();
  465. }
  466. },
  467. onload: rsp => resolve(rsp),
  468. onerror: rsp => {
  469. console.log(`${details.url} : error`);
  470. reject(`error`);
  471. },
  472. ontimeout: rsp => {
  473. console.log(`${details.url} ${details.timeout > 0 ? details.timeout : 20000}ms timeout`);
  474. reject(`timeout`);
  475. }
  476. });
  477. });
  478. }
  479.  
  480. /**
  481. * 获取带-的番号
  482. * @param {String} avid 番号如:ABP888
  483. * @returns {String} 带-的番号
  484. */
  485. static getAvCode(avid) {
  486. // 带-的番号不处理,除了-0 如:DSVR-01167
  487. if (avid.match(/-[^0]/g)) return avid;
  488. // 999999_001,999999-001 不处理
  489. if (avid.match(/^[0-9-_]+$/g)) return avid;
  490. // crazyasia99999,sm999,video_999,BrazzersExxtra.99.99.99 不处理
  491. if (avid.match(/^(crazyasia|sm|video_|BrazzersExxtra)+/gi)) return avid;
  492. let letter = avid.match(/[a-z|A-Z]+/gi);
  493. let num = avid.match(/\d+$/gi)[0];
  494. if (num.length > 3) {
  495. num = num.replace(/\b(0+)/gi, ""); //去除开头的0
  496. if (num.length < 3) {
  497. num = (Array(3).join(0) + num).slice(-3);
  498. }
  499. }
  500. return letter.toString().replace(/,/g, "-") + "-" + num;
  501. }
  502. /**
  503. * 通过图片或视频url解析出DmmId
  504. * @param {String} url 带DmmId的图片或视频url
  505. * @returns {String} DmmId的番号
  506. */
  507. static getDmmId(url) {
  508. //let url = "https://pics.dmm.co.jp/digital/video/1mtall028/1mtall028-2.jpg";
  509. let array = url.split("/");
  510. let dmmId = array[array.length - 2];
  511. //结尾数字串
  512. let num = dmmId.match(/\d+$/gi);
  513. //前缀
  514. let prefix = dmmId.replace(num, "");
  515.  
  516. if (num) {
  517. //非00开头的数字同时字符数小于5的,添加00开头
  518. if (!num[0].match(/^00/) && num[0].length < 5) {
  519. num = '00' + num;
  520. }
  521. return prefix + num;
  522. } else {
  523. return null;
  524. }
  525. }
  526. /**
  527. * 根据avid转成dmmId即cid
  528. * @param {string} avid 番号
  529. * @returns {string} dmmId dmm的cid番号
  530. */
  531. static avIdToDmmId(avid) {
  532. // todo:待优化
  533. return avid;
  534. }
  535. /**
  536. * 获取查询onejav的url
  537. * @param {string} avid 番号
  538. * @returns {string} 返回符合onejav查询番号参数的url
  539. */
  540. static getOneJavSearchUrl(avid) {
  541. //FC2-PPV-9999999 => 9999999 , ABP-999 => ABP999
  542. avid = avid.replace(/-|FC2|PPV/g, "");
  543. return "https://onejav.com/search/" + avid;
  544. }
  545. /**
  546. * 获取查询blogjav的番号处理过后的查询字符
  547. * @param {string} avid 番号
  548. * @returns {string} 返回番号处理过后的查询字符
  549. */
  550. static getBlogJavSearchVal(avid) {
  551. //FC2-PPV-9999999 => FC2+PPV+9999999 , HEYZO-9999 => HEYZO+9999
  552. let cd = avid.replace(/-/g, "+");
  553. // 不含空格的情况,同时只含有字母与数字
  554. if (!(/\s+/g).test(cd) && (/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]+$/g).test(cd)) {
  555. // ABP999 => ABP+999
  556. // 取结尾数字
  557. let num = cd.match(/\d+$/gi);
  558. //前缀
  559. let prefix = cd.replace(num, "");
  560. cd = prefix + "+" + num;
  561. }
  562. return cd;
  563. }
  564. /**
  565. * 获取查询jav321的url
  566. * @param {string} avid 番号
  567. * @returns {Promise} 返回符合Jav321查询番号参数的url
  568. */
  569. static getJav321SearchUrl(avid) {
  570. // 测试 todo
  571. return new Promise((resolve, reject) => {
  572. GM_xmlhttpRequest({
  573. method: "POST",
  574. url: 'https://www.jav321.com/search',
  575. headers: {
  576. 'Content-Type': 'application/x-www-form-urlencoded'
  577. },
  578. data: "sn=" + avid,
  579. timeout: 20000,
  580. onload: (r) => resolve(r.finalUrl),
  581. onerror: (r) => reject(`查找jav321 ${avid} 出错了`),
  582. ontimeout: (r) => reject(`查找jav321 ${avid} 超时了`)
  583. });
  584. });
  585. }
  586. /**
  587. * 获取查询javstore的url
  588. * @param {string} avid 番号
  589. * @returns {Promise} 返回符合JavStore查询番号参数的url
  590. */
  591. static getJavStoreSearchUrl(avid) {
  592. let promise1 = Common.request(`https://javstore.net/search/${avid}.html`);
  593. return promise1.then((result) => {
  594. if (!result.loadstuts) return;
  595. let doc = Common.parsetext(result.responseText);
  596. // 查找包含avid番号的a标签数组
  597. let a_array = $(doc).find(`.news_1n li h3 span a`);
  598. let a = a_array[0];
  599. //如果找到全高清大图优先获取全高清的
  600. for (let i = 0; i < a_array.length; i++) {
  601. // 筛选匹配的番号数据 FC2-PPV-9999999 => 正则/FC2.*PPV.*9999999/gi
  602. let reg = RegExp(avid.replace(/-/g, ".*"), "gi");
  603. if (a_array[i].title.search(reg) > 0) {
  604. if (!a) a = a_array[i];
  605. let fhd_idx = a_array[i].title.search(/Uncensored|FHD/i);
  606. if (fhd_idx >= 0) {
  607. a = a_array[i];
  608. break;
  609. }
  610. }
  611. }
  612.  
  613. return a ? `https://javstore.net${a.pathname}` : null;
  614. });
  615. }
  616. /**
  617. * jav321链接加入鼠标点击打开页面事件
  618. * @param {jQuery} $ele 链接元素
  619. * @param {String} avid 番号
  620. * @returns {jQuery} 链接元素
  621. */
  622. static jav321LinkMousedown($ele, avid) {
  623. $ele.mousedown((e) => {
  624. //鼠标左键 0 鼠标中键滚轮 1
  625. if (e.button < 2) {
  626. Common.getJav321SearchUrl(avid).then((url) => {
  627. if (url && !(/https:\/\/www.jav321.com\/search/).test(url)) {
  628. GM_openInTab(url, { active: !e.button, insert: true, setParent: true });
  629. } else {
  630. Common.notifiy(`Jav321查无此番号: ${avid}`, '换个JAV站点查找试试吧!', icon, "");
  631. }
  632. }).catch((errMsg) => Common.notifiy(errMsg));
  633. }
  634. });
  635. return $ele;
  636. }
  637. /**
  638. * javstor链接加入鼠标点击打开页面事件
  639. * @param {jQuery} $ele 链接元素
  640. * @param {String} avid 番号
  641. * @returns {jQuery} 链接元素
  642. */
  643. static javstoreLinkMousedown($ele, avid) {
  644. $ele.mousedown((e) => {
  645. //鼠标左键 0 鼠标中键滚轮 1
  646. if (e.button < 2) {
  647. //FC2-PPV-9999999 => FC2+PPV+9999999 , HEYZO-9999 => HEYZO+9999
  648. avid = avid.replace(/-/g, "+");
  649. Common.getJavStoreSearchUrl(avid).then((url) => {
  650. if (url) {
  651. GM_setValue(url, avid);
  652. GM_openInTab(url, { active: !e.button, insert: true, setParent: true });
  653. } else {
  654. Common.notifiy(`JavStore查无此番号: ${avid}`, '换个JAV站点查找试试吧!', icon, "");
  655. }
  656. });
  657. }
  658. });
  659. return $ele;
  660. }
  661. /**
  662. * 加入AV预览内容图使用的CSS
  663. */
  664. static addAvImgCSS() {
  665. GM_addStyle(`
  666. .min {max-height: 535px;height:auto;cursor: pointer;} /*Common.addAvImg使用*/
  667. .max {min-width: 1520px;} /*Common.addAvImg使用*/
  668. `);
  669. }
  670. /**
  671. * 加入AV预览内容图
  672. * @param {string} avid av唯一码
  673. * @param {function} func 函数
  674. * @param {boolean} isZoom 是否放大,默认true
  675. */
  676. static addAvImg(avid, func, isZoom) {
  677. let p = Common.getBigPreviewImgUrlFromBlogjav(avid);
  678. let p2 = Common.getBigPreviewImgUrlFromJavStore(avid);
  679. p.then(imgUrl => {
  680. if (imgUrl === null) {
  681. addJavArchiveImg.call(this);
  682. return;
  683. }
  684.  
  685. Common.requestGM_XHR({
  686. method: 'HEAD',
  687. url: imgUrl,
  688. headers: { 'referrer': imgUrl.replace(/^(https?:\/\/[^\/#&]+).*$/, '$1') },
  689. timeout: 5000
  690. }).then(result => {
  691. if (result.status == 200 && (imgUrl.replace(/^https?:\/\//, '') == result.finalUrl.replace(/^https?:\/\//, '') || result.finalUrl.search(/removed.png/i) < 0)) {
  692. GM_deleteValue(`temp_img_url_${avid}`);
  693. addImg(imgUrl, func, isZoom);
  694. Promise.resolve();
  695. } else {
  696. return Promise.reject("error");
  697. }
  698. }).catch(msg => {
  699. console.log("blogjav获取的图片地址已经被移除或加载失败" + msg);
  700. addJavArchiveImg.call(this);
  701. });
  702.  
  703. function addJavArchiveImg() {
  704. p2.then(url => {
  705. imgUrl = GM_getValue(`temp_img_url_${avid}`, "");
  706. if (imgUrl === "") {
  707. console.log(`${avid} 没有找到预览图`);
  708. addImg(EMPTY_IMAGE_DATA, func, false);
  709. } else {
  710. GM_deleteValue(`temp_img_url_${avid}`);
  711. addImg(imgUrl, func, isZoom);
  712. }
  713. });
  714. }
  715.  
  716. function addImg(targetImgUrl, func, isZoom) {
  717. console.log("显示的图片地址:" + targetImgUrl);
  718. //创建img元素,加载目标图片地址
  719. //创建新img元素
  720. let className = "max";
  721. if (isZoom != undefined && !isZoom) {
  722. className = "min";
  723. }
  724. let $img = $(`<img id="javRealImg" title="点击可放大缩小 (图片正常时)" class="${className}"></img>`);
  725. $img.attr("src", targetImgUrl);
  726. $img.attr("style", "float: left;cursor: pointer;");
  727. $img.click(function () {
  728. if ($(this).hasClass('max')) {
  729. $(this).attr("class", 'min');
  730. this.parentElement.parentElement.scrollIntoView();
  731. }
  732. else {
  733. $(this).attr("class", 'max');
  734. }
  735. });
  736. //将新img元素插入指定位置
  737. func($img);
  738. }
  739. });
  740. }
  741. /**
  742. * 根据番号从blogjav获取大预览图Url
  743. * @param {string} avid av唯一码
  744. * @returns {Promise} 大预览图Url地址
  745. */
  746. static getBigPreviewImgUrlFromBlogjav(avid) {
  747. // oneJav 取消获取blogjav预览图
  748. if ((/(OneJAV)/g).test(document.title)) {
  749. return Promise.resolve(null);
  750. }
  751. //请求搜索blogjav.net的番号
  752. return Common.request(`https://www.bing.com/search?q=${Common.getBlogJavSearchVal(avid)}+site:blogjav.net&mkt=ja-JP`, "", 15000).then((result) => {
  753. if (!result.loadstuts) {
  754. console.log("从bing查找blogjav番号出错");
  755. return null;
  756. }
  757. var doc = Common.parsetext(result.responseText);
  758. let a_array = $(doc).find("#b_results .b_algo h2 a");
  759. let a = null;
  760. console.log("avid:" + avid);
  761. //如果找到全高清大图优先获取全高清的
  762. for (let i = 0; i < a_array.length; i++) {
  763. if (i == 5) break;
  764. // 筛选匹配的番号数据 mium-999 => 正则/mium.*999/gi
  765. let reg = RegExp(avid.replace(/-/g, ".*"), "gi");
  766. if (a_array[i].innerHTML.search(reg) > 0) {
  767. if (!a) a = a_array[i];
  768. var fhd_idx = a_array[i].innerHTML.search(/FHD/i);
  769. if (fhd_idx > 0) {
  770. a = a_array[i];
  771. break;
  772. }
  773. }
  774. };
  775. return Promise.resolve(a);
  776. }).then(a => {
  777. if (a) {
  778. return Promise.resolve(a);
  779. } else {
  780. return Common.request(`https://blogjav.net/?s=${Common.getBlogJavSearchVal(avid)}`, "", 15000).then((result) => {
  781. if (!result.loadstuts) {
  782. console.log("从blogjav查找番号出错");
  783. return null;
  784. }
  785. var doc = Common.parsetext(result.responseText);
  786. let a_array = $(doc).find(".entry-title a");
  787. let a = null;
  788. console.log("avid:" + avid);
  789. //如果找到全高清大图优先获取全高清的
  790. for (let i = 0; i < a_array.length; i++) {
  791. if (i == 5) break;
  792. // 筛选匹配的番号数据 mium-999 => 正则/mium.*999/gi
  793. let reg = RegExp(avid.replace(/-/g, ".*"), "gi");
  794. if (a_array[i].innerHTML.search(reg) > 0) {
  795. if (!a) a = a_array[i];
  796. var fhd_idx = a_array[i].innerHTML.search(/FHD/i);
  797. if (fhd_idx > 0) {
  798. a = a_array[i];
  799. break;
  800. }
  801. }
  802. };
  803. return Promise.resolve(a);
  804. });
  805. }
  806. }).then(a => {
  807. let targetImgUrl = "";
  808. if (a) {
  809. //请求调用内页详情的访问地址
  810. return Common.request(a.href, "https://pixhost.to/", 15000).then((result) => {
  811. if (!result.loadstuts) return null;
  812. let doc = Common.parsetext(result.responseText);
  813. let img_array = $(doc).find('.entry-content a img[data-lazy-src*="imagetwist."],.entry-content a img[data-lazy-src*="pixhost."]');
  814.  
  815. //如果找到内容大图
  816. if (img_array.length > 0) {
  817. var new_img_src = $(img_array[img_array.length - 1]).data('lazySrc');
  818. targetImgUrl = new_img_src.replace('thumbs', 'images').replace('//t', '//img').replace(/[\?*\"*]/, '').replace('/th/', '/i/');
  819. if (/imagetwist/gi.test(targetImgUrl)) targetImgUrl = targetImgUrl.replace('.jpg', '.jpeg');
  820. console.log("blogjav获取的图片地址:" + targetImgUrl);
  821. if (targetImgUrl.length === 0) {
  822. return null;
  823. } else {
  824. return targetImgUrl;
  825. }
  826. } else {
  827. return null;
  828. }
  829. });
  830. } else {
  831. return Promise.resolve(null);
  832. }
  833. });
  834. }
  835. /**
  836. * 根据番号从JavStore获取大预览图Url,并且缓存到GM中
  837. * @param {string} avid av唯一码
  838. */
  839. static getBigPreviewImgUrlFromJavStore(avid) {
  840. //异步请求搜索JavStore的番号
  841. GM_setValue(`temp_img_url_${avid}`, "");
  842. let promise1 = Common.request(`https://javstore.net/search/${avid}.html`);
  843. return promise1.then((result) => {
  844. if (!result.loadstuts) return;
  845. let doc = Common.parsetext(result.responseText);
  846. // 查找包含avid番号的a标签数组,忽略大小写
  847. let a_array = $(doc).find(`.news_1n li h3 span a`);
  848. let a = a_array[0];
  849. //如果找到全高清大图优先获取全高清的
  850. for (let i = 0; i < a_array.length; i++) {
  851. // 筛选匹配的番号数据 FC2-PPV-9999999 => 正则/FC2.*PPV.*9999999/gi
  852. let reg = RegExp(avid.replace(/-/g, ".*"), "gi");
  853. if (a_array[i].title.search(reg) > 0) {
  854. if (!a) a = a_array[i];
  855. let fhd_idx = a_array[i].title.search(/Uncensored|FHD/i);
  856. if (fhd_idx >= 0) {
  857. a = a_array[i];
  858. break;
  859. }
  860. }
  861. }
  862. if (a) {
  863. //异步请求调用内页详情的访问地址
  864. let promise2 = Common.request(`https://javstore.net${a.pathname}`, "http://pixhost.to/");
  865. return promise2.then((result) => {
  866. if (!result.loadstuts) return;
  867. let doc = Common.parsetext(result.responseText);
  868. let img_array = $(doc).find('.news a font[size*="+1"],.news a img[alt*=".th"]');
  869. if (img_array.length > 0) {
  870. let imgUrl = img_array[img_array.length - 1].parentElement.href;
  871. if(img_array[0].tagName === 'IMG'){
  872. imgUrl = img_array[img_array.length - 1].src;
  873. imgUrl = imgUrl ? imgUrl : img_array[0].dataset.src;
  874. imgUrl = imgUrl.replace('pixhost.org', 'pixhost.to').replace('.th', '')
  875. .replace('thumbs', 'images').replace('//t', '//img').replace(/[\?*\"*]/, '');
  876. }
  877.  
  878. return Common.requestGM_XHR({
  879. method: 'HEAD',
  880. url: imgUrl,
  881. headers: { 'referrer': imgUrl.replace(/^(https?:\/\/[^\/#&]+).*$/, '$1') },
  882. timeout: 5000
  883. }).then(result => {
  884. if (result.status == 200 && (imgUrl.replace(/^https?:\/\//, '') == result.finalUrl.replace(/^https?:\/\//, '') || result.finalUrl.search(/removed.png/i) < 0)) {
  885. console.log("javstore获取的图片地址:" + imgUrl);
  886. GM_setValue(`temp_img_url_${avid}`, imgUrl);
  887. return Promise.resolve(imgUrl);
  888. } else {
  889. console.log("javstore获取的图片地址已经被移除或加载失败");
  890. return Promise.resolve();
  891. }
  892. });
  893. }
  894. });
  895. }
  896. });
  897. }
  898. /**
  899. * 获取Dmm对应番号的数据
  900. * @param {string} dmmIdUrl DmmId网址
  901. * @returns {Promise} Promise内实现异步返回参数dmmData
  902. */
  903. static getDmmData(dmmIdUrl) {
  904. if (!dmmIdUrl) return Promise.resolve(null);
  905. //异步请求dmm的番号页面
  906. return Common.requestGM_XHR({
  907. url: dmmIdUrl,
  908. timeout: 15000,
  909. headers: {
  910. "Accept-Language": "ja-JP", //突破dmm地区访问限制,部分作品限制日本ip访问,例如STARS-706
  911. "cookie": "age_check_done=1;" //跳过18岁以上限制
  912. },
  913. }).then((result) => {
  914. var doc = Common.parsetext(result.responseText);
  915. let dmmData = {};
  916. dmmData.collect_num = $(doc).find(".tx-count span").text();
  917. dmmData.score = $(doc).find(".d-review__average strong").text();
  918. dmmData.user_num = $(doc).find(".d-review__evaluates strong").text();
  919. dmmData.url = dmmIdUrl;
  920. dmmData.finalUrl = result.finalUrl;
  921. return dmmData;
  922. }).catch(msg => {
  923. return {};
  924. });
  925. }
  926. /**
  927. * 获取JavDb对应番号的数据
  928. * @param {string} avid av编号
  929. * @returns {Promise} Promise内实现异步返回参数javdbData
  930. */
  931. static getJavDbData(avid) {
  932. return new Promise((resolve, reject) => {
  933. let promise = Common.request("https://" + GM_getValue('javdb_url') + "/search?f=all&q=" + avid);
  934. promise.then((result) => {
  935. if (!result.loadstuts) {
  936. console.log("javdb获取番号数据出错");
  937. }
  938. let doc = Common.parsetext(result.responseText);
  939. let a = $(doc).find(`.box .video-title:contains('${avid.toUpperCase()}')`);
  940. if (a.length) {
  941. let javdbData = {};
  942. javdbData.score = $(a[0].parentElement).find('.score>span').text();
  943. javdbData.url = a[0].parentElement.href.replace(location.origin, 'https://' + [GM_getValue('javdb_url')]);
  944. resolve(javdbData);
  945. } else {
  946. reject("javdb没查找到此番号");
  947. }
  948. });
  949. });
  950. }
  951. /**
  952. * 查询115网盘是否拥有番号
  953. * @param {string} javId 番号
  954. * @param {Function} callback 回调函数
  955. */
  956. static search115Data(javId, callback) {
  957. //异步请求搜索115番号 //115查询
  958. let javId2 = javId.replace(/(-)/g, ""); //把番号-去除,例如ABC-123 =》 ABC123
  959. let javId3 = javId.replace(/(-)/g, "00"); //把番号-替换为00,例如CCVR-065 =》 CCVR00065
  960. let javId4 = javId.replace(/(-)/g, "-0"); //把番号-替换为-0,例如DSVR-584 =》 DSVR-0584
  961. //保存查询关键词参数
  962. GM_setValue("115_search_var", `${javId}|${javId2}|${javId3}|${javId4}`);
  963. let promise1 = Common.request(`https://webapi.115.com/files/search?search_value=${javId}%20${javId2}%20${javId3}%20${javId4}&format=json`);
  964. promise1.then((result) => {
  965. let resultJson = JSON.parse(result.responseText);
  966. if (resultJson.count > 0) {
  967. let pickcode = '';
  968. let reg = new RegExp(GM_getValue("115_search_var"), "gi");
  969. for (let i = 0; i < resultJson.data.length; i++) {
  970. let row = resultJson.data[i];
  971. if (row.play_long && (row.n.search(reg) >= 0)) { //iv vdi ico play_long
  972. pickcode = row.pc;
  973. callback(true, `https://v.anxia.com/?pickcode=${pickcode}`, pickcode);
  974. return;
  975. }
  976. }
  977. }
  978. callback(false, null, null);
  979. });
  980. }
  981. /**
  982. * 查询夸克网盘是否拥有番号
  983. * @param {string} javId 番号
  984. * @returns {Promise} Promise内返回参数resultData
  985. */
  986. static searchQuarkData(javId) {
  987. //异步请求搜索夸克番号
  988. let javId2 = javId.replace(/(-)/g, " "); //把番号-去除,例如ABC-123 =》 ABC 123
  989. let javId3 = javId.replace(/(-)/g, "00"); //把番号-替换为00,例如CCVR-065 =》 CCVR00065
  990. let javId4 = javId.replace(/(-)/g, "-0"); //把番号-替换为-0,例如DSVR-584 =》 DSVR-0584
  991. //保存查询关键词参数
  992. GM_setValue("quark_search_var", `${javId}|${javId2}|${javId3}|${javId4}`);
  993. let p1 = Common.request(`https://drive.quark.cn/1/clouddrive/file/search?pr=ucpro&fr=pc&q=${javId2}&_page=1&_size=50&_fetch_total=1&_sort=file_type:desc,updated_at:desc&_is_hl=1`);
  994. return p1.then((result) => {
  995. let resultJson = JSON.parse(result.responseText);
  996. if (resultJson.status == 200 && resultJson.metadata._count > 0) {
  997. let reg = new RegExp(GM_getValue("quark_search_var"), "gi");
  998. for (let i = 0; i < resultJson.data.list.length; i++) {
  999. let row = resultJson.data.list[i];
  1000. if (row.duration && (row.file_name.search(reg) >= 0)) { //时长、文件名判断
  1001. return Promise.resolve({
  1002. isHave: true,
  1003. playUrl: `https://pan.quark.cn/list#/video/${row.fid}`,
  1004. pickcode: row.fid
  1005. });
  1006. }
  1007. }
  1008. }
  1009. return Promise.resolve({ isHave: false });
  1010. });
  1011. }
  1012. /**
  1013. * 查找番号是否存在于缓存
  1014. * @param {string} javId 番号
  1015. * @returns {boolean}
  1016. */
  1017. static browseJavidHasCache(javId) {
  1018. return GM_getValue("myBrowseJavidArray", '[]').indexOf(javId) > 0 ? true : false;
  1019. }
  1020. /**
  1021. * 保存番号到GM缓存
  1022. * @param {string} javId 番号
  1023. */
  1024. static addBrowseJavidCache(javId) {
  1025. if (!this.browseJavidHasCache(javId)) {
  1026. let myBrowseJavidArray = JSON.parse(GM_getValue("myBrowseJavidArray", '[]'));
  1027. myBrowseJavidArray.push(javId);
  1028. GM_setValue("myBrowseJavidArray", JSON.stringify(myBrowseJavidArray));
  1029. }
  1030. }
  1031. static getSchemaBuilder() {
  1032. // 构造jav库
  1033. let ds = lf.schema.create('jav_v2', 5);
  1034. // 创建MyMovie表
  1035. ds.createTable('MyMovie').
  1036. //addColumn('id', lf.Type.INTEGER).
  1037. //索引编码 如javlikqu54
  1038. addColumn('index_cd', lf.Type.STRING).
  1039. //识别编码 如CHN-141
  1040. addColumn('code', lf.Type.STRING).
  1041. //缩略图路径
  1042. addColumn('thumbnail_url', lf.Type.STRING).
  1043. //片名
  1044. addColumn('movie_name', lf.Type.STRING).
  1045. //演员
  1046. addColumn('actor', lf.Type.STRING).
  1047. //封面图路径
  1048. addColumn('cover_img_url', lf.Type.STRING).
  1049. //预览图路径
  1050. addColumn('prev_img_url', lf.Type.STRING).
  1051. //发布日期
  1052. addColumn('release_date', lf.Type.STRING).
  1053. //评分
  1054. addColumn('score', lf.Type.STRING).
  1055. //片长(分钟)
  1056. addColumn('duration', lf.Type.INTEGER).
  1057. //导演
  1058. addColumn('director', lf.Type.STRING).
  1059. //制作商
  1060. addColumn('maker', lf.Type.STRING).
  1061. //发行商
  1062. addColumn('publisher', lf.Type.STRING).
  1063. //加入时间
  1064. addColumn('add_time', lf.Type.STRING).
  1065. //115的pickcode
  1066. addColumn('pick_code', lf.Type.STRING).
  1067. //是否已阅
  1068. addColumn('is_browse', lf.Type.BOOLEAN).
  1069. //是否想要 0:否 1:是 2:未知
  1070. addColumn('is_want', lf.Type.INTEGER).
  1071. //是否看过 0:否 1:是 2:未知
  1072. addColumn('is_seen', lf.Type.INTEGER).
  1073. //是否拥有 0:否 1:是 2:未知
  1074. addColumn('is_have', lf.Type.INTEGER).
  1075. //是否同步
  1076. addColumn('is_sync', lf.Type.BOOLEAN).
  1077. //定义主键
  1078. addPrimaryKey(['index_cd']).
  1079. //定义索引
  1080. addIndex('idxaddtime', ['add_time'], false, lf.Order.DESC);
  1081. return ds;
  1082. }
  1083. };
  1084.  
  1085. class Jav {
  1086. /**
  1087. * 加载数据 todo 改进
  1088. * @param {String} pageName 访问网页名
  1089. */
  1090. static loadData(pageName, queue) {
  1091. Common.toString();// 无此步骤Common作用域失效,暂时未知原因
  1092. let todo = async () => { // todo 190628
  1093. await loadPageNumData(pageName, 1);
  1094. for (let i = 2; i < GM_getValue(pageName + "_pageNum") + 1; i++) {
  1095. queue.push(() => {
  1096. let defer = $.Deferred();
  1097. loadPageNumData(pageName, i).then(() => {
  1098. defer.resolve();
  1099. });
  1100. return defer.promise();
  1101. });
  1102. }
  1103. };
  1104. return todo();
  1105. }
  1106.  
  1107. static loadPageNumData(pageName, PageNum) {
  1108. let url = location.origin + "/cn/" + pageName + ".php?&sort=added&page=" + PageNum;// console.log("打开链接url:" + url);
  1109. let commonClass = Common;// 无此步骤Common作用域失效,暂时未知原因
  1110. let promise1 = Common.request(url);
  1111. promise1.then((result) => {
  1112. return new Promise(resolve => {
  1113. if ($.type(result) !== "function" && result.status !== 200) {
  1114. return resolve();
  1115. }
  1116. let doc = result.responseText;
  1117. //设置初始化总页数
  1118. if (PageNum == 1) {
  1119. let docArr = doc.split("的影片: ");
  1120. let totalNum = parseInt(docArr[1].substring(0, docArr[1].search(/<\/div/)));
  1121. GM_setValue(pageName + "_pageNum", parseInt((totalNum + 19) / 20));
  1122. }
  1123. let tableText = doc.substring(doc.search(/<table class="videotextlist">/), doc.search(/<table style="width: 95%; margin: 10px auto;">/));
  1124. //<table class="videotextlist"> //<table style="width: 95%; margin: 10px auto;">
  1125. let $movList = $(commonClass.parsetext(tableText)).find("tr");
  1126. let indexArrStr = "0";
  1127. let timeArrStr = "0";
  1128. let myBrowseJson = "";
  1129. for (let i = 1; i < $movList.length; i++) {
  1130. let movie = $movList.get(i);
  1131. let $aEle = $($(movie).children("td.title").find("a").get(0));
  1132. // 索引编码
  1133. let index_cd = $aEle.attr("href").split("=")[1];
  1134. // 创建时间
  1135. let add_time = $($(movie).children("td").get(2)).text();
  1136. indexArrStr = indexArrStr + index_cd + ',';
  1137. timeArrStr = timeArrStr + add_time + "|";
  1138. myBrowseJson = myBrowseJson + '{"index_cd":"' + index_cd + '","add_time":"' + add_time + '"},';
  1139. }
  1140.  
  1141. // 保存当前页的json格式数据
  1142. GM_setValue(pageName + "_myBrowseJson" + result.finalUrl.split("page=")[1], myBrowseJson);
  1143. console.log("处理完url:" + location.origin + "/ja/" + pageName + ".php?&sort=added&page=" + PageNum);
  1144. resolve();
  1145. });
  1146. });
  1147. return promise1;
  1148. }
  1149.  
  1150. /**
  1151. * 合并json数据
  1152. * @param {string} pageName 访问网页名
  1153. */
  1154. static mergeJson(pageName) {
  1155. // 读取访问指定网页的页数量
  1156. var p = GM_getValue(pageName + "_pageNum");
  1157. if (p > 0) {
  1158. GM_setValue(pageName + "_myBrowseJsonAll", "");
  1159. // 循环合并Json,以同步方式保存.
  1160. let loopMerge = async () => {
  1161. for (let i = 1; i < p; i++) {
  1162. let tempJson = GM_getValue(pageName + "_myBrowseJson" + i);
  1163. if (tempJson && tempJson !== "") {
  1164. await new Promise(resolve => {
  1165. GM_setValue(pageName + "_myBrowseJsonAll", GM_getValue(pageName + "_myBrowseJsonAll") + tempJson);
  1166. resolve();
  1167. })
  1168. }
  1169. }
  1170. };
  1171. return loopMerge().then(() => {
  1172. console.log("doNum:" + (GM_getValue("doNum") + 1) + " --" + pageName);
  1173. GM_setValue("doNum", GM_getValue("doNum") + 1);
  1174. });
  1175. }
  1176. }
  1177.  
  1178. /**
  1179. * JSON数组去重
  1180. * @param {Array} array Array
  1181. * @param {string} key 唯一的key名,根据此键名进行去重
  1182. * @param {function} func
  1183. */
  1184. static uniqueArray(array, key, func) {
  1185. var result = [array[0]];
  1186. for (var i = 1; i < array.length; i++) {
  1187. var item = array[i];
  1188. var repeat = false;
  1189. for (var j = 0; j < result.length; j++) {
  1190. if (item[key] == result[j][key]) {
  1191. func(item, result[j]);
  1192. repeat = true;
  1193. break;
  1194. }
  1195. }
  1196. if (!repeat) {
  1197. result.push(item);
  1198. }
  1199. }
  1200. return result;
  1201. }
  1202.  
  1203.  
  1204.  
  1205. /**
  1206. * javbus详情页磁链列表增加复制、115离线快捷键功能函数、顺带将磁链按大小排序
  1207. */
  1208. static javbusUs() {
  1209. $('#magnet-table tbody tr td[colspan="4"]').attr("colspan", "5");
  1210. let tr_array = $('#magnet-table tr[height="35px"]');
  1211. for (var i = 0; i < tr_array.length; i++) {
  1212. let trEle = tr_array[i];
  1213. let magnetUrl = $(trEle).find("td a")[0].href;
  1214. $(trEle).append("<td style='text-align:center;'><div><a class='nong-copy' href='" + magnetUrl + "'>复制</a></div></td>");
  1215. $(trEle).append("<td><div class='nong-offline'><a class='nong-offline-download' target='_blank' "
  1216. + "href='http://115.com/?tab=offline&amp;mode=wangpan'>115离线</a></div></td>");
  1217. $(trEle).attr("maglink", magnetUrl);
  1218. $(trEle).find(".nong-copy")[0].addEventListener('click', thirdparty.nong.magnet_table.handle_event, false);
  1219. $(trEle).find(".nong-offline-download")[0].addEventListener('click', thirdparty.nong.magnet_table.handle_event, false);
  1220. }
  1221. }
  1222.  
  1223. /**
  1224. * 按磁链大小排序方法
  1225. */
  1226. static javbusUs_sort() {
  1227. let table = $('#magnet-table')
  1228. let tr_array = $('#magnet-table tr[height="35px"]');
  1229. tr_array.sort((a,b) => {
  1230. let magnetSize = $(a).find("td:nth-child(2) a")[0].innerText;
  1231. let unit = 1024
  1232. let lower_size = magnetSize.toLowerCase()
  1233. if(lower_size.includes("mb")){
  1234. unit = 1
  1235. } else if(lower_size.includes("tb")){
  1236. unit = 1024 * 1024
  1237. }
  1238. let size1 = parseFloat(lower_size.replace(/(mb|gb|tb| )/g, "")) * unit
  1239.  
  1240. magnetSize = $(b).find("td:nth-child(2) a")[0].innerText;
  1241. unit = 1024
  1242. lower_size = magnetSize.toLowerCase()
  1243. if(lower_size.includes("mb")){
  1244. unit = 1
  1245. } else if(lower_size.includes("tb")){
  1246. unit = 1024 * 1024
  1247. }
  1248. let size2 = parseFloat(lower_size.replace(/(mb|gb|tb| )/g, "")) * unit
  1249.  
  1250. return size1 < size2 ? 1 : -1
  1251. })
  1252. tr_array.detach().appendTo(table)
  1253. }
  1254.  
  1255. /**
  1256. * 初始化同步保存数据方法
  1257. */
  1258. static syncSaveData() {
  1259. GM_setValue("doNum", 0);//console.log("saveData");
  1260. let pm1 = mergeJson("mv_wanted");
  1261. let pm2 = mergeJson("mv_watched");
  1262. let pm3 = mergeJson("mv_owned");
  1263.  
  1264. Promise.all([pm1, pm2, pm3]).then(() => {
  1265. console.log("mergeJson处理完毕");
  1266. if (GM_getValue("doNum") === 3) {
  1267. let j1 = GM_getValue("mv_wanted_myBrowseJsonAll");
  1268. let j2 = GM_getValue("mv_watched_myBrowseJsonAll");
  1269. let j3 = GM_getValue("mv_owned_myBrowseJsonAll");
  1270. //let myBrowseAll = j3.substring(0, j3.length - 1);
  1271. let myBrowseAll = j1 + j2 + j3.substring(0, j3.length - 1);
  1272. let myBrowseArray = JSON.parse("[" + myBrowseAll + "]");
  1273.  
  1274. //json数组去重
  1275. myBrowseArray = this.uniqueArray(myBrowseArray, "index_cd", (item, resultObj) => {
  1276. if (item["add_time"] < resultObj["add_time"]) {
  1277. resultObj["add_time"] = item["add_time"];
  1278. }
  1279. });
  1280. GM_setValue("myBrowseAllData", JSON.stringify(myBrowseArray));
  1281. //应同步的总数
  1282. GM_setValue("myBrowseAllNum", myBrowseArray.length);//console.log(JSON.stringify(myBrowseArray));
  1283.  
  1284. let startTime = new Date();//console.log("startTime: " + startTime);
  1285. let b = GM_getValue(domain + "_stepTwo_V3", false);
  1286. if (!b) {
  1287. let jsonObj;
  1288. let row;
  1289. for (let i = 0; i < myBrowseArray.length; i++) {
  1290. jsonObj = myBrowseArray[i];
  1291. row = myMovie.createRow({
  1292. 'index_cd': jsonObj.index_cd,
  1293. 'code': '',
  1294. 'release_date': '',
  1295. 'duration': '',
  1296. 'director': '',
  1297. 'maker': '',
  1298. 'score': '',
  1299. 'actor': '',
  1300. 'cover_img_url': '',
  1301. 'thumbnail_url': '',
  1302. 'prev_img_url': '',
  1303. 'movie_name': '',
  1304. 'publisher': '',
  1305. 'add_time': jsonObj.add_time,
  1306. 'pick_code': '',
  1307. 'is_browse': true,
  1308. 'is_want': 2,
  1309. 'is_seen': 2,
  1310. 'is_have': 2,
  1311. 'is_sync': false
  1312. });
  1313. javDb.insertOrReplace().into(myMovie).values([row]).exec();
  1314. }
  1315. // 如果保存影片数量大于等于需同步总数,则同步完成
  1316. if (GM_getValue(domain + "_saveMovieNum", 0) >= myBrowseArray.length) {
  1317. GM_setValue(domain + "_stepTwo_V3", true);
  1318. GM_setValue(domain + "_doDataSyncStepAll_V3", true);
  1319. }
  1320. console.log(domain + "_stepTwoTime:" + (new Date() - startTime));
  1321. return Promise.resolve();
  1322. }
  1323. }
  1324. });
  1325. }
  1326.  
  1327. static getMovie($doc) {
  1328. return {
  1329. index_cd: $('#video_title a', $doc).attr('href').split("v=")[1],
  1330. code: $('.header', $doc)[0].nextElementSibling.textContent,
  1331. release_date: $('#video_date .text', $doc).text(),
  1332. duration: $('#video_length .text', $doc).text(),
  1333. director: $('#video_director .text', $doc).text(),
  1334. maker: $('#video_maker .text', $doc).text(),
  1335. score: $('#video_review .text .score', $doc).text(),
  1336. actor: $('#video_cast .text', $doc).text(),
  1337. cover_img_url: $('#video_jacket_img', $doc).attr("src").replace("http://", "").replace("https://", ""),
  1338. thumbnail_url: $('#video_jacket_img', $doc).attr("src").replace("http://", "").replace("https://", "").replace("pl", "ps"),
  1339. prev_img_url: "",
  1340. movie_name: $('#video_title a', $doc).text(),
  1341. publisher: $('#video_label .text a', $doc).text(),
  1342. add_time: (new Date()).Format("yyyy-MM-dd hh:mm:ss"),
  1343. pick_code: '',
  1344. is_browse: true,
  1345. is_want: ($('#subscribed .smallbutton.hidden', $doc).length > 0) ? 1 : 0,
  1346. is_seen: ($('#watched .smallbutton.hidden', $doc).length > 0) ? 1 : 0,
  1347. is_have: ($('#owned .smallbutton.hidden', $doc).length > 0) ? 1 : 0,
  1348. is_sync: true
  1349. }
  1350. }
  1351. /**
  1352. * 同步movie信息到myMovie表中
  1353. * @param result 页面响应结果
  1354. */
  1355. static syncMovie(result) {
  1356. let commonClass = Common;// 无此步骤Common作用域失效,暂时未知原因
  1357. let $doc = $(commonClass.parsetext(result.responseText));
  1358. let movie = Jav.getMovie($doc);
  1359. let myBrowseJsonArray = JSON.parse(GM_getValue("myBrowseAllData", "[]"));
  1360. if (myBrowseJsonArray.length > 0) {
  1361. let jsonObj = myBrowseJsonArray.filter((p) => {
  1362. return p.index_cd == result.finalUrl.split("v=")[1];
  1363. });
  1364. if (jsonObj.length > 0) movie.add_time = jsonObj[0].add_time;
  1365. }
  1366. let row = myMovie.createRow(movie);
  1367. javDb.insertOrReplace().into(myMovie).values([row]).exec();
  1368. }
  1369.  
  1370. /**
  1371. * javlib记录已阅影片
  1372. */
  1373. static javlibSaveData(AVID, pickcode, pm_mater) {
  1374. let movie = Jav.getMovie($(document));
  1375. movie.pick_code = pickcode;
  1376. Common.addBrowseJavidCache(AVID);
  1377. pm_mater.then(() => {
  1378. //查找是否存在此番号数据
  1379. return javDb.select().from(myMovie).where(myMovie.index_cd.eq(movie.index_cd)).exec()
  1380. .then((results) => {
  1381. if (results.length > 0) movie.add_time = results[0].add_time;
  1382. let row = myMovie.createRow(movie);
  1383. javDb.insertOrReplace().into(myMovie).values([row]).exec();
  1384. console.log(`${movie.code} 已经存入已阅影片`);
  1385. });
  1386. });
  1387. }
  1388.  
  1389. /**
  1390. * 针对页面的番号信息增加功能及样式修改. javlib和javbus共同使用
  1391. * @returns {string} 番号
  1392. */
  1393. static getAvidAndChgPage() {
  1394. let AVID = $('.header')[0].nextElementSibling.textContent;
  1395. // 实现点击番号复制到系统剪贴板 todo 181221v1
  1396. $('.header')[0].nextElementSibling.id = "avid";
  1397. $('#avid').empty().attr("title", "点击复制番号").attr("avid", AVID);
  1398. let a_avid = document.createElement('a');
  1399. $(a_avid).attr("href", "#").append(AVID);
  1400. $(a_avid).click(() => {
  1401. GM_setClipboard($('#avid').attr("avid"));
  1402. });
  1403. $('#avid').append(a_avid);
  1404. $('#avid').after("<span style='color:red;'>(←点击复制)</span>");
  1405. $($('.header')[0]).attr("class", "header_hobby");
  1406. return AVID;
  1407. }
  1408.  
  1409. static waterfallButton() {
  1410. // 瀑布流ui按钮
  1411. let a3 = document.createElement('a');
  1412. (waterfallScrollStatus > 0) ? $(a3).append('关闭瀑布流&nbsp;&nbsp;') : $(a3).append('开启瀑布流&nbsp;&nbsp;');
  1413. $(a3).css({
  1414. "color": "blue",
  1415. "font": "bold 12px monospace"
  1416. });
  1417. $(a3).attr("href", "#");
  1418. $(a3).click(function () {
  1419. if ((/关闭/g).test($(this).html())) {
  1420. GM_setValue('scroll_status', 0);
  1421. } else {
  1422. GM_setValue('scroll_status', 1);
  1423. }
  1424. window.location.reload();
  1425. });
  1426. return a3;
  1427. }
  1428.  
  1429. static javlibaryScript() {
  1430. let a3 = this.waterfallButton();
  1431. if ((/(JAVLibrary)/g).test(document.title)) {
  1432. //数据库初始化 start01
  1433. var pm_mater = Common.getSchemaBuilder().connect({
  1434. storeType: lf.schema.DataStoreType.INDEXED_DB
  1435. }).then((database) => {
  1436. javDb = database;
  1437. myMovie = javDb.getSchema().table('MyMovie');
  1438. //javDb.delete().from(myMovie).exec();// 清空MyMovie表数据.
  1439. return javDb.select().from(myMovie).where(myMovie.is_browse.eq(true)).exec();
  1440. }).then((results) => {
  1441. console.log("已经保存已阅影片数量:" + results.length);
  1442. GM_setValue(domain + "_saveMovieNum", results.length);
  1443. // results.forEach(function(row) {
  1444. // console.log(row['index_cd'],'|',row['code'],'|', row['add_time'],'|',row['movie_name']);
  1445. // });
  1446. if (document.URL.indexOf("bestrated") > 0) {
  1447. $(".left select").after("<a href='/cn/vl_bestrated.php?deleteTwoMonthAway' class='hobby-a'>&nbsp;&nbsp;只看近两月份</a>");
  1448. $(".left select").after("<a href='/cn/vl_bestrated.php?deleteOneMonthAway' class='hobby-a'>&nbsp;&nbsp;只看当前月份</a>");
  1449. $(".left select").after("<a href='/cn/vl_bestrated.php?filterMyBrowse' class='hobby-a'>&nbsp;&nbsp;不看我阅览过(上个月)</a>");
  1450. $(".left select").after("<a href='/cn/vl_bestrated.php?filterMyBrowse&mode=2' class='hobby-a'>&nbsp;&nbsp;不看我阅览过(全部)</a>");
  1451. //todo
  1452. } else if (document.URL.indexOf("vl_newrelease") > 0 || document.URL.indexOf("vl_update") > 0
  1453. || document.URL.indexOf("vl_genre") > 0 || document.URL.indexOf("vl_mostwanted") > 0) {
  1454. $(".displaymode .right").prepend("<a href='" + document.location.origin + document.location.pathname
  1455. + "?delete9down" + document.location.search.replace('?', '&') + "' class='hobby-a'>只看9分以上&nbsp;&nbsp;</a>");
  1456. $(".displaymode .right").prepend("<a href='" + document.location.origin + document.location.pathname
  1457. + "?delete8down" + document.location.search.replace('?', '&') + "' class='hobby-a'>只看8分以上&nbsp;&nbsp;</a>");
  1458. $(".displaymode .right").prepend("<a href='" + document.location.origin + document.location.pathname
  1459. + "?delete7down" + document.location.search.replace('?', '&') + "' class='hobby-a'>只看7分以上&nbsp;&nbsp;</a>");
  1460. }
  1461.  
  1462. if ((/(bestrated|newrelease|newentries|vl_update|mostwanted|vl_star)/g).test(document.URL) ||
  1463. (/(vl_genre|vl_searchbycombo|mv_owned|mv_watched|mv_wanted|mv_visited)/g).test(document.URL) ||
  1464. (/(vl_label|vl_maker|vl_director|vl_searchbyid|userwanted|userowned)/g).test(document.URL)) {
  1465.  
  1466. // 指定站点页面加入瀑布流控制按钮
  1467. $(".displaymode .right").prepend($(a3));
  1468.  
  1469. // 瀑布流脚本
  1470. thirdparty.waterfallScrollInit();
  1471.  
  1472. let a1 = document.createElement('a');
  1473.  
  1474. $(a1).append('按【VR】+评分排序&nbsp;&nbsp;');
  1475. $(a1).css({
  1476. "color": "blue",
  1477. "font": "bold 12px monospace"
  1478. });
  1479. $(a1).attr("href", "#");
  1480. $(a1).click(() => {
  1481. let div_array = $("div.videos div.video");
  1482. div_array.sort((a, b) => {
  1483. let a_score = parseFloat($(a).children("a").attr("score"));
  1484. let b_score = parseFloat($(b).children("a").attr("score"));
  1485. if (a_score > b_score) {
  1486. return -1;
  1487. } else if (a_score === b_score) {
  1488. return 0;
  1489. } else {
  1490. return 1;
  1491. }
  1492. });
  1493. div_array.sort((a, b) => {
  1494. let a_val = $(a).children("a").attr("title").indexOf("【VR】") >= 0 ? 1 : 0;
  1495. let b_val = $(b).children("a").attr("title").indexOf("【VR】") >= 0 ? 1 : 0;
  1496. if (a_val > b_val) {
  1497. return -1;
  1498. } else if (a_val === b_val) {
  1499. return 0;
  1500. } else {
  1501. return 1;
  1502. }
  1503. });
  1504. // 删除Dom列表数据关系,重新添加排序数据
  1505. div_array.detach().appendTo("#waterfall");
  1506. });
  1507.  
  1508. let a2 = $(a1).clone();
  1509. $(a2).html('按时间排序&nbsp;&nbsp;');
  1510. $(a2).click(() => {
  1511. let div_array = $("div.videos div.video");
  1512. div_array.sort((a, b) => {
  1513. let a_time = new Date($(a).children("a").attr("release_date").replace(/-/g, "\/")).getTime();
  1514. let b_time = new Date($(b).children("a").attr("release_date").replace(/-/g, "\/")).getTime();
  1515. let a_score = parseFloat($(a).children("a").attr("score"));
  1516. let b_score = parseFloat($(b).children("a").attr("score"));
  1517. if (a_time > b_time) {
  1518. return -1;
  1519. } else if (a_time === b_time) {
  1520. return (a_score > b_score) ? -1 : 1;
  1521. } else {
  1522. return 1;
  1523. }
  1524. });
  1525.  
  1526. // 删除Dom列表数据关系,重新添加排序数据
  1527. div_array.detach().appendTo("#waterfall");
  1528. });
  1529. $(".displaymode .right").prepend($(a2));
  1530. $(".displaymode .right").prepend($(a1));
  1531. }
  1532. });
  1533. //JavWebSql.DBinit();
  1534. if ($('a[href="myaccount.php"]').length) {
  1535. // 已经登录
  1536. // 从未同步过,同步云数据到本地数据库
  1537. let isSync = GM_getValue(domain + "_doDataSyncStepAll_V3", false);
  1538. console.log(domain + " 是否同步过:" + isSync);
  1539. if (!isSync) {
  1540. pm_mater.then(() => {
  1541. return new Promise(resolve => {
  1542. var hasStepOne = GM_getValue(domain + "_stepOne_V3", false);
  1543. let stepOneStartTime = new Date();
  1544. console.log(domain + " 同步是否完成第一步:" + hasStepOne);
  1545. if (!hasStepOne) {
  1546. // 立即下载数据
  1547. GM_setValue("mv_wanted_pageNum", 0);
  1548. GM_setValue("mv_watched_pageNum", 0);
  1549. GM_setValue("mv_owned_pageNum", 0);
  1550.  
  1551. //start02 todo lovefieldDB
  1552. // 创建请求队列 //浏览器对同一域名进行请求的最大并发连接数:chrome为6
  1553. let queue = new Queue(7);
  1554. // 读取想要的影片
  1555. this.loadData("mv_wanted", queue);
  1556. // 读取看过的影片
  1557. this.loadData("mv_watched", queue);
  1558. // 读取拥有的影片
  1559. this.loadData("mv_owned", queue);
  1560. // 延迟1秒运行定时循环函数
  1561. setTimeout(() => {
  1562. // 定时循环函数,当队列执行完成时结束
  1563. var s4 = setInterval(() => {
  1564. //console.log("queue.taskList.length : " + queue.taskList.length);
  1565. if (queue.taskList.length == 0) {
  1566. let end_num = 0;
  1567. for (let i = 0, l = queue.threads.length; i < l; i++) {
  1568. if (queue.threads[i].promise.state() === 'resolved') {
  1569. end_num++;
  1570. }
  1571. }
  1572. if (end_num == queue.threads.length) {
  1573. GM_setValue(domain + "_stepOne_V3", true); // todo 需打开
  1574. console.log(domain + "_stepOneTime:" + (new Date() - stepOneStartTime));
  1575. clearInterval(s4);
  1576. return resolve();
  1577. }
  1578. }
  1579. }, 300);
  1580. }, 1000);
  1581. } else {
  1582. return resolve();
  1583. }
  1584. });
  1585. }).then(() => {
  1586. this.syncSaveData();
  1587. });
  1588. }
  1589. // 增加同步数据到本地的触发按钮
  1590. }
  1591.  
  1592. // 新增VR发行菜单入口
  1593. $('.menul1 ul li:contains("新发行")').after('<li><a href="vl_genre.php?g=aaua">VR发行</a></li>');
  1594.  
  1595. // 处理javlib番号详情页面的脚本
  1596. if ($('.header').length && $('meta[name="keywords"]').length) {
  1597. //获取番号影片详情页的番号 例如:http://www.javlibrary.com/cn/?v=javli7j724
  1598. let AVID = this.getAvidAndChgPage();
  1599.  
  1600. window.onload = () => {
  1601. $('iframe').remove();
  1602. };
  1603. let pickcode = '';
  1604.  
  1605. //增加预览图片大图链接
  1606. let imgs = $('.previewthumbs>img').clone();
  1607. $('.previewthumbs>img').remove();
  1608. imgs.each((i, img) => {
  1609. $('.previewthumbs').eq(0).append(`<a target="_blank" href="${img.src.replace("-", "jp-")}">${img.outerHTML}</a>`);
  1610. });
  1611.  
  1612. //加入坐标div,辅助插入元素
  1613. $('#video_genres').before(`<div id="zuobiao" class="item"></div>`);
  1614. let $div_zuobiao = $('#zuobiao');
  1615.  
  1616. //加入dmm评分数据
  1617. if (imgs.length) {
  1618. let dmmId = Common.getDmmId(imgs[0].src);
  1619. if (!dmmId) {
  1620. dmmId = Common.avIdToDmmId(AVID);
  1621. }
  1622.  
  1623. Common.getDmmData(`https://www.dmm.co.jp/digital/videoa/-/detail/=/cid=${dmmId}/`).then((dmmData) => {
  1624. $div_zuobiao.before(addLinkHtml(dmmData));
  1625.  
  1626. function addLinkHtml(dmmData) {
  1627. return `
  1628. <div id="video_review_dmm" class="item">
  1629. <table><tbody><tr>
  1630. <td class="header"><a target="_blank" href="${dmmData.url}">DMM评价:</a></td>
  1631. <td><span class="text">${dmmData.score.replace("点", "分")}</span>, ${dmmData.user_num}人评, ${dmmData.collect_num}收藏</td>
  1632. </tr></tbody></table>
  1633. </div>
  1634. `;
  1635. }
  1636. });
  1637. }
  1638.  
  1639. //加入javdb评分数据
  1640. let p3 = Common.getJavDbData(Common.getAvCode(AVID));
  1641. p3.then((javdbData) => {
  1642. let score = javdbData.score.trim().replace("由", "").replace("人評價", "人评");
  1643. $div_zuobiao.after(`
  1644. <div id="video_review_javdb" class="item">
  1645. <table><tbody><tr>
  1646. <td class="header"><a target="_blank" href="${javdbData.url}">javdb评价:</a></td>
  1647. <td><span class="text">${score}</td>
  1648. </tr></tbody></table>
  1649. </div>
  1650. `);
  1651. }).catch(errMsg => { console.log(errMsg); });
  1652.  
  1653. let $div_video_cast = $('#video_cast');
  1654. //加入Jav跳转
  1655. $div_video_cast.after(`
  1656. <div id="javweb_jump" class="item">
  1657. <table><tbody><tr>
  1658. <td class="header">JAV跳转:</td>
  1659. <td id="linkJump">
  1660. <span class="genre"><a href="https://${GM_getValue('javbus_url')}/${AVID}" target="_blank">JavBus</a></span>
  1661. </td>
  1662. </tr></tbody></table>
  1663. </div>
  1664. `);
  1665. // javstoreLink
  1666. let $span = $(`<span class="genre"><a href="javascript:void(0);">JavStore</a></span>`);
  1667. $('#linkJump').prepend(Common.javstoreLinkMousedown($span, AVID));
  1668.  
  1669.  
  1670. //加入在线预览跳转
  1671. $div_video_cast.after(`
  1672. <div id="video_webplayer" class="item">
  1673. <table><tbody><tr>
  1674. <td class="header">在线预览:</td>
  1675. <td>
  1676. <span class="genre"><a href="https://missav.com/cn/${AVID}" target="_blank" title="需解封印" >missav</a></span>
  1677. <span class="genre"><a href="https://7mmtv.tv/zh/censored_search/all/${AVID}/1.html" target="_blank" title="需解封印" >7mmtv</a></span>
  1678. <span class="genre"><a href="https://supjav.com/zh/?s=${Common.getAvCode(AVID)}+${AVID}" target="_blank" title="需解封印">supjav</a></span>
  1679. </td>
  1680. </tr></tbody></table>
  1681. </div>
  1682. `);
  1683.  
  1684. $('#watched .smallbutton').html("放弃了");
  1685. $('#watched .smalldarkbutton.hidden').html("我放弃这片了");
  1686.  
  1687.  
  1688. //查找115是否有此番号
  1689. Common.search115Data(AVID, (BOOLEAN_TYPE, playUrl, pc) => {
  1690. if (BOOLEAN_TYPE) {
  1691. let $imgObj = $('#video_jacket_img');
  1692. pickcode = pc;
  1693. $imgObj.after(`
  1694. <div style="position: absolute;width: 100%;height: 12%;background: rgba(0,0,0,0.5);top: 88%;left: 0;">
  1695. <p style="color: white;font-size: 46px;margin: 0 0 0px;display: inline-block;text-align: left;">115网盘已拥有此片</p>
  1696. <a target="_blank" href="${playUrl}">
  1697. <p style="color: white;font-size: 46px;margin: 0 0 0px;display: inline-block;text-align: right;width: 50%;">115在线播放 ►</p></a>
  1698. </div>
  1699. `);
  1700. $('#owned button[class="smallbutton"]').click();
  1701. }
  1702. console.log("番号输出:" + AVID);
  1703. //加入预览JAV全片截图
  1704. Common.addAvImg(Common.getAvCode(AVID), ($img) => {
  1705. // http://www.javlibrary.com/cn/?v=javlilzo4e
  1706. let divEle = $("div[id='video_title']")[0]; // todo 190604
  1707. if (divEle) {
  1708. $(divEle).after(
  1709. '<div style="width: 100%;height: 100%;display: inline-block;margin: 0px 0px 0px 0px;">' +
  1710. '<div id="hobby_div_left" style="float: left;min-width: 60%;"></div>' +
  1711. '<div id="hobby_div_right" style="float: left;min-width: 66px;"></div>' +
  1712. '</div>'
  1713. );
  1714. $('#hobby_div_left').append($('#video_jacket_info'));
  1715. $('#hobby_div_left').append($('#video_favorite_edit'));
  1716. $('#hobby_div_right').append($img);
  1717. }
  1718. }, !BOOLEAN_TYPE);
  1719.  
  1720. // 只支持javlibray处理已阅影片
  1721. this.javlibSaveData(AVID, pickcode, pm_mater);
  1722. });
  1723.  
  1724. //查找夸克是否有此番号
  1725. Common.searchQuarkData(AVID).then(result => {
  1726. if (result.isHave) {
  1727. let $imgObj = $('#video_jacket_img');
  1728. $imgObj.after(`
  1729. <div style="position: absolute;width: 100%;height: 12%;background: rgba(0,0,0,0.5);top: 88%;left: 0;">
  1730. <p style="color: white;font-size: 46px;margin: 0 0 0px;display: inline-block;text-align: left;">夸克网盘已有此片</p>
  1731. <a target="_blank" href="${result.playUrl}">
  1732. <p style="color: white;font-size: 46px;margin: 0 0 0px;display: inline-block;text-align: right;width: 50%;">夸克在线播放 ►</p></a>
  1733. </div>
  1734. `);
  1735. $('#owned button[class="smallbutton"]').click();
  1736. }
  1737.  
  1738. // 只支持javlibray处理已阅影片
  1739. this.javlibSaveData(AVID, pickcode, pm_mater);
  1740. });
  1741.  
  1742. //标题去除超链接
  1743. $('#video_title h3').after($('#video_title a'));
  1744. $('#video_title h3').text($('#video_title a').text());
  1745. $('#video_title a').empty();
  1746.  
  1747. // 挊
  1748. thirdparty.nong.searchMagnetRun();
  1749. }//番号影片详情页处理end
  1750. }
  1751. }
  1752.  
  1753. static javBusScript() {
  1754. let a3 = this.waterfallButton();
  1755. if ((/(JavBus|AVMOO|AVSOX)/g).test(document.title) || $("footer:contains('JavBus')").length) {
  1756. GM_addStyle(`
  1757. .info p {line-height: 18px!important;}
  1758. .screencap img{ width:100%; max-width: 1000px;}
  1759. `);
  1760. // 新增FC2菜单入口
  1761. $('#navbar ul.nav.navbar-nav li:eq(0)')
  1762. .after(`<li><a href="https://${GM_getValue('javdb_url')}/advanced_search?type=3&score_min=4.2&score_max=&released_start=&released_end=&actors%5B%5D=&tags%5B%5D=&p=0&d=0&d=1&c=0&s=0&i=0&v=0&commit=檢索&lm=h" target="_blank">FC2</a></li>`);
  1763. // 新增VR菜单入口
  1764. $('#navbar ul.nav.navbar-nav li:eq(0)').after('<li><a href="/search/VR&type=1">VR</a></li>');
  1765. // 指定站点页面加入瀑布流控制按钮
  1766. let li_elem = document.createElement('li');
  1767. $(li_elem).append($(a3));
  1768. // JavBus
  1769. $(".visible-md-block").closest(".dropdown").after($(li_elem));
  1770. // AVMOO|AVSOX
  1771. $(".active").closest(".navbar-nav").append($(li_elem));
  1772.  
  1773. // 瀑布流脚本
  1774. thirdparty.waterfallScrollInit();
  1775.  
  1776. //获取番号影片详情页的番号 例如:https://www.javbus.com/AVVR-323
  1777. if ($('.header').length && $('meta[name="keywords"]').length) {
  1778. let AVID = this.getAvidAndChgPage();
  1779. Common.addBrowseJavidCache(AVID);
  1780.  
  1781. //加入坐标div,辅助插入元素
  1782. $('p.header').before('<p id="zuobiao"></p>');
  1783. let $p_zuobiao = $('#zuobiao');
  1784.  
  1785. //加入dmm评分数据
  1786. let a_imgs = $('#sample-waterfall>a');
  1787. if (a_imgs.length && !$('a.avatar-box[href*="uncensored"]').length && !location.hostname.includes('javbus.org')
  1788. && $('#sample-waterfall>a[href*="pics.dmm"]').length) {
  1789. let p1 = Common.getDmmData(`https://www.dmm.co.jp/digital/videoa/-/detail/=/cid=${Common.getDmmId(a_imgs[0].href)}/`);
  1790. p1.then((dmmData) => {
  1791. $p_zuobiao.before(`
  1792. <p>
  1793. <span class="header">
  1794. <a target="_blank" href="${dmmData.url}" style="color: blue;">
  1795. DMM&nbsp;评:</a>
  1796. </span>
  1797. ${dmmData.score.replace("点", "分")}, ${dmmData.user_num}人评, ${dmmData.collect_num}收藏
  1798. </p>
  1799. `);
  1800. });
  1801. }
  1802.  
  1803. //加入javdb评分数据
  1804. Common.getJavDbData(AVID).then((javdbData) => {
  1805. let score = javdbData.score.trim().replace("由", "").replace("人評價", "人评");
  1806. $p_zuobiao.after(`
  1807. <p>
  1808. <span class="header"><a target="_blank" href="${javdbData.url}" style="color: blue;">javdb评:</a></span>
  1809. ${score}
  1810. </p>
  1811. `);
  1812. });
  1813.  
  1814. //查找115是否有此番号
  1815. Common.search115Data(AVID, (BOOLEAN_TYPE, playUrl, pc) => {
  1816. if (BOOLEAN_TYPE) {
  1817. let $imgObj = $('.bigImage');
  1818. $imgObj.after(`
  1819. <div style="position: absolute;width: 100%;height: 12%;background: rgba(0,0,0,0.5);top: 88%;left: 0;">
  1820. <p style="color: white;font-size: 46px;margin: 0 0 0px;display: inline-block;text-align: left;">115网盘已拥有此片</p>
  1821. <a target="_blank" href="${playUrl}">
  1822. <p style="color: white;font-size: 46px;margin: 0 0 0px;display: inline-block;text-align: right;width: 50%;">115在线播放 ►</p></a>
  1823. </div>
  1824. `);
  1825. }
  1826. console.log("番号输出:" + AVID);
  1827. Common.addAvImg(AVID, ($img) => {
  1828. //https://www.javbus.com/CHN-141
  1829. let divEle = $("div[class='col-md-3 info']")[0];
  1830. $(divEle).attr("id", "video_info");
  1831. if (divEle) {
  1832. $(divEle.parentElement).append($img);
  1833. }
  1834. }, false);//javbus 默认不放大
  1835. });
  1836.  
  1837. //查找夸克是否有此番号
  1838. Common.searchQuarkData(AVID).then(result => {
  1839. if (result.isHave) {
  1840. let $imgObj = $('.bigImage');
  1841. $imgObj.after(`
  1842. <div style="position: absolute;width: 100%;height: 12%;background: rgba(0,0,0,0.5);top: 88%;left: 0;">
  1843. <p style="color: white;font-size: 46px;margin: 0 0 0px;display: inline-block;text-align: left;">夸克网盘已有此片</p>
  1844. <a target="_blank" href="${result.playUrl}">
  1845. <p style="color: white;font-size: 46px;margin: 0 0 0px;display: inline-block;text-align: right;width: 50%;">夸克在线播放 ►</p></a>
  1846. </div>
  1847. `);
  1848. }
  1849. });
  1850.  
  1851. //加入在线预览跳转
  1852. $('.col-md-3.info').append(`
  1853. <p>
  1854. <span class="header">在线预览:</span>
  1855. <a href="https://missav.com/cn/${AVID}" target="_blank" style="color: rgb(204, 0, 0);" title="需解封印">missav&nbsp;</a>
  1856. <a href="https://7mmtv.tv/zh/censored_search/all/${AVID}/1.html" target="_blank" style="color: rgb(204, 0, 0);" title="需解封印">7mmtv&nbsp;</a>
  1857. <a href="https://supjav.com/zh/?s=${AVID}" target="_blank" style="color: rgb(204, 0, 0);" title="需解封印">supjav&nbsp;</a>
  1858. </p>
  1859. `);
  1860. // 加入javlib的跳转链接
  1861. $('.col-md-3.info').append(`
  1862. <p id="linkJump">
  1863. <span class="header">JAV跳转:</span>
  1864. <a href="https://${GM_getValue('javlib_url')}/cn/vl_searchbyid.php?keyword=${AVID}" target="_blank" style="color: rgb(204, 0, 0);">JavLib&nbsp;</a>
  1865. </p>
  1866. `);
  1867. // javstoreLink
  1868. let $a = $(`<a title="综合 JAV资源站" href="javascript:void(0);" style="color: rgb(204, 0, 0);">JavStore&nbsp;</a>`);
  1869. $('#linkJump').append(Common.javstoreLinkMousedown($a, AVID));
  1870.  
  1871. // 修改javbus磁链列表头,增加两列
  1872. $('#magnet-table tbody tr').append('<td style="text-align:center;white-space:nowrap">操作</td><td style="text-align:center;white-space:nowrap">离线下载</td>');
  1873. // 先执行一次,针对已经提前加载出磁链列表结果时有效
  1874. this.javbusUs();
  1875. this.javbusUs_sort();
  1876. // 针对为提前加载出磁链列表结果,通过dom元素是否改变事件来判断是否执行功能。
  1877. $('#magnet-table').on("DOMNodeInserted", () => {
  1878. // 触发后关闭监听事件
  1879. $('#magnet-table').off();
  1880. this.javbusUs();
  1881. this.javbusUs_sort();
  1882. });
  1883.  
  1884. // 挊
  1885. thirdparty.nong.searchMagnetRun();
  1886. }
  1887. }
  1888. }
  1889.  
  1890. static oneJavScript() {
  1891. if ((/(OneJAV)/g).test(document.title)) { //todo 190404
  1892. GM_addStyle(`
  1893. .column.is-5 {max-width: 82%;width: auto;}
  1894. .column {flex-basis: inherit;flex-grow: inherit;width: 800px;}
  1895. .container {max-width: 100%;width: 100%;}
  1896. .has-text-grey-dark {max-width: 1000px;}
  1897. .image {width: auto; max-width: 800px;}
  1898. `);
  1899. // 插入自己创建的div
  1900. $('div.container nav.pagination.is-centered').before("<div id='card' ></div>");
  1901. // 将所有番号内容移到新建的div里
  1902. $('div#card').append($('div.container div.card.mb-3'));
  1903. // 瀑布流脚本
  1904. thirdparty.waterfallScrollInit();
  1905. }
  1906. }
  1907.  
  1908. static jav321Script() {
  1909. if ((/(^JAV321)/g).test(document.body.innerText)) { //todo 190531
  1910. Common.addAvImgCSS();
  1911. GM_addStyle(`
  1912. .col-md-3 {width: 20%;padding-left: 18px; padding-right: 2px;}
  1913. .col-xs-12,.col-md-12 {padding-left: 2px; padding-right: 0px;}
  1914. .col-md-7 {width: 79%;padding-left: 2px;padding-right: 0px;}
  1915. .col-md-9 {width: max-content;}
  1916. .col-md-offset-1 {margin-left: auto;}
  1917. .hobby {display: inline-block;float: left;}
  1918. .hobby_mov {width: 75%;}
  1919. .hobby_p {color: white;font-size: 40px;margin: 0 0 0px;display: inline-block;text-align: right;width: 100%;}
  1920. `);
  1921. $(".col-md-7.col-md-offset-1.col-xs-12 .row .col-md-3 .img-responsive:eq(0)").offsetParent().attr("class", "hobby");
  1922. $("#video_overlay_sample").offsetParent().attr("class", "hobby_mov");
  1923. // 调整div位置
  1924. $('div.col-md-7.col-md-offset-1.col-xs-12').before($('div.col-xs-12.col-md-12')[0].parentElement);
  1925.  
  1926. let meta = $('small')[0];
  1927. let arr = meta.textContent.split(" ");
  1928. let javID = arr[0];
  1929.  
  1930. //查找115是否有此番号
  1931. Common.search115Data(javID, (BOOLEAN_TYPE, playUrl, pc) => {
  1932. if (BOOLEAN_TYPE) {
  1933. let $imgObj = $('div.col-xs-12.col-md-12 img.img-responsive');
  1934. $imgObj.after(`
  1935. <div style="position: absolute;width: 100%;height: 22%;background: rgba(0,0,0,0.5);top: 78%;left: 0;">
  1936. <a target="_blank" href="${playUrl}"><p class="hobby_p">115在线播放 ►</p></a>
  1937. </div>
  1938. `);
  1939. }
  1940.  
  1941. //插入预览图
  1942. Common.addAvImg(javID, ($img) => {
  1943. //https://www.jav321.com/video/300mium-391
  1944. var divEle = $("div.col-md-9")[0];
  1945. //$(divEle).attr("id", "video_info");
  1946. if (divEle) {
  1947. $(divEle).after($img);
  1948. }
  1949. }, !BOOLEAN_TYPE);
  1950.  
  1951. Common.addBrowseJavidCache(javID);
  1952. });
  1953.  
  1954. $('.panel.panel-info:eq(0)').after($('.panel.panel-info:has(.table.table-striped)'));
  1955.  
  1956. // 修改jav321磁链列表头,增加两列
  1957. $('table.table.table-striped tbody tr:eq(0)').append('<th>操作</th><th>离线下载</th>');
  1958.  
  1959. //详情页磁链列表增加复制、115离线快捷键功能函数
  1960. let tr_array = $('table.table.table-striped tbody tr:gt(0)');
  1961. for (var i = 0; i < tr_array.length; i++) {
  1962. let trEle = tr_array[i];
  1963. let magnetUrl = $(trEle).find("td a")[0].href;
  1964. $(trEle).append(`
  1965. <td style='text-align:center;'><div><a class='nong-copy' href='${magnetUrl}'>复制</a></div></td>
  1966. <td><div class='nong-offline'>
  1967. <a class='nong-offline-download' target='_blank' href='http://115.com/?tab=offline&amp;mode=wangpan'>115离线</a>
  1968. </div></td>
  1969. `);
  1970. $(trEle).attr("maglink", magnetUrl);
  1971. $(trEle).find(".nong-copy")[0].addEventListener('click', thirdparty.nong.magnet_table.handle_event, false);
  1972. $(trEle).find(".nong-offline-download")[0].addEventListener('click', thirdparty.nong.magnet_table.handle_event, false);
  1973. //.addEventListener('click', this.handle_event, false);
  1974. }
  1975. }
  1976. }
  1977.  
  1978. static javDBScript() {
  1979. if ((/(JavDB)/g).test(document.title)) {
  1980. if ($('.app-desktop-banner').length) $('.app-desktop-banner').remove();
  1981. if ($('.modal.is-active.over18-modal').length) $('.modal.is-active.over18-modal').remove();
  1982.  
  1983. // 修改FC2菜单入口
  1984. $('.navbar-dropdown.is-boxed .navbar-item:contains("FC2")')
  1985. .attr("href","/advanced_search?type=3&score_min=4.2&score_max=&released_start=&released_end=&actors%5B%5D=&tags%5B%5D=&p=0&d=0&d=1&c=0&s=0&i=0&v=0&commit=檢索&lm=h");
  1986. // 新增VR菜单入口
  1987. $('.navbar-dropdown.is-boxed .navbar-item:eq(0)')
  1988. .after('<a class="navbar-item" href="/advanced_search?type=0&score_min=4.2&score_max=&released_start=&released_end=&actors%5B%5D=&tags%5B%5D=&tags%5B%5D=212%7CVR&p=0&d=0&d=1&c=0&s=0&i=0&v=0&commit=檢索&lm=h">VR</a>');
  1989.  
  1990. // 瀑布流脚本
  1991. thirdparty.waterfallScrollInit();
  1992.  
  1993. // 非小封面列表
  1994. if (!$("#waterfall").hasClass("v cols-4 vcols-8")) {
  1995. // 如果没有,加入tabs元素
  1996. if (!$(".tabs.is-boxed").length) {
  1997. $("#waterfall").before(`<div class="tabs is-boxed" style="justify-content: flex-end;"></div>`);
  1998. }
  1999. // 加入一个锚点
  2000. $(".tabs.is-boxed").before(`<a name="maodian" style="position: relative;top: -60px;"></a>`);
  2001. // 加入排序与过滤功能
  2002. $('.tabs.is-boxed').append(`
  2003. <div style="display: flex;">
  2004. <div class="is-active" style="border: 1px solid #3273dc;">
  2005. <a id="javtopusernum" href="#maodian" style="background-color: white;color: #3273dc;font-weight: bold;">
  2006. <span>评分人数排序</span>
  2007. </a>
  2008. </div>
  2009. <div class="is-active" style="border: 1px solid #3273dc;">
  2010. <a id="javtopscore" href="#maodian" style="background-color: white;color: #3273dc;font-weight: bold;">
  2011. <span>JAV评分排序</span>
  2012. </a>
  2013. </div>
  2014. <div style="border: 1px solid #3273dc;background-color: #f5f5f5;height: 2.8em;display: flex;">
  2015. <a href="#maodian" style="color: #3273dc; font-weight: bold;">
  2016. <span>屏蔽评分人数&nbsp&lt;&nbsp</span>
  2017. </a>
  2018. <input id="offusernum" name="offusernum" class="input" placeholder="0&nbsp人数" min="0" max="9999" type="number"
  2019. style="height: 1.5em;width: 5.5em;padding: 2px;margin: 0.6em 1em 0 0;">
  2020. </div>
  2021. </div>
  2022. `);
  2023.  
  2024. $('#javtopscore').click(() => {
  2025. let div_array = $(JAVDB_ITEM_SELECTOR);
  2026. div_array.sort((a, b) => {
  2027. let a_score = parseFloat($(a).attr("score"));
  2028. let b_score = parseFloat($(b).attr("score"));
  2029. if (a_score > b_score) {
  2030. return -1;
  2031. } else if (a_score === b_score) {
  2032. return 0;
  2033. } else {
  2034. return 1;
  2035. }
  2036. });
  2037. // 删除Dom列表数据关系,重新添加排序数据
  2038. div_array.detach().appendTo("#waterfall");
  2039. $('#javtopscore').css("background-color", "#3273dc").css("color", "white");
  2040. $('#javtopusernum').css("background-color", "white").css("color", "#3273dc");
  2041. });
  2042.  
  2043. $('#javtopusernum').click(() => {
  2044. let div_array = $(JAVDB_ITEM_SELECTOR);
  2045. div_array.sort((a, b) => {
  2046. let a_score = parseFloat($(a).attr("usernum"));
  2047. let b_score = parseFloat($(b).attr("usernum"));
  2048. if (a_score > b_score) {
  2049. return -1;
  2050. } else if (a_score === b_score) {
  2051. return 0;
  2052. } else {
  2053. return 1;
  2054. }
  2055. });
  2056. // 删除Dom列表数据关系,重新添加排序数据
  2057. div_array.detach().appendTo("#waterfall");
  2058. $('#javtopusernum').css("background-color", "#3273dc").css("color", "white");
  2059. $('#javtopscore').css("background-color", "white").css("color", "#3273dc");
  2060. });
  2061.  
  2062. $('#offusernum').change(() => {
  2063. let offusernum = $('#offusernum').val();
  2064. if (offusernum) {
  2065. $(JAVDB_ITEM_SELECTOR).toArray().forEach(e => {
  2066. parseInt($(e).attr("usernum")) < parseInt(offusernum) ? $(e).hide() : $(e).show();
  2067. });
  2068. }
  2069. });
  2070. }
  2071. }
  2072. }
  2073.  
  2074. static javStoreScript() {
  2075. if ($('.all_page_javstore1 .danhgia_thich').length) {
  2076. GM_addStyle(`
  2077. .category_news_main_right {width: 100%;}
  2078. .boxoright {width: calc((100%) - 460px)}
  2079. .boxoleft { background: #ffffff!important; width: 460px; padding: 0 5px;}
  2080. .boxoleft > div { margin: 0 0 0 0; }
  2081. .news_2n > h2 { margin: 10px 0 10px 0;}
  2082. .onlinePlayLink {font-size: large; margin: 0 0 0 38px;}
  2083. `);
  2084. // 移除左侧右侧
  2085. if ($('.category_news_left_side,.slide_exlogo,.box_left_news.news_2n')) {
  2086. $('.category_news_left_side,.slide_exlogo,.box_left_news.news_2n').remove();
  2087. }
  2088. // 显示大预览图
  2089. let img_array = $('.news a font[size*="+1"],.news a img[alt*=".th"]');
  2090. //if (img_array.length == 0) $(doc).find('.news a img[alt*=".th"]');
  2091. img_array.toArray().forEach(e => {
  2092. let imgUrl = e.parentElement.href;
  2093. if(e.tagName === 'IMG'){
  2094. imgUrl = img_array[img_array.length - 1].src;
  2095. imgUrl = imgUrl ? imgUrl : img_array[0].dataset.src;
  2096. imgUrl = imgUrl.replace('pixhost.org', 'pixhost.to').replace('.th', '')
  2097. .replace('thumbs', 'images').replace('//t', '//img')
  2098. .replace(/[\?*\"*]/, '');
  2099. }
  2100. e.parentElement.href = "#";
  2101. e.parentElement.target = "";
  2102. e.parentElement.title = "返回顶部";
  2103. $(e.parentElement).attr("style", "display: inherit;text-align: center;");
  2104. let $img = $(`<img src="${imgUrl}" border="0">`);
  2105. $(e.parentElement).append($img);
  2106. e.parentElement.removeChild(e);
  2107. });
  2108.  
  2109. $(".boxoleft").append(`
  2110. <div class="box_left_news news_2n">
  2111. <h2><a href="javascript:void(0);">在线预览</a></h2>
  2112. <div class="onlinePlayLink">
  2113. </div>
  2114. <h2><a href="javascript:void(0);">下载</a></h2>
  2115. </div>
  2116. `);
  2117.  
  2118. // 挊
  2119. thirdparty.nong.searchMagnetRun();
  2120.  
  2121. $(".onlinePlayLink").append(`
  2122. <a href="https://njav.tv/zh/search?keyword=${$('.boxoleft .box_left_news.news_2n').attr("avid")}" target="_blank" style="color: rgb(204, 0, 0);" title="">njav&nbsp;&nbsp;</a>
  2123. <a href="https://missav.com/cn/${$('.boxoleft .box_left_news.news_2n').attr("avid")}" target="_blank" style="color: rgb(204, 0, 0);" title="此站需解封">missav&nbsp;&nbsp;</a>
  2124. <a href="https://7mmtv.tv/zh/censored_search/all/${$('.boxoleft .box_left_news.news_2n').attr("avid")}/1.html" target="_blank" style="color: rgb(204, 0, 0);" title="此站需解封">7mmtv&nbsp;&nbsp;</a>
  2125. <a href="https://supjav.com/zh/?s=${$('.boxoleft .box_left_news.news_2n').attr("avid")}" target="_blank" style="color: rgb(204, 0, 0);" title="此站需解封">supjav&nbsp;&nbsp;</a>
  2126. `);
  2127.  
  2128. Common.addBrowseJavidCache($('.name').text().match(/[a-z|A-Z|0-9| _-]+/)[0].trim());
  2129. }
  2130. }
  2131.  
  2132. static quarkScript() {
  2133. if ($('.VideoDetail--content-body--1KZ6K00').length) {
  2134. GM_addStyle(`
  2135. .DetailLayout--content--14Z28Ay {width: 100%;margin-top: auto;}
  2136. .VideoDetail--content--1LYsa87 {width: 100%;}
  2137. .VideoDetail--content-body--1KZ6K00 {height: 920px;}
  2138. .AnthologyList--anthology-list--Vlx6xtN {height: auto;}
  2139. .VideoDetail--content-header--2Cto_s7 {height: auto;padding-top: 0px;}
  2140. `);
  2141. $('.DetailLayout--header-wrap--3cP6QaP').remove();
  2142. $('.VideoDetail--content--1LYsa87').append($('.VideoDetail--content-header--2Cto_s7'));
  2143. $('.VideoDetail--content--1LYsa87').append($('.VideoDetail--content-footer--3sQbRiy'));
  2144.  
  2145. let loop = setInterval(() => {
  2146. if ($('.AnthologyList--anthology-title--1uEdKDT').length) {
  2147. $('.AnthologyList--anthology-title--1uEdKDT').remove();
  2148. clearInterval(loop);
  2149. }
  2150. }, 500);
  2151. }
  2152. }
  2153. }
  2154.  
  2155. // 第三方脚本调用
  2156. var thirdparty = {
  2157. // 登录115执行脚本,自动离线下载准备步骤
  2158. login115Run: () => {
  2159. if (domain.indexOf('115.com') >= 0) {
  2160. jav_userID = GM_getValue('jav_user_id', 0); //115用户ID缓存
  2161. //获取115ID
  2162. if (jav_userID === 0) {
  2163. if (domain.indexOf('115.com') >= 0) {
  2164. if (typeof (window.wrappedJSObject.user_id) != 'undefined') {
  2165. jav_userID = window.wrappedJSObject.user_id;
  2166. GM_setValue('jav_user_id', jav_userID);
  2167. alert('115登陆成功!');
  2168. return;
  2169. }
  2170. } else {
  2171. //alert('请先登录115账户!');
  2172. Common.notifiy("115还没有登录",
  2173. '请先登录115账户后,再离线下载!',
  2174. icon,
  2175. 'http://115.com/?mode=login'
  2176. );
  2177. GM_setValue('jav_user_id', 0);
  2178. }
  2179. }
  2180.  
  2181. if (domain.indexOf('115.com') >= 0) {
  2182. console.log('jav老司机:115.com,尝试获取userid.');
  2183. jav_userID = GM_getValue('jav_user_id', 0);
  2184. if (jav_userID !== 0) {
  2185. console.log("jav老司机: 115账号:" + jav_userID + ",无需初始化.");
  2186. return false;
  2187. }
  2188. jav_userID = $.cookie("OOFL");
  2189. console.log("jav老司机: 115账号:" + jav_userID);
  2190. if (!jav_userID) {
  2191. console.log("jav老司机: 尚未登录115账号");
  2192. return false;
  2193. } else {
  2194. console.log("jav老司机: 初始化成功");
  2195. Common.notifiy('老司机自动开车', '登陆初始化成功,赶紧上车把!', icon, "");
  2196. GM_setValue('jav_user_id', jav_userID);
  2197. }
  2198. return false;
  2199. }
  2200. }
  2201. },
  2202. // 瀑布流脚本
  2203. waterfallScrollInit: () => {
  2204. var w = new thirdparty.waterfall({});
  2205. // javbus.com、avmo.pw、avso.pw
  2206. var $pages = $('div#waterfall div.item');
  2207. if ($pages.length) {
  2208. $pages[0].parentElement.parentElement.id = "waterfall_h";
  2209. // javbus.com
  2210. if ($("footer:contains('JavBus')").length) {
  2211. w = new thirdparty.waterfall({
  2212. next: 'a#next',
  2213. item: 'div#waterfall div.item',
  2214. cont: '.masonry',
  2215. pagi: '.pagination-lg',
  2216. });
  2217. }
  2218. //avmo.pw、avso.pw
  2219. if ((/(AVMOO|AVSOX)/g).test(document.title)) {
  2220. w = new thirdparty.waterfall({
  2221. next: 'a[name="nextpage"]', //nextpage
  2222. item: 'div#waterfall div.item',
  2223. cont: '#waterfall',
  2224. pagi: '.pagination',
  2225. });
  2226. }
  2227. }
  2228. // javlibrary
  2229. var $pages2 = $('div.videos div.video');
  2230. if ($pages2.length) {
  2231. GM_addStyle(`
  2232. .videothumblist .videos .video {height: 270px;padding: 0px;margin: 4px;}
  2233. .videothumblist .videos .video .title {height: 2.8em;}
  2234. .id {height: 1.3em;overflow: hidden;}
  2235. `);
  2236. $pages2[0].parentElement.id = "waterfall";
  2237. w = new thirdparty.waterfall({
  2238. next: 'a[class="page next"]',
  2239. item: 'div.videos div.video',
  2240. cont: '#waterfall',
  2241. pagi: '.page_selector',
  2242. });
  2243. }
  2244. // onejav
  2245. var $pages3 = $('div.container div.card.mb-3');
  2246. if ($pages3.length) {
  2247. $pages3[0].parentElement.id = "waterfall";
  2248. w = new thirdparty.waterfall({
  2249. next: 'a.pagination-next.button.is-primary',
  2250. item: 'div.container div.card.mb-3',
  2251. cont: '#waterfall',
  2252. pagi: '.pagination.is-centered',
  2253. });
  2254. }
  2255.  
  2256. // javdb
  2257. var $pages4 = $(JAVDB_ITEM_SELECTOR);
  2258. if ($pages4.length) {
  2259. GM_addStyle(`
  2260. .container {max-width: inherit !important;}
  2261. .tags{display: block !important;}
  2262. .tag.hobby{display: block;float: right;color: #fff;line-height: 2em;}
  2263. `);
  2264. $pages4[0].parentElement.id = "waterfall";
  2265. w = new thirdparty.waterfall({
  2266. next: '.pagination .pagination-next',
  2267. item: JAVDB_ITEM_SELECTOR,
  2268. cont: '#waterfall',
  2269. pagi: '.pagination',
  2270. });
  2271. }
  2272.  
  2273. w.setSecondCallback((cont, elems) => {
  2274. if (location.pathname.includes('/star/') && elems) {
  2275. cont.append(elems.slice(1));
  2276. } else {
  2277. cont.append(elems);
  2278. }
  2279. });
  2280.  
  2281. // javlib脚本
  2282. w.setThirdCallback((elems) => {
  2283. // hobby mod script
  2284. let filerMonth = (indexCd_id, dateString) => {
  2285. //过滤最新X月份的影片
  2286. if ($(indexCd_id).context.URL.indexOf("bestrated.php?delete") > 0) {
  2287. if ($(indexCd_id).context.URL.indexOf("bestrated.php?deleteOneMonthAway") > 0 && !Common.isLastXMonth(dateString, 1)) {
  2288. $(indexCd_id).remove();
  2289. } else if ($(indexCd_id).context.URL.indexOf("bestrated.php?deleteTwoMonthAway") > 0 && !Common.isLastXMonth(dateString, 2)) {
  2290. $(indexCd_id).remove();
  2291. }
  2292. }
  2293. }
  2294.  
  2295. let filerScore = (indexCd_id, score) => {
  2296. //过滤X评分以下的影片 //if(vid == 'javlikq7qu')debugger;
  2297. if ($(indexCd_id).context.URL.indexOf("?delete") > 0) {
  2298. if ($(indexCd_id).context.URL.indexOf("delete7down") > 0 && score <= 7.01) {
  2299. $(indexCd_id).remove();
  2300. } else if ($(indexCd_id).context.URL.indexOf("delete8down") > 0 && score <= 8.01) {
  2301. $(indexCd_id).remove();
  2302. } else if ($(indexCd_id).context.URL.indexOf("delete9down") > 0 && score <= 9.01) {
  2303. $(indexCd_id).remove();
  2304. }
  2305. }
  2306. }
  2307.  
  2308. let setbgcolor = (indexCd_id, dateString) => {
  2309. // 如果是最近两个月份的影片标上背景色
  2310. if ($(indexCd_id).context.URL.indexOf("bestrated") > 0 && Common.isLastXMonth(dateString, 2)) {
  2311. //$(indexCd_id).css("background-color", "blanchedalmond");
  2312. $('div[class="hobby_add"]', $(indexCd_id)).css("background-color", "#ffffc9");
  2313. }
  2314. }
  2315.  
  2316. let extCode = (indexCd_id, actor, dateString, pingfengString) => {
  2317. $(indexCd_id).find(".id").append(` &nbsp;${actor}`);
  2318. let t = $(indexCd_id).find(".title").get(0); //todo v3.5.0
  2319. $(t).text().indexOf("【VR】") >= 0 ? $(t).css("background-color", "black").css("color", "white") : null;
  2320. $(indexCd_id).children("a").append(`<div class='hobby_add'style='color: red;font-size: 14px;'>
  2321. ${dateString}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${pingfengString}</div>`);
  2322. $(indexCd_id).children("a").attr("release_date", dateString);
  2323. let s = 0;
  2324. let r = Math.random() / 100;
  2325. if (pingfengString.replace(/[\\(\\)]/g, "") != '') {
  2326. s = r + parseFloat(pingfengString.replace(/[\\(\\)]/g, ""));
  2327. } else {
  2328. s = 0 + r;
  2329. }
  2330. if (s >= 10) {
  2331. s = 0.01;
  2332. }
  2333. $(indexCd_id).children("a").attr("score", s);
  2334. setbgcolor(indexCd_id, dateString);
  2335. filerMonth(indexCd_id, dateString);
  2336. filerScore(indexCd_id, s);
  2337. }
  2338.  
  2339. if (document.title.search(/JAVLibrary/) > 0 && elems) {//javlib列表
  2340. for (let i = 0; i < elems.length; i++) {
  2341. let _vid = $(elems[i]).attr("id").replace('vid_', ''); //vid_javlikd42y
  2342. // 给列表中的影片添加鼠标点击事件
  2343. $("a", $("#vid_" + _vid)).first().mousedown((event) => {
  2344. // 判断鼠标左键或中间才执行
  2345. if (event.button < 2) {
  2346. // 设置点击后填充新的背景色peachpuff
  2347. $("#vid_" + _vid).css("background-color", "#ffe7d3");
  2348. }
  2349. });
  2350. let indexCd_id, actor, dateString, pingfengString;
  2351. let code = $(elems[i]).find('.id').text();
  2352. // 查找影片是否存在我浏览过的MyMovie表中
  2353. let prom = javDb.select().from(myMovie).
  2354. where(lf.op.and(myMovie.is_browse.eq(true), myMovie.index_cd.eq(_vid))).exec();
  2355. prom.then(results => {
  2356. //let promise1 = Promise.resolve();
  2357. //return new Promise(resolve => {
  2358. if (results.length != 0) { //存在MyMovie表中
  2359. indexCd_id = "#vid_" + results[0].index_cd;
  2360. if ($(indexCd_id).context.URL.indexOf("bestrated.php?filterMyBrowse") > 0) {
  2361. $(indexCd_id).remove();
  2362. } else {
  2363. $(indexCd_id).css("background-color", "#ffe7d3"); //hotpink,khaki,indianred,peachpuff
  2364. if (results.length != 0 && results[0].is_sync) { //已经同步过
  2365. extCode(indexCd_id, results[0].actor, results[0].release_date, results[0].score);
  2366. } else { //未同步过
  2367. getMovieInfo(true);
  2368. }
  2369. Common.addBrowseJavidCache(code);
  2370. }
  2371. }
  2372. else if (Common.browseJavidHasCache(code)) { //纯正GM缓存中
  2373. getMovieInfo(true);
  2374. }
  2375. else { //都不存在
  2376. getMovieInfo(false);
  2377. }
  2378.  
  2379. function getMovieInfo(isSave) {
  2380. let promise1 = Common.request(location.origin + "/ja/?v=" + _vid);
  2381. promise1.then((result) => {
  2382. indexCd_id = "#vid_" + result.finalUrl.split("=")[1]; //例如:http://www.j12lib.com/cn/?v=javlikd42a
  2383. let doc = result.responseText;
  2384. let movie_info = doc.substring(doc.search(/<table id="video_jacket_info">/),
  2385. doc.search(/<div id="video_favorite_edit" class="">/));
  2386. // 阻止构造Document对象时加载src内容
  2387. movie_info = movie_info.replace("src", "hobbysrc");
  2388. let $doc = $(Common.parsetext(movie_info));
  2389. actor = $('#video_cast .text', $doc).text();
  2390. dateString = $('#video_date .text', $doc).text();
  2391. pingfengString = $('#video_review .text .score', $doc).text();
  2392. extCode(indexCd_id, actor, dateString, pingfengString);
  2393. // todo 1118
  2394. if (isSave) Jav.syncMovie(result);
  2395. return Promise.resolve();
  2396. });
  2397. }
  2398. });
  2399. }
  2400. }
  2401. });
  2402.  
  2403. w.setFourthCallback((elems) => { // todo 20190404
  2404. if (document.title.search(/OneJAV/) > 0 && elems) {
  2405. // 增加对应所有番号的Javlib的跳转链接,
  2406. for (let index = 0; index < elems.length; index++) {
  2407. let aEle = $(elems[index]).find("h5.title.is-4.is-spaced a")[0];
  2408. let avid = $(aEle).text().replace(/[ ]/g, "").replace(/[\r\n]/g, "") //去掉空格//去掉回车换行
  2409. let avcd = avid;
  2410. if (!(/(-)/g).test(avid)) {
  2411. avcd = Common.getAvCode(avid);
  2412. }
  2413. //修改样式
  2414. $(aEle.parentElement.parentElement).attr("style", "flex-direction: column;");
  2415. if (!(/^FC2-/g).test(avid)) {
  2416. // Javlib的跳转链接
  2417. $(aEle.parentElement).append(`<a style='color:red;' href='https://${GM_getValue('javlib_url')}/cn/vl_searchbyid.php?keyword=` +
  2418. avcd + "&" + avid + "' target='_blank' title='点击到Javlib看看'>&nbsp;&nbsp;Javlib</a>");
  2419. }
  2420. // 番号预览大图
  2421. Common.addAvImg(avcd, ($img) => {
  2422. let divEle = $(elems[index]).find("div.column.is-5")[0];
  2423. if (divEle) {
  2424. $(divEle).append($img);
  2425. }
  2426. }, false);
  2427. }
  2428. }
  2429.  
  2430. if (((/(JavBus|AVMOO|AVSOX)/g).test(document.title) || $("footer:contains('JavBus')").length) && elems) {
  2431. if (location.pathname.search('/searchstar|/actresses|/&mdl=favor&sort=4') < 0) { //排除actresses页面
  2432. // 处理列表文字内容排版
  2433. for (let i = 0; i < elems.length; i++) {
  2434. //$(elems[i]).css("height","385px");
  2435. if ($(elems[i]).find("div.avatar-box").length > 0) continue;
  2436. let spanEle = $(elems[i]).find("div.photo-info span")[0];
  2437. let t1 = $(spanEle).html().substr($(spanEle).html().indexOf("<br>") + 4);
  2438. let t2 = $(spanEle).html().substr(0, $(spanEle).html().indexOf("<br>"));
  2439. $(spanEle).html(t1 + "<br>" + t2);
  2440. // 已阅番号标色
  2441. if (Common.browseJavidHasCache($(elems[i]).find(".photo-info>span>date:eq(0)").text())) {
  2442. $(elems[i]).find(".movie-box").css("background-color", "#ffe7d3");
  2443. }
  2444. // 给列表中的影片添加鼠标点击事件
  2445. $("a", $(elems[i])).first().mousedown((event) => {
  2446. // 判断鼠标左键或中间才执行
  2447. if (event.button < 2) {
  2448. // 设置点击后填充新的背景色peachpuff
  2449. $(elems[i]).find(".movie-box").css("background-color", "#ffe7d3");
  2450. }
  2451. });
  2452. }
  2453. }
  2454. }
  2455.  
  2456. // javdb列表内容排版处理
  2457. if ((/(JavDB)/g).test(document.title) && elems) {
  2458. elems.toArray().forEach(e => {
  2459. //移除新种标签
  2460. $(e).find(".tags.has-addons span:not(.tag.is-success,.tag.is-warning)").remove();
  2461. if ($(e).find(".tag.is-warning").length) {
  2462. $(e).find(".tag.is-warning").text("含中字");
  2463. }
  2464. let $div = $(e).find(".tags.has-addons").eq(0);
  2465. let avid = $(e).find(".video-title strong").text();
  2466.  
  2467. if (!$div.children().length) {
  2468. $div.append(`<span class="tag is-success" style="background-color:#fff;">.</span>`);
  2469. }
  2470. if (!$("#waterfall").hasClass("v cols-4 vcols-8")) {
  2471. $div.append(`
  2472. <a title="可忽略" href="https://${GM_getValue('avsox_url')}/cn/search/${avid}" target="_blank">
  2473. <span class="tag hobby" style="margin-right: 5px;background-color:#bf9be6;display:none;">avsox</span>
  2474. </a>
  2475. <a title="无码 JAV资源站" href="https://${GM_getValue('javbus_url')}/${avid}" target="_blank">
  2476. <span class="tag hobby" style="margin-right: 5px;background-color:#febe00;">JavBus</span>
  2477. </a>
  2478. <a title="有码 JAV资源站" href="https://${GM_getValue('javlib_url')}/cn/vl_searchbyid.php?keyword=${avid}" target="_blank">
  2479. <span class="tag hobby" style="margin-right: 0px;background-color:#f908bb;">JavLib</span>
  2480. </a>
  2481. <a title="FC2 JAV资源站" href="${Common.getOneJavSearchUrl(avid)}" target="_blank">
  2482. <span class="tag hobby" style="margin-right: 3px;background-color:#00d1b2;">OneJav</span>
  2483. </a>
  2484. `);
  2485. let $a = $(`
  2486. <a title="素人 JAV资源站" href="javascript:void(0);">
  2487. <span class="tag hobby" style="margin-right: 0px;background-color:#418fa7;">Jav321</span>
  2488. </a>
  2489. `);
  2490. $div.append(Common.jav321LinkMousedown($a, avid));
  2491.  
  2492. let $b = $(`
  2493. <a title="综合 JAV资源站" href="javascript:void(0);">
  2494. <span class="tag hobby" style="margin-right: 0px;background-color:#ad1d18;">JavStore</span>
  2495. </a>
  2496. `);
  2497. $div.append(Common.javstoreLinkMousedown($b, avid));
  2498.  
  2499. // 提取评分数、评分人数
  2500. $(e).attr("score", $(e).find('.score>span').text().split('分, 由')[0].trim());
  2501. $(e).attr("usernum", $(e).find('.score>span').text().split('分, 由')[1].replace("人評價", ""));
  2502. // 已阅番号标色
  2503. if (Common.browseJavidHasCache(avid)) $(e).find(".video-title,.score").css("background-color", "#ffe7d3");
  2504. }
  2505. });
  2506. }
  2507.  
  2508. });
  2509.  
  2510. if ((/(JavBus|AVMOO|AVSOX)/g).test(document.title) || $("footer:contains('JavBus')").length) {
  2511. // javbus.com、avmo.pw、avso.pw 样式
  2512. GM_addStyle(`
  2513. #waterfall_h {height: initial !important;width: initial !important;flex-direction: row;flex-wrap: wrap;margin: 5px 15px !important;}
  2514. #waterfall_h .item {position: relative !important;top: initial !important;left: initial !important;float: left;}
  2515. #waterfall_h .movie-box img {position: absolute; top: -200px; bottom: -200px; left: -200px; right: -200px; margin: auto;}
  2516. #waterfall_h .movie-box .photo-frame {position: relative;} #waterfall_h .avatar-box .photo-info p {margin: 0 0 2px;}
  2517. #waterfall_h .avatar-box .photo-info {line-height: 15px; padding: 6px;height: 220px;}
  2518. #waterfall_h .avatar-box .photo-frame {margin: 10px;text-align: center;}
  2519. #waterfall_h .avatar-box.text-center {height: 195px;}//actresses页面
  2520. `);
  2521.  
  2522. if ($('#waterfall').length == 0 && location.pathname.search(/search/) > 0 &&
  2523. location.pathname.search(/uncensored/) < 1) {
  2524. window.location.href = $('li[role="presentation"]:eq(1) a').attr("href");
  2525. }
  2526.  
  2527. if (location.pathname.includes('/uncensored') || location.hostname.includes('javbus.org') || (/(AVSOX)/g).test(document.title)) {
  2528. GM_addStyle(`#waterfall_h .movie-box {width: 354px;} #waterfall_h .movie-box .photo-info {height: 105px;}`);
  2529. } else {
  2530. GM_addStyle(`#waterfall_h .movie-box {width: 167px;} #waterfall_h .movie-box .photo-info {height: 145px;}`);
  2531. }
  2532. }
  2533. },
  2534. // 瀑布流脚本
  2535. waterfall: (() => {
  2536. function waterfall(selectorcfg = {}) {
  2537. // 瀑布流脚本使用类
  2538. class Lock {
  2539. constructor(d = false) {
  2540. this.locked = d;
  2541. }
  2542. lock() {
  2543. this.locked = true;
  2544. }
  2545. unlock() {
  2546. this.locked = false;
  2547. }
  2548. }
  2549. this.lock = new Lock();
  2550. this.baseURI = this.getBaseURI();
  2551. this.selector = {
  2552. next: 'a.next',
  2553. item: '',
  2554. cont: '#waterfall', //container
  2555. pagi: '.pagination',
  2556. };
  2557. Object.assign(this.selector, selectorcfg);
  2558. this.pagegen = this.fetchSync(location.href);
  2559. this.anchor = $(this.selector.pagi)[0];
  2560. this._count = 0;
  2561. this._1func = (cont, elems) => {
  2562. cont.empty().append(elems);
  2563. };
  2564. this._2func = (cont, elems) => {
  2565. cont.append(elems);
  2566. };
  2567. this._3func = (elems) => { };
  2568. if ($(this.selector.item).length) {
  2569. // 开启关闭瀑布流判断
  2570. if (waterfallScrollStatus > 0) {
  2571. document.addEventListener('scroll', this.scroll.bind(this));
  2572. document.addEventListener('wheel', this.wheel.bind(this));
  2573. }
  2574. this.appendElems(this._1func);
  2575. }
  2576. }
  2577.  
  2578. waterfall.prototype.getBaseURI = () => {
  2579. let _ = location;
  2580. return `${_.protocol}//${_.hostname}${(_.port && `:${_.port}`)}`;
  2581. };
  2582. waterfall.prototype.getNextURL = function (href) {
  2583. let a = document.createElement('a');
  2584. a.href = href;
  2585. return `${this.baseURI}${a.pathname}${a.search}`;
  2586. };
  2587. // 瀑布流脚本
  2588. waterfall.prototype.fetchURL = function (url) {
  2589. console.log(`fetchUrl = ${url}`);
  2590. const fetchwithcookie = fetch(url, { credentials: 'same-origin' });
  2591. return fetchwithcookie.then(response => response.text())
  2592. .then(html => new DOMParser().parseFromString(html, 'text/html'))
  2593. .then(doc => {
  2594. let $doc = $(doc);
  2595. let href = $doc.find(this.selector.next).attr('href');
  2596. let nextURL = href ? this.getNextURL(href) : undefined;
  2597. let elems = $doc.find(this.selector.item);
  2598. for (const elem of elems) {
  2599. const links = elem.getElementsByTagName('a');
  2600. for (const link of links) {
  2601. link.target = "_blank";
  2602. }
  2603. }
  2604. // javdb列表 bug:一直有最后一页 console.log(`1 ${url}`);console.log(`2 ${nextURL}`);
  2605. if ($(JAVDB_ITEM_SELECTOR).length && (this._count !== 0) && url === nextURL) {
  2606. if ($(`#waterfall>div>a[href="${$(elems[0]).find('a.box')[0].attr('href')}"]`).length > 0) {
  2607. nextURL = undefined;
  2608. elems = [];
  2609. }
  2610. }
  2611. return {
  2612. nextURL,
  2613. elems
  2614. };
  2615. });
  2616. };
  2617. // 瀑布流脚本
  2618. waterfall.prototype.fetchSync = function* (urli) {
  2619. let url = urli;
  2620. do {
  2621. yield new Promise((resolve, reject) => {
  2622. if (this.lock.locked) {
  2623. reject();
  2624. }
  2625. else {
  2626. this.lock.lock();
  2627. resolve();
  2628. }
  2629. }).then(() => {
  2630. return this.fetchURL(url).then(info => {
  2631. url = info.nextURL;
  2632. return info.elems;
  2633. });
  2634. }).then(elems => {
  2635. this.lock.unlock();
  2636. return elems;
  2637. }).catch((err) => {
  2638. // Locked!
  2639. });
  2640. } while (url);
  2641. };
  2642. // 瀑布流脚本
  2643. waterfall.prototype.appendElems = function () {
  2644. let nextpage = this.pagegen.next();
  2645. if (!nextpage.done) {
  2646. nextpage.value.then(elems => {
  2647. const cb = (this._count === 0) ? this._1func : this._2func;
  2648. cb($(this.selector.cont), elems);
  2649. this._count += 1;
  2650. // hobby mod script
  2651. this._3func(elems);
  2652. this._4func(elems);
  2653. });
  2654. }
  2655. return nextpage.done;
  2656. };
  2657. // 瀑布流脚本
  2658. waterfall.prototype.end = function () {
  2659. document.removeEventListener('scroll', this.scroll.bind(this));
  2660. document.removeEventListener('wheel', this.wheel.bind(this));
  2661. let $end = $(`<h1>The End</h1>`);
  2662. $(this.anchor).replaceWith($end);
  2663. };
  2664. waterfall.prototype.reachBottom = function (elem, limit) {
  2665. return (elem.getBoundingClientRect().top - $(window).height()) < limit;
  2666. };
  2667. waterfall.prototype.scroll = function () {
  2668. if (this.reachBottom(this.anchor, 500) && this.appendElems(this._2func)) {
  2669. this.end();
  2670. }
  2671. };
  2672. waterfall.prototype.wheel = function () {
  2673. if (this.reachBottom(this.anchor, 1000) && this.appendElems(this._2func)) {
  2674. this.end();
  2675. }
  2676. };
  2677. waterfall.prototype.setFirstCallback = function (f) {
  2678. this._1func = f;
  2679. };
  2680. waterfall.prototype.setSecondCallback = function (f) {
  2681. this._2func = f;
  2682. };
  2683. waterfall.prototype.setThirdCallback = function (f) {
  2684. this._3func = f;
  2685. };
  2686. waterfall.prototype.setFourthCallback = function (f) {
  2687. this._4func = f;
  2688. };
  2689. return waterfall;
  2690. })(),
  2691. // 挊
  2692. nong: {
  2693. main: {
  2694. //av信息查询类
  2695. //avsox|avmoo
  2696. jav: {
  2697. type: 0,
  2698. re: /.*movie.*/,
  2699. vid: () => {
  2700. return $('.header_hobby')[0].nextElementSibling.getAttribute("avid");
  2701. },
  2702. proc: (main) => {
  2703. var divE = $("div[class='col-md-3 info']")[0];
  2704. $(divE).after(main.cur_tab);
  2705. }
  2706. },
  2707. javbus: {
  2708. type: 0,
  2709. re: /(jav|bus|dmm|see|cdn|fan){2}\./g,
  2710. vid: () => {
  2711. var a = $('.header_hobby')[0].nextElementSibling;
  2712. return a ? a.getAttribute("avid") : '';
  2713. },
  2714. proc: (main) => {
  2715. var divE = $("div[class='col-md-3 info']")[0];
  2716. $(divE).after(main.cur_tab);
  2717. }
  2718. },
  2719. javlibrary: {
  2720. type: 0,
  2721. re: /.*\?v=jav.*/,
  2722. vid: () => {
  2723. let avid = $('#video_id')[0].getElementsByClassName('text')[0].getAttribute("avid");
  2724. return Common.getAvCode(avid);
  2725. },
  2726. proc: (main) => {
  2727. //去十八岁警告
  2728. Common.setCookie("over18", 18);
  2729. $('.socialmedia').remove();
  2730. GM_addStyle(`
  2731. #video_info {text-align: left;font: 14px Arial;min-width: 230px;max-width: 260px;padding: 0px 0px 0px 0px;}
  2732. #video_jacket_info {overflow: hidden;} //table-layout: fixed;
  2733. #coverimg {vertical-align: top;overflow: hidden;max-width: 50%;}
  2734. #javtext {vertical-align: top;width: 260px;}
  2735. #video_info td.header {width: 75px;}
  2736. #video_info td.icon {width: 0px;}
  2737. #content {padding-top: 0px;}
  2738. #video_info table {margin-top: 6px;border-bottom: 1px solid #ffffff;}
  2739. `);
  2740.  
  2741. var tdE = $("td[style='vertical-align: top;']")[0];
  2742. tdE.id = "coverimg";
  2743. $("td[style='vertical-align: top;']")[1].id = 'javtext';
  2744. $('#leftmenu').remove();
  2745. $('#rightcolumn').attr("style", "margin: 0px 0px 0px 0px;width: 100%;padding: initial;");
  2746. $(tdE.parentElement).append('<td id="hobby" style="vertical-align: top;"></td>');
  2747. $('#hobby').append(main.cur_tab);
  2748. }
  2749. },
  2750. javstore: {
  2751. type: 0,
  2752. re: /.*javstore.*/,
  2753. vid: () => {
  2754. if (GM_getValue(document.URL, false)) {
  2755. let avid = GM_getValue(document.URL);
  2756. GM_deleteValue(document.URL);
  2757. $('.boxoleft .box_left_news.news_2n').attr("avid", avid);
  2758. return avid;
  2759. } else {
  2760. let $ele = $('.boxoleft .box_left_news.news_2n').attr("avid", $('.name').text().match(/[a-z|A-Z|0-9| _-]+/)[0].trim());
  2761. return $ele.attr('avid');
  2762. }
  2763. },
  2764. proc: (main) => {
  2765. $('.boxoleft .box_left_news.news_2n').append(main.cur_tab);
  2766. }
  2767. },
  2768. },
  2769. resource_sites: {
  2770. [GM_getValue('javdb_url')]: (kw, cb) => {
  2771. let promise = Common.request("https://" + GM_getValue('search_index') + "/search?f=download&q=" + kw, "https://" + GM_getValue('search_index') + "/");
  2772. promise.then((result) => {
  2773. let data = [];
  2774. return new Promise((resolve, reject) => {
  2775. thirdparty.nong.search_engines.full_url = result.finalUrl;
  2776. let doc = Common.parsetext(result.responseText);
  2777. let a = $(doc).find(`.box .video-title:contains('${kw.toUpperCase().replace("+", "-")}')`);
  2778. if (a) {
  2779. resolve(a[0].parentElement.href.replace(location.origin, 'https://' + [GM_getValue('javdb_url')]));
  2780. }
  2781. else {
  2782. reject();
  2783. }
  2784. }).then(url => {
  2785. Common.request(url).then(result => {
  2786. thirdparty.nong.search_engines.full_url = result.finalUrl;
  2787. let doc = Common.parsetext(result.responseText);
  2788. let t = $(doc).find('#magnets-content .item');
  2789. if (t) {
  2790. for (let elem of t) {
  2791. data.push({
  2792. "title": elem.querySelector(".magnet-name span:nth-child(1)").textContent,
  2793. "maglink": elem.querySelector(".magnet-name a:nth-child(1)").href,
  2794. "size": elem.querySelector(".magnet-name .meta") ? elem.querySelector(".magnet-name .meta").textContent : "",
  2795. "src": result.finalUrl,
  2796. });
  2797. }
  2798. }
  2799. else {
  2800. data.push({
  2801. "title": "没有找到磁链接",
  2802. "maglink": "",
  2803. "size": "0",
  2804. "src": result.finalUrl,
  2805. });
  2806. }
  2807. cb(result.finalUrl, data);
  2808. })
  2809. }).catch(() => {
  2810. data.push({
  2811. "title": "没有找到磁链接",
  2812. "maglink": "",
  2813. "size": "0",
  2814. "src": result.finalUrl,
  2815. });
  2816. cb(result.finalUrl, data);
  2817. });
  2818. });
  2819. },
  2820. [GM_getValue('btsow_url')]: (kw, cb) => {
  2821. let promise = Common.request("https://" + GM_getValue('search_index') + "/search/" + kw);
  2822. promise.then((result) => {
  2823. thirdparty.nong.search_engines.full_url = result.finalUrl;
  2824. var doc = Common.parsetext(result.responseText);
  2825. if (!doc) {
  2826. thirdparty.nong.search_engines.parse_error(GM_getValue('search_index'));
  2827. }
  2828. var data = [];
  2829. var t = doc.getElementsByClassName('data-list')[0];
  2830. if (t) {
  2831. var a = t.getElementsByTagName('a');
  2832. for (var i = 0; i < a.length; i++) {
  2833. if (!a[i].className.match('btn')) {
  2834. data.push({
  2835. 'title': a[i].title,
  2836. 'maglink': 'magnet:?xt=urn:btih:' + a[i].outerHTML.replace(/.*hash\//, '').replace(/" .*\n.*\n.*\n.*/, ''),
  2837. 'size': a[i].nextElementSibling.textContent,
  2838. 'src': a[i].href,
  2839. });
  2840. }
  2841. }
  2842. }
  2843. cb(result.finalUrl, data);
  2844. });
  2845. },
  2846. [GM_getValue('btdig_url')]: (kw, cb) => {
  2847. let promise = Common.request("https://" + GM_getValue('search_index') + "/search?q=" + kw);
  2848. promise.then((result) => {
  2849. thirdparty.nong.search_engines.full_url = result.finalUrl;
  2850. let doc = Common.parsetext(result.responseText);
  2851. let data = [];
  2852. let t = doc.querySelectorAll("div.one_result");
  2853. if (t) {
  2854. for (let elem of t) {
  2855. data.push({
  2856. "title": elem.querySelector(".torrent_name a").textContent,
  2857. "maglink": elem.querySelector(".fa.fa-magnet a").href,
  2858. "size": elem.querySelector(".torrent_size").textContent,
  2859. "src": elem.querySelector(".torrent_name a").href,
  2860. });
  2861. }
  2862. }
  2863. else {
  2864. data.push({
  2865. "title": "没有找到磁链接",
  2866. "maglink": "",
  2867. "size": "0",
  2868. "src": result.finalUrl,
  2869. });
  2870. }
  2871. cb(result.finalUrl, data);
  2872. });
  2873. },
  2874. [GM_getValue('nyaa_url')]: (kw, cb) => {
  2875. let promise = Common.request("https://" + GM_getValue('search_index') + "/?f=0&c=0_0&q=" + kw);
  2876. promise.then((result) => {
  2877. thirdparty.nong.search_engines.full_url = result.finalUrl;
  2878. let doc = Common.parsetext(result.responseText);
  2879. if (!doc) {
  2880. thirdparty.nong.search_engines.parse_error(GM_getValue('search_index'));
  2881. }
  2882. let data = [];
  2883. let t = doc.querySelectorAll("tr.default,tr.success");
  2884. if (t.length !== 0) {
  2885. for (let elem of t) {
  2886. data.push({
  2887. "title": elem.querySelector("td:nth-child(2)>a:nth-child(1)").title,
  2888. "maglink": elem.querySelector("td:nth-child(3)>a:nth-last-child(1)").href,
  2889. //"torrent_url": "https://nyaa.si" + elem.querySelector("td:nth-child(3)>a:nth-child(1)").href,
  2890. "size": elem.querySelector("td:nth-child(4)").textContent,
  2891. "src": "https://" + [GM_getValue('nyaa_url')]
  2892. + elem.querySelector("td:nth-child(2)>a:nth-child(1)").getAttribute('href'),
  2893. });
  2894. }
  2895. }
  2896. cb(result.finalUrl, data);
  2897. });
  2898. },
  2899. [GM_getValue('torrentkitty_url')]: (kw, cb) => {
  2900. let promise = Common.request("https://" + GM_getValue('search_index') + "/search/" + kw);
  2901. promise.then((result) => {
  2902. thirdparty.nong.search_engines.full_url = result.finalUrl;
  2903. let doc = Common.parsetext(result.responseText);
  2904. let data = [];
  2905. let t = $(doc).find("#archiveResult tr:gt(0)");
  2906. if (t) {
  2907. for (let elem of t) {
  2908. if ((/(No result)/g).test(elem.querySelector(".name").textContent))
  2909. break;
  2910. data.push({
  2911. "title": elem.querySelector(".name").textContent,
  2912. "maglink": elem.querySelector(".action>a:nth-child(2)").href,
  2913. "size": elem.querySelector(".size").textContent,
  2914. "src": "https://" + [GM_getValue('torrentkitty_url')] + elem.querySelector(".action>a:nth-child(1)").getAttribute('href'),
  2915. });
  2916. }
  2917. }
  2918. else {
  2919. data.push({
  2920. "title": "没有找到磁链接",
  2921. "maglink": "",
  2922. "size": "0",
  2923. "src": result.finalUrl,
  2924. });
  2925. }
  2926. cb(result.finalUrl, data);
  2927. });
  2928. },
  2929. },
  2930. offline_sites: {
  2931. 115: {
  2932. name: '115离线',
  2933. url: 'http://115.com/?tab=offline&mode=wangpan',
  2934. enable: true,
  2935. },
  2936. },
  2937. // 挊
  2938. search_engines: {
  2939. switch_engine: (i) => {
  2940. // var index = GM_getValue("search_index",0);
  2941. GM_setValue('search_index', i);
  2942. return i;
  2943. },
  2944. cur_engine: (kw, cb) => {
  2945. let ops = Object.keys(thirdparty.nong.resource_sites);
  2946. let z = thirdparty.nong.resource_sites[GM_getValue('search_index', ops[0])];
  2947. if (!z) {
  2948. //alert("search engine not found");
  2949. GM_setValue('search_index', Object.keys(thirdparty.nong.resource_sites)[0]);
  2950. z = thirdparty.nong.resource_sites[GM_getValue('search_index')];
  2951. }
  2952. return z(kw, cb);
  2953. },
  2954. parse_error: (a) => {
  2955. alert("调用搜索引擎错误,可能需要更新,请向作者反馈。i=" + a);
  2956. },
  2957. full_url: '',
  2958.  
  2959. },
  2960. // 挊
  2961. magnet_table: {
  2962. template: {
  2963. create_head: () => {
  2964. var a = document.createElement('tr');
  2965. a.className = 'jav-nong-row';
  2966. a.id = 'jav-nong-head';
  2967. var list = ['标题', '大小', '操作', '离线下载'];
  2968. for (var i = 0; i < list.length; i++) {
  2969. var b = thirdparty.nong.magnet_table.template.head.cloneNode(true);
  2970. if (i === 0) {
  2971. var select = document.createElement("select");
  2972. var ops = Object.keys(thirdparty.nong.resource_sites); // todo 181225
  2973. var cur_index = GM_getValue("search_index", ops[0]);
  2974. for (var j = 0; j < ops.length; j++) {
  2975. var op = document.createElement("option");
  2976. op.value = ops[j];
  2977. op.textContent = ops[j];
  2978. if (cur_index == ops[j]) {
  2979. op.setAttribute("selected", "selected");
  2980. }
  2981. select.appendChild(op);
  2982. }
  2983. b.removeChild(b.firstChild);
  2984. b.appendChild(select);
  2985. let a3 = document.createElement('a');
  2986. $(a3).append('&nbsp;修改&nbsp;')
  2987. $(a3).css({
  2988. "color": "blue",
  2989. "font": "bold 12px monospace"
  2990. });
  2991. $(a3).attr("href", "#");
  2992. $(a3).click(() => {
  2993. Common.openSystemConfig();
  2994. });
  2995. b.append(a3);
  2996. a.appendChild(b);
  2997. continue;
  2998. }
  2999. b.firstChild.textContent = list[i];
  3000. a.appendChild(b);
  3001. }
  3002. // var select_box = this.create_select_box();
  3003. // a.firstChild.appendChild(select_box);
  3004.  
  3005. return a;
  3006. },
  3007. create_row: (data) => {
  3008. var a = document.createElement('tr');
  3009. a.className = 'jav-nong-row';
  3010. a.setAttribute('maglink', data.maglink);
  3011. // 暂时针对cnbtkitty.pw站点生效。
  3012. if (data.maglink.indexOf("#magnetlink") > -1) {
  3013. a.setAttribute('id', data.id);
  3014. let promise1 = Common.request(data.maglink + "?hobbyId=" + data.id);// 传递修改hobbyId,用于修改时定位。
  3015. promise1.then((result) => {
  3016. //定位磁链编码开始下标位置
  3017. let indexNum = result.responseText.indexOf('#website#infohash#');
  3018. if (indexNum >= 0) {
  3019. let magnetlink = result.responseText.substring(indexNum + 18, indexNum + 58);
  3020. let hobbyId = result.finalUrl.substring(result.finalUrl.indexOf('?hobbyId=') + 9, result.finalUrl.length);
  3021. $("#" + hobbyId).attr("maglink", "magnet:?xt=urn:btih:" + magnetlink);
  3022. }
  3023. });
  3024. }
  3025.  
  3026. var b = document.createElement('td');
  3027. var list = [
  3028. thirdparty.nong.magnet_table.template.create_info(data.title, data.maglink),
  3029. thirdparty.nong.magnet_table.template.create_size(data.size, data.src),
  3030. thirdparty.nong.magnet_table.template.create_operation(data.maglink),
  3031. thirdparty.nong.magnet_table.template.create_offline()
  3032. ];
  3033. for (var i = 0; i < list.length; i++) {
  3034. var c = b.cloneNode(true);
  3035. c.appendChild(list[i]);
  3036. a.appendChild(c);
  3037. }
  3038. return a;
  3039. },
  3040. create_loading: () => {
  3041. var a = document.createElement('tr');
  3042. a.className = 'jav-nong-row';
  3043. var p = document.createElement('p');
  3044. p.textContent = 'Loading';
  3045. p.id = 'notice';
  3046. a.appendChild(p);
  3047. return a;
  3048. },
  3049. create_info: (title, maglink) => {
  3050. var a = thirdparty.nong.magnet_table.template.info.cloneNode(true);
  3051. a.firstChild.textContent = title.length < 20 ? title : title.substr(0, 20) + '...';
  3052. a.firstChild.href = maglink;
  3053. a.title = title;
  3054. return a;
  3055. },
  3056. create_size: (size, src) => {
  3057. var a = thirdparty.nong.magnet_table.template.size.cloneNode(true);
  3058. a.textContent = size;
  3059. a.href = src;
  3060. return a;
  3061. },
  3062. create_operation: (maglink) => {
  3063. var a = thirdparty.nong.magnet_table.template.operation.cloneNode(true);
  3064. a.firstChild.href = maglink;
  3065. return a;
  3066. },
  3067. create_offline: () => { //有用 hobby
  3068. var a = thirdparty.nong.magnet_table.template.offline();
  3069. a.className = 'nong-offline';
  3070. return a;
  3071. },
  3072. create_select_box: () => {
  3073. var select_box = document.createElement('select');
  3074. select_box.id = 'nong-search-select';
  3075. select_box.setAttribute('title', '切换搜索结果');
  3076. var search_name = GM_getValue('search', default_search_name);
  3077. for (var k in thirdparty.nong.search_engines) {
  3078. var o = document.createElement('option');
  3079. if (k == search_name) {
  3080. o.setAttribute('selected', 'selected');
  3081. }
  3082. o.setAttribute('value', k);
  3083. o.textContent = k;
  3084. select_box.appendChild(o);
  3085. }
  3086. return select_box;
  3087. },
  3088. head: (() => {
  3089. var a = document.createElement('th');
  3090. var b = document.createElement('a');
  3091. a.appendChild(b);
  3092. return a;
  3093. })(),
  3094. info: (() => {
  3095. var a = document.createElement('div');
  3096. var b = document.createElement('a');
  3097. b.textContent = 'name';
  3098. b.href = 'src';
  3099. a.appendChild(b);
  3100. return a;
  3101. })(),
  3102. size: (() => {
  3103. var a = document.createElement('a');
  3104. a.textContent = 'size';
  3105. return a;
  3106. })(),
  3107. operation: (() => {
  3108. var a = document.createElement('div');
  3109. var copy = document.createElement('a');
  3110. copy.className = 'nong-copy';
  3111. copy.textContent = '复制';
  3112. a.appendChild(copy);
  3113. return a;
  3114. })(),
  3115. offline: () => {
  3116. var a = document.createElement('div');
  3117. var b = document.createElement('a');
  3118. b.className = 'nong-offline-download';
  3119. b.target = '_blank';
  3120. for (var k in thirdparty.nong.offline_sites) {
  3121. if (thirdparty.nong.offline_sites[k].enable) {
  3122. var c = b.cloneNode(true);
  3123. c.href = thirdparty.nong.offline_sites[k].url;
  3124. c.textContent = thirdparty.nong.offline_sites[k].name;
  3125. a.appendChild(c);
  3126. }
  3127. }
  3128. return a;
  3129. },
  3130. },
  3131. create_empty_table: () => { //有用 hobby
  3132. var a = document.createElement('table');
  3133. a.id = 'nong-table-new';
  3134. return a;
  3135. },
  3136. updata_table: (src, data, type) => {
  3137. if (type == 'full') {
  3138. var tab = $('#nong-table-new')[0];
  3139. tab.removeChild(tab.querySelector("#notice").parentElement);
  3140. for (var i = 0; i < data.length; i++) {
  3141. tab.appendChild(thirdparty.nong.magnet_table.template.create_row(data[i]));
  3142. }
  3143. }
  3144. thirdparty.nong.magnet_table.reg_event();
  3145. },
  3146. full: (src, data) => {
  3147. var tab = thirdparty.nong.magnet_table.create_empty_table();
  3148. tab.appendChild(thirdparty.nong.magnet_table.template.create_head());
  3149. var loading = thirdparty.nong.magnet_table.template.create_loading();
  3150. tab.appendChild(loading);
  3151. return tab;
  3152. },
  3153. handle_event: (event) => {
  3154. var maglink = event.target.parentElement.parentElement.getAttribute('maglink')
  3155. || event.target.parentElement.parentElement.parentElement.getAttribute('maglink');
  3156. if (event.target.className == 'nong-copy') {
  3157. event.target.innerHTML = '成功';
  3158. maglink = maglink.substr(0, 60);
  3159. GM_setClipboard(maglink);
  3160. setTimeout(() => {
  3161. event.target.innerHTML = '复制';
  3162. }, 1000);
  3163. event.preventDefault(); //阻止跳转
  3164. }
  3165. else if (event.target.className == 'nong-offline-download') {
  3166. maglink = maglink.substr(0, 60);
  3167. GM_setValue('magnet', maglink);
  3168. //获取115 token接口
  3169. let promise = Common.request('http://115.com/?ct=offline&ac=space&_=' + new Date().getTime());
  3170. promise.then((responseDetails) => {
  3171. if (responseDetails.responseText.indexOf('html') >= 0) {
  3172. //未登录处理
  3173. Common.notifiy("115还没有登录",
  3174. '请先登录115账户后,再离线下载!',
  3175. icon,
  3176. 'http://115.com/?mode=login'
  3177. );
  3178. return false;
  3179. }
  3180. var sign115 = JSON.parse(responseDetails.response).sign;
  3181. var time115 = JSON.parse(responseDetails.response).time;
  3182. console.log("uid=" + jav_userID + " sign:" + sign115 + " time:" + time115);
  3183. console.log("rsp:" + responseDetails.response);
  3184. GM_xmlhttpRequest({
  3185. method: 'POST',
  3186. url: 'http://115.com/web/lixian/?ct=lixian&ac=add_task_url', //添加115离线任务接口
  3187. headers: {
  3188. "Content-Type": "application/x-www-form-urlencoded"
  3189. },
  3190. data: "url=" + encodeURIComponent(maglink) + "&uid=" + jav_userID + "&sign=" + sign115
  3191. + "&time=" + time115,
  3192. onload: (responseDetails) => {
  3193. var lxRs = JSON.parse(responseDetails.responseText); //离线结果
  3194. if (lxRs.state) {
  3195. //离线任务添加成功
  3196. Common.notifiy("115老司机自动开车",
  3197. '离线任务添加成功',
  3198. icon,
  3199. 'http://115.com/?tab=offline&mode=wangpan'
  3200. );
  3201. }
  3202. else {
  3203. //离线任务添加失败
  3204. if (lxRs.errcode == '911') {
  3205. lxRs.error_msg = '你的帐号使用异常,需要在线手工重新验证即可正常使用。';
  3206. }
  3207. Common.notifiy("失败了",
  3208. '请重新打开115,' + lxRs.error_msg,
  3209. icon,
  3210. 'http://115.com/?tab=offline&mode=wangpan'
  3211. );
  3212. }
  3213. console.log("sign:" + sign115 + " time:" + time115);
  3214. console.log("磁链:" + maglink + " 下载结果:" + lxRs.state + " 原因:" + lxRs.error_msg);
  3215. console.log("rsp:" + responseDetails.response);
  3216. }
  3217. });
  3218.  
  3219. });
  3220. event.preventDefault(); //阻止跳转
  3221. }
  3222. },
  3223. reg_event: () => { // target 处理 更精准
  3224. var list = [
  3225. '.nong-copy',
  3226. '.nong-offline-download'
  3227. ];
  3228. for (var i = 0; i < list.length; i++) {
  3229. var a = document.querySelectorAll(list[i]);
  3230. for (var u = 0; u < a.length; u++) {
  3231. a[u].addEventListener('click', thirdparty.nong.magnet_table.handle_event, false);
  3232. }
  3233. }
  3234. },
  3235. },
  3236. // 挊
  3237. searchMagnetRun: () => {
  3238. let main = thirdparty.nong.main;
  3239. let main_keys = Object.keys(main);
  3240. main.cur_tab = null;
  3241. main.cur_vid = '';
  3242. for (var i = 0; i < main_keys.length; i++) {
  3243. var v = main[main_keys[i]];
  3244. if (new RegExp(v.re).test(location.href)) {
  3245. if (v.type === 0) {
  3246. try {
  3247. main.cur_vid = v.vid();
  3248. console.log('挊的番号:', main.cur_vid);
  3249. }
  3250. catch (e) {
  3251. main.cur_vid = '';
  3252. }
  3253. if (main.cur_vid) {
  3254. GM_addStyle(`
  3255. #nong-table-new{margin:10px auto;color:#666 !important;font-size:13px;text-align:center;background-color: #F2F2F2;}
  3256. #nong-table-new th,#nong-table-new td{text-align: center;height:30px;background-color: #FFF;padding:0 5px 0;border: 1px solid #EFEFEF;}
  3257. .jav-nong-row{text-align: center;height:30px;background-color: #FFF;padding:0 5px 0;border: 1px solid #EFEFEF;}
  3258. .nong-copy{color:#08c !important;}
  3259. .nong-offline{text-align: center;}
  3260. #jav-nong-head a {margin-right: 5px;color: black;}
  3261. .nong-offline-download{color: rgb(0, 180, 30) !important; margin-right: 4px !important;}
  3262. .nong-offline-download:hover{color:red !important;}
  3263. `);
  3264. main.cur_tab = thirdparty.nong.magnet_table.full();
  3265. v.proc(main);
  3266.  
  3267. let t = $('#jav-nong-head')[0].firstChild;
  3268. t.firstChild.addEventListener('change', (e) => {
  3269. console.log("url: http://" + e.target.value);
  3270. GM_setValue('search_index', e.target.value);
  3271. let s = $('#nong-table-new')[0];
  3272. s.parentElement.removeChild(s);
  3273. thirdparty.nong.searchMagnetRun();
  3274. });
  3275.  
  3276. if (GM_getValue('search_index', null) === null) {
  3277. GM_setValue('search_index', Object.keys(thirdparty.nong.resource_sites)[0]);
  3278. }
  3279. thirdparty.nong.search_engines.cur_engine(main.cur_vid, (src, data) => {
  3280. if (data.length === 0) {
  3281. let url = thirdparty.nong.search_engines.full_url;
  3282. $('#nong-table-new #notice').text('No search result! '); //todo 181224
  3283. $('#nong-table-new #notice').append(
  3284. `<a href="${url}" target="_blank" style="color: red;">&nbsp;Go</a>`); //todo 190630
  3285. }
  3286. else {
  3287. thirdparty.nong.magnet_table.updata_table(src, data, 'full');
  3288. /*display search url*/
  3289. var y = $('#jav-nong-head th')[1].firstChild;
  3290. y.href = thirdparty.nong.search_engines.full_url;
  3291. }
  3292. });
  3293. }
  3294. }
  3295. break;
  3296. }
  3297. }
  3298. },
  3299. },
  3300. };
  3301.  
  3302. function mainRun() {
  3303. Common.init();
  3304. GM_addStyle(`
  3305. .tm-setting {display: flex;align-items: center;justify-content: space-between;padding-top: 20px;}
  3306. .tm-checkbox {width: 16px;height: 16px;}
  3307. .tm-text {width: 150px;height: 16px;}
  3308. `);
  3309.  
  3310. Jav.javStoreScript();
  3311. if ((/(JAVLibrary|JavBus|AVMOO|AVSOX)/g).test(document.title) || $("footer:contains('JavBus')").length) {
  3312. Common.addAvImgCSS();
  3313. GM_addStyle(`
  3314. .container {width: 100%;float: left;}
  3315. .col-md-3 {float: left;max-width: 260px;}
  3316. .col-md-9 {width: inherit;}
  3317. .hobby-a {color: red; font: bold 12px monospace;} /*javlib*/
  3318. .footer {padding: 20px 0;background: #1d1a18;float: left;} /*javbus*/
  3319. #nong-table-new {margin: initial !important;important;color: #666 !important;font-size: 13px;text-align: center;background-color: #F2F2F2;float: left;}
  3320. .header_hobby {font-weight: bold;text-align: right;width: 75px;} /*javbus*/
  3321. `);
  3322. Jav.javlibaryScript();
  3323. Jav.javBusScript();
  3324. }
  3325.  
  3326. Jav.oneJavScript();
  3327. Jav.jav321Script();
  3328. Jav.javDBScript();
  3329. Jav.quarkScript();
  3330. thirdparty.login115Run();
  3331. }
  3332. mainRun();
  3333. })();