JavScript

一站式体验,JavBus & JavDB 兼容

2023/02/22のページです。最新版はこちら。

作者のサイトでサポートを受ける。または、このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
  1. // ==UserScript==
  2. // @name JavScript
  3. // @namespace JavScript@blc
  4. // @version 4.5.2
  5. // @author blc
  6. // @description 一站式体验,JavBus & JavDB 兼容
  7. // @include *
  8. // @icon https://s1.ax1x.com/2022/04/01/q5lzYn.png
  9. // @resource success https://s1.ax1x.com/2022/04/01/q5l2LD.png
  10. // @resource info https://s1.ax1x.com/2022/04/01/q5lyz6.png
  11. // @resource warn https://s1.ax1x.com/2022/04/01/q5lgsO.png
  12. // @resource error https://s1.ax1x.com/2022/04/01/q5lcQK.png
  13. // @supportURL https://t.me/+bAWrOoIqs3xmMjll
  14. // @connect *
  15. // @run-at document-start
  16. // @grant unsafeWindow
  17. // @grant GM_removeValueChangeListener
  18. // @grant GM_addValueChangeListener
  19. // @grant GM_registerMenuCommand
  20. // @grant GM_getResourceURL
  21. // @grant GM_xmlhttpRequest
  22. // @grant GM_notification
  23. // @grant GM_setClipboard
  24. // @grant GM_deleteValue
  25. // @grant GM_addElement
  26. // @grant GM_listValues
  27. // @grant GM_openInTab
  28. // @grant GM_addStyle
  29. // @grant GM_getValue
  30. // @grant GM_setValue
  31. // @grant GM_info
  32. // @license GPL-3.0-only
  33. // @compatible chrome last 2 versions
  34. // @compatible edge last 2 versions
  35. // ==/UserScript==
  36.  
  37. // prettier-ignore
  38. (function () {
  39. const NUM_REGEX = /\d+\.?\d*/g;
  40. const ZH_REGEX = /中文|字幕|中字|-c(?!d)/i;
  41. const CODE_REGEX = /^[a-z0-9]+(-|\w)+/i;
  42. const VR_REGEX = /(?<![a-z])VR(?![a-z-])/i;
  43. const FC2_REGEX = /^FC2-/i;
  44.  
  45. const REP = "%s";
  46. const DOC = document;
  47. const VOID = "javascript:void(0)";
  48. const PICK_RUL = "https://v.anxia.com/?pickcode=";
  49. const FILE_RUL = `https://115.com/?cid=${REP}&offset=0&mode=wangpan`;
  50. const TAB_NAME = { img: "大图", video: "预览", player: "视频" };
  51.  
  52. const addListener = EventTarget.prototype.addEventListener;
  53. EventTarget.prototype.addEventListener = function (type, ...args) {
  54. if (type !== "XContentLoaded") return addListener.call(this, type, ...args);
  55. document.readyState !== "loading" ? args[0]() : addListener.call(this, "DOMContentLoaded", ...args);
  56. };
  57.  
  58. // capture
  59. const captureJump = () => {
  60. const { hash } = location;
  61. if (!hash?.includes("#jump#")) return;
  62.  
  63. const code = hash.split("#").at(-1);
  64. if (!CODE_REGEX.test(code)) return;
  65.  
  66. DOC.addEventListener(
  67. "XContentLoaded",
  68. () => {
  69. const capture = captureQuery(code)?.href;
  70. if (capture) location.replace(capture);
  71. },
  72. { once: true }
  73. );
  74. };
  75. const captureQuery = (code, { body } = DOC) => {
  76. const nodeList = Array.from(body.querySelectorAll(":any-link"));
  77. const { length } = nodeList;
  78. if (!length) return;
  79.  
  80. const { regex } = codeParse(code);
  81. code = code.toUpperCase();
  82.  
  83. const res = [];
  84. for (let i = 0; i < length; i++) {
  85. const { href = "", textContent = "", innerHTML = "" } = nodeList[i];
  86.  
  87. if (!href || /^#|javascript/i.test(href)) continue;
  88. const str = [textContent, innerHTML]
  89. .map(item => item?.trim() ?? "")
  90. .filter(Boolean)
  91. .join("&")
  92. .toUpperCase();
  93. if (!str || !regex.test(str)) continue;
  94.  
  95. if (!str.includes(code)) {
  96. res.push({ href, zh: false });
  97. continue;
  98. }
  99.  
  100. if (ZH_REGEX.test(textContent)) return { href, zh: true };
  101. res.unshift({ href, zh: false });
  102.  
  103. if (nodeList.some(item => item.href === href && ZH_REGEX.test(item.textContent))) return { href, zh: true };
  104. }
  105. if (res.length) return res[0];
  106. };
  107. const codeParse = code => {
  108. const _ = FC2_REGEX.test(code) ? "|_" : "";
  109. code = code.split("-").map((item, index) => (index ? item.replace(/^0/, "") : item));
  110.  
  111. return {
  112. prefix: code[0],
  113. regex: new RegExp(`(?<![a-z])${code.join(`(0|-${_}){0,4}`)}(?!\\d)`, "i"),
  114. };
  115. };
  116. captureJump();
  117.  
  118. // match
  119. const MatchDomains = [
  120. { domain: "JavDB", regex: /javdb\d*\.com/ },
  121. { domain: "JavBus", regex: /(jav|bus|dmm|see|cdn|fan){2}\.[a-z]{2,}/ },
  122. { domain: "Drive115", regex: /captchaapi\.115\.com/ },
  123. ];
  124. const Domain = MatchDomains.find(item => item.regex.test(location.host))?.domain;
  125. if (!Domain) return;
  126.  
  127. // request
  128. const request = (url, data, method = "GET", options = {}) => {
  129. method = method ? method.toUpperCase().trim() : "GET";
  130. if (!url || !["GET", "HEAD", "POST"].includes(method)) return;
  131.  
  132. if (Object.prototype.toString.call(data) === "[object Object]") {
  133. data = Object.keys(data)
  134. .map(key => `${key}=${encodeURIComponent(data[key])}`)
  135. .join("&");
  136. }
  137. const { responseType, headers = {} } = options;
  138. if (method === "GET") {
  139. options.responseType = responseType ?? "document";
  140. if (data) {
  141. let joiner = "?";
  142. if (url.includes(joiner)) joiner = /\?|&$/.test(url) ? "" : "&";
  143. url = `${url}${joiner}${data}`;
  144. }
  145. }
  146. if (method === "POST") {
  147. options.responseType = responseType ?? "json";
  148. options.headers = { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", ...headers };
  149. }
  150. return new Promise(resolve => {
  151. GM_xmlhttpRequest({
  152. url,
  153. data,
  154. method,
  155. timeout: 30000,
  156. onload: ({ status, response }) => {
  157. if (status >= 400) response = false;
  158. if (response && ["", "text"].includes(options.responseType)) {
  159. if (/<\/?[a-z][\s\S]*>/i.test(response)) {
  160. response = new DOMParser().parseFromString(response, "text/html");
  161. } else if (/^\{.*\}$/.test(response)) {
  162. response = JSON.parse(response);
  163. }
  164. }
  165. resolve(response ?? true);
  166. },
  167. ontimeout: () => resolve(false),
  168. onerror: () => resolve(false),
  169. ...options,
  170. });
  171. });
  172. };
  173. // utils
  174. const notify = ({ text = "点击跳转115", type = "error", clickUrl = "https://115.com/", setTab, ...details }) => {
  175. GM_notification({
  176. text: text || GM_info.script.name,
  177. image: GM_getResourceURL(type),
  178. highlight: false,
  179. silent: true,
  180. timeout: 5000,
  181. onclick: () => openInTab(clickUrl),
  182. ...details,
  183. });
  184. if (setTab) setTabBar({ type, title: details.title });
  185. };
  186. const addPrefetch = arr => {
  187. arr = arr.filter(Boolean);
  188. if (!arr.length) return;
  189.  
  190. DOC.head.insertAdjacentHTML("beforeend", arr.map(item => `<link rel="prefetch" href="${item}">`).join(""));
  191. };
  192. const setTabBar = ({ type = GM_info.script.icon, title }) => {
  193. if (title) DOC.title = title;
  194. type = type.includes("http") ? type : GM_getResourceURL(type);
  195.  
  196. let icons = DOC.querySelectorAll("link[rel*='icon']");
  197. if (!icons?.length) icons = [DOC.create("link", { type: "image/x-icon", rel: "shortcut icon" })];
  198.  
  199. icons.forEach(node => {
  200. node.href = type;
  201. DOC.getElementsByTagName("head")[0].append(node);
  202. });
  203. };
  204. const openInTab = (url, active = true, options = {}) => {
  205. if (url) return GM_openInTab(url, { active: !!active, setParent: true, ...options });
  206. };
  207. const imgLoaded = img => img.classList.add("x-in");
  208. const fadeInImg = node => {
  209. const img = node.querySelector("img");
  210. if (!img) return;
  211.  
  212. img.title = "";
  213. if (img.complete && img.naturalHeight !== 0) return imgLoaded(img);
  214. img.onload = () => imgLoaded(img);
  215. };
  216. const addCopy = (selectors, attrs = {}) => {
  217. const node = typeof selectors === "string" ? DOC.querySelector(selectors) : selectors;
  218. const _attrs = { "data-copy": node.textContent, class: "x-ml", href: VOID };
  219. const target = DOC.create("a", { ..._attrs, ...attrs }, "复制");
  220. target.addEventListener("click", e => handleCopy(e, "成功"));
  221. node.append(target);
  222. };
  223. const handleCopy = (e, tip = "复制成功", copy) => {
  224. const { target } = e;
  225. copy = copy ? copy : target?.dataset?.copy?.trim() ?? "";
  226. if (!copy) return;
  227.  
  228. e.preventDefault();
  229. e.stopPropagation();
  230. GM_setClipboard(copy);
  231.  
  232. const { textContent = "" } = target;
  233. target.textContent = tip || "复制成功";
  234. const timer = setTimeout(() => {
  235. clearTimeout(timer);
  236. target.textContent = textContent;
  237. }, 300);
  238. };
  239. const getDate = (timestamp, joiner = "-") => {
  240. const date = timestamp ? new Date(timestamp) : new Date();
  241. const Y = date.getFullYear();
  242. const M = `${date.getMonth() + 1}`.padStart(2, "0");
  243. const D = `${date.getDate()}`.padStart(2, "0");
  244. return `${Y}${joiner}${M}${joiner}${D}`;
  245. };
  246. const transToBytes = (sizeStr = "") => {
  247. const sizeNum = sizeStr?.match(NUM_REGEX)?.[0] ?? 0;
  248. if (sizeNum <= 0) return 0;
  249.  
  250. const matchList = [
  251. { unit: /byte/gi, transform: size => size },
  252. { unit: /kb/gi, transform: size => size * 1000 },
  253. { unit: /mb/gi, transform: size => size * 1000 ** 2 },
  254. { unit: /gb/gi, transform: size => size * 1000 ** 3 },
  255. { unit: /kib/gi, transform: size => size * 1024 },
  256. { unit: /mib/gi, transform: size => size * 1024 ** 2 },
  257. { unit: /gib/gi, transform: size => size * 1024 ** 3 },
  258. ];
  259.  
  260. return (
  261. matchList
  262. .find(({ unit }) => unit.test(sizeStr))
  263. ?.transform(sizeNum)
  264. ?.toFixed(2) ?? 0
  265. );
  266. };
  267. DOC.create = (tag, attrs = {}, child) => {
  268. const node = DOC.createElement(tag);
  269. for (const [name, value] of Object.entries(attrs)) node.setAttribute(name, value);
  270. if (child) node.append(child);
  271. return node;
  272. };
  273. const createVideo = (sources, attrs = {}) => {
  274. if (typeof sources === "string") sources = [{ src: sources, type: "video/mp4" }];
  275. const video = DOC.create("video", attrs);
  276. video.controls = true;
  277. video.currentTime = 3;
  278. video.volume = localStorage.getItem("volume") ?? 0;
  279. video.preload = "none";
  280. video.append(...sources.map(item => DOC.create("source", item)));
  281.  
  282. let timer = null;
  283. video.addEventListener("volumechange", ({ target }) => {
  284. if (timer) clearTimeout(timer);
  285. timer = setTimeout(() => localStorage.setItem("volume", target.volume), 1000);
  286. });
  287. video.addEventListener("keyup", ({ code, target }) => {
  288. if (code === "Enter") {
  289. target.requestFullscreen();
  290. target.play();
  291. }
  292. if (code === "KeyM") target.muted = !target.muted;
  293. });
  294. return video;
  295. };
  296. const paramParse = (param, filter, separator = "#") => {
  297. return unique(param.split(separator).filter(item => filter.includes(item)));
  298. };
  299. const unique = (arr, key) => {
  300. if (!key) return Array.from(new Set(arr));
  301. return unique(arr.map(e => e[key].toLowerCase())).map(e => arr.find(x => x[key].toLowerCase() === e));
  302. };
  303. const verify = () => {
  304. const h = 667;
  305. const w = 375;
  306. const t = (window.screen.availHeight - h) / 2;
  307. const l = (window.screen.availWidth - w) / 2;
  308.  
  309. window.open(
  310. `https://captchaapi.115.com/?ac=security_code&type=web&cb=Close911_${new Date().getTime()}`,
  311. "验证账号",
  312. `height=${h},width=${w},top=${t},left=${l},toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no`
  313. );
  314. };
  315. const delay = (s = 1) => {
  316. return new Promise(r => {
  317. setTimeout(r, s * 1000);
  318. });
  319. };
  320.  
  321. class Store {
  322. static init() {
  323. const date = getDate();
  324. const cdKey = "CD";
  325.  
  326. if (GM_getValue(cdKey, "") !== date) {
  327. GM_setValue(cdKey, date);
  328. GM_setValue("DETAILS", {});
  329. GM_setValue("RESOURCE", {});
  330. GM_setValue("VERIFY_STATUS", "");
  331. }
  332.  
  333. const expired = getDate(new Date() - 1000 * 60 * 60 * 24 * 30);
  334. if ((localStorage.getItem(cdKey) ?? expired) > expired) return;
  335. localStorage.clear();
  336. localStorage.setItem(cdKey, date);
  337. }
  338. static getDetail(key) {
  339. const localDetail = {
  340. img: localStorage.getItem(`${key}_img`) ?? undefined,
  341. video: localStorage.getItem(`${key}_video`) ?? undefined,
  342. };
  343.  
  344. const details = GM_getValue("DETAILS", {});
  345. return { ...localDetail, ...(details[key] ?? {}) };
  346. }
  347. static upDetail(key, val) {
  348. const details = GM_getValue("DETAILS", {});
  349. details[key] = { ...(details[key] ?? {}), ...val };
  350. GM_setValue("DETAILS", details);
  351.  
  352. if (FC2_REGEX.test(key)) return;
  353. val = JSON.stringify(val, ["img", "video"]);
  354. if (val === "{}") return;
  355. for (const [_key, _val] of Object.entries(JSON.parse(val))) {
  356. localStorage.setItem(`${key}_${_key}`, _val);
  357. }
  358. }
  359. static getResource(key) {
  360. const resource = GM_getValue("RESOURCE", {});
  361. return resource[key];
  362. }
  363. static upResource(key, val) {
  364. const resource = GM_getValue("RESOURCE", {});
  365. resource[key] = val;
  366. GM_setValue("RESOURCE", resource);
  367. }
  368. static getVerifyStatus() {
  369. return GM_getValue("VERIFY_STATUS", "");
  370. }
  371. static setVerifyStatus(val) {
  372. GM_setValue("VERIFY_STATUS", val);
  373. }
  374. }
  375. class Apis {
  376. static async fetchBlogJav(code) {
  377. if (FC2_REGEX.test(code)) code = code.replace("-PPV-", " PPV ");
  378. const re = { img: "" };
  379.  
  380. const requests = [
  381. {
  382. url: `https://blogjav.net/?s=${code}`,
  383. selectors: "#main .entry-title a",
  384. },
  385. {
  386. url: `https://duckduckgo.com/?q=${code} site:blogjav.net`,
  387. selectors: "#links h2 a",
  388. },
  389. {
  390. url: `https://www.google.com/search?q=${code} site:blogjav.net`,
  391. selectors: "#rso .g .yuRUbf > a",
  392. },
  393. ];
  394. let list = await Promise.allSettled(requests.map(item => request(item.url)));
  395.  
  396. const { regex } = codeParse(code);
  397. code = code.toUpperCase();
  398. let url = "";
  399. for (let index = 0, { length } = requests; index < length; index++) {
  400. const { status, value } = list[index];
  401. if (status !== "fulfilled" || !value) continue;
  402.  
  403. const href = Array.from(value?.querySelectorAll(requests[index].selectors) ?? []).find(item => {
  404. const str = item.textContent.toUpperCase();
  405. return regex.test(str) && str.includes(code);
  406. })?.href;
  407. if (!href) continue;
  408.  
  409. url = href;
  410. break;
  411. }
  412. if (!url) return re;
  413.  
  414. list = await Promise.allSettled([
  415. request(url),
  416. request(`http://webcache.googleusercontent.com/search?q=cache:${url}`),
  417. ]);
  418. url = "";
  419. for (let index = 0, { length } = list; index < length; index++) {
  420. const { status, value } = list[index];
  421. if (status !== "fulfilled" || !value) continue;
  422.  
  423. let img = value.querySelector("#main .entry-content a img");
  424. if (!img) continue;
  425.  
  426. img = img.getAttribute("data-src") ?? img.getAttribute("data-lazy-src");
  427. if (!img) continue;
  428.  
  429. url = img.replace("//t", "//img").replace("thumbs", "images");
  430. break;
  431. }
  432. re.img = url;
  433. return re;
  434. }
  435. static async fetchJavStore(code) {
  436. if (FC2_REGEX.test(code)) code = code.replace("-PPV-", "PPV ");
  437. const re = { img: "" };
  438.  
  439. let res = await request(`https://javstore.net/search/${code}.html`);
  440. if (!res) return re;
  441.  
  442. res = res.querySelectorAll("#content_news li > a");
  443. if (!res.length) return re;
  444.  
  445. const { regex } = codeParse(code);
  446. code = code.toUpperCase();
  447. res = Array.from(res).find(item => {
  448. const str = item.title.toUpperCase();
  449. return str.includes(code) && regex.test(str) && item.querySelector("img").src.startsWith("https");
  450. })?.href;
  451. if (!res) return re;
  452.  
  453. res = await request(res);
  454. if (!res) return re;
  455.  
  456. res = res.querySelector(".news a img[alt*='.th']")?.src;
  457. if (!res?.startsWith("https")) return re;
  458.  
  459. re.img = res
  460. .replace("//t", "//img")
  461. .replace("pixhost.org", "pixhost.to")
  462. .replace("thumbs", "images")
  463. .replace(".th", "");
  464.  
  465. return re;
  466. }
  467. static async fetchVideoByGuess({ code, isVR, cid }) {
  468. const re = { video: "" };
  469. if (!code && !cid) return re;
  470.  
  471. const HOST = `https://cc3001.dmm.co.jp/${isVR ? "vrsample" : "litevideo/freepv"}/`;
  472. const SUFFIX = isVR ? "vrlite" : "_dmb_w";
  473. const list = [];
  474.  
  475. const parseUrl = (prefix, num = "") => {
  476. return `${HOST}${prefix[0]}/${prefix.substring(0, 3)}/${prefix}${num}/${prefix}${num}${SUFFIX}.mp4`;
  477. };
  478.  
  479. if (code) {
  480. const [prefix, num = ""] = code.toLowerCase().split(/-|_/);
  481. const matchList = [
  482. { prefix: ["fera", "fuga", "jrze", "mesu"], add: "h_086" },
  483. { prefix: ["spz", "udak", "ofku"], add: "h_254" },
  484. { prefix: ["abp", "ppt", "abw"], add: "118" },
  485. { prefix: ["mds", "scpx"], add: "84" },
  486. { prefix: ["shind"], add: "h_1560" },
  487. { prefix: ["pydvr"], add: "h_1321" },
  488. { prefix: ["meko"], add: "h_1160" },
  489. { prefix: ["fgan"], add: "h_1440" },
  490. { prefix: ["spro"], add: "h_1594" },
  491. { prefix: ["hzgb"], add: "h_1100" },
  492. { prefix: ["stcv"], add: "h_1616" },
  493. { prefix: ["skmj"], add: "h_1324" },
  494. { prefix: ["haru"], add: "h_687" },
  495. { prefix: ["fone"], add: "h_491" },
  496. { prefix: ["fsvr"], add: "h_955" },
  497. { prefix: ["jukf"], add: "h_227" },
  498. { prefix: ["rebd"], add: "h_346" },
  499. { prefix: ["ktra"], add: "h_094" },
  500. { prefix: ["supa"], add: "h_244" },
  501. { prefix: ["zex"], add: "h_720" },
  502. { prefix: ["pym"], add: "h_283" },
  503. { prefix: ["hz"], add: "h_113" },
  504. { prefix: ["dtvr"], add: "24" },
  505. { prefix: ["umd"], add: "125" },
  506. { prefix: ["gvg"], add: "13" },
  507. { prefix: ["t28"], add: "55" },
  508. { prefix: ["lol"], add: "12" },
  509. { prefix: ["dv"], add: "53" },
  510. ];
  511. const add = matchList.find(item => item.prefix.includes(prefix))?.add ?? "1";
  512. list.push(parseUrl(prefix, num));
  513. list.push(parseUrl(`${add}${prefix}`, num));
  514. if (num) {
  515. list.push(parseUrl(prefix, `00${num}`));
  516. list.push(parseUrl(`${add}${prefix}`, `00${num}`));
  517. }
  518. }
  519. if (cid) {
  520. list.push(parseUrl(cid));
  521. list.push(parseUrl(cid.replace("00", "")));
  522. }
  523.  
  524. const res = await Promise.allSettled(unique(list).map(item => request(item, {}, "HEAD")));
  525. for (let index = 0, { length } = res; index < length; index++) {
  526. const { status, value } = res[index];
  527. if (status !== "fulfilled" || !value) continue;
  528.  
  529. re.video = list[index];
  530. break;
  531. }
  532. return re;
  533. }
  534. static async fetchVideoByStudio({ code, studio }) {
  535. const re = { video: "" };
  536. if (!studio) return re;
  537.  
  538. code = code.toLowerCase();
  539. const matchList = [
  540. {
  541. name: "東京熱",
  542. match: `https://my.cdn.tokyo-hot.com/media/samples/${REP}.mp4`,
  543. },
  544. {
  545. name: "カリビアンコム",
  546. match: `https://smovie.caribbeancom.com/sample/movies/${REP}/720p.mp4`,
  547. },
  548. {
  549. name: "一本道",
  550. match: `http://smovie.1pondo.tv/sample/movies/${REP}/1080p.mp4`,
  551. },
  552. {
  553. name: "HEYZO",
  554. trans: code => code.replace(/HEYZO-/gi, ""),
  555. match: `https://sample.heyzo.com/contents/3000/${REP}/heyzo_hd_${REP}_sample.mp4`,
  556. },
  557. {
  558. name: "天然むすめ",
  559. match: `https://smovie.10musume.com/sample/movies/${REP}/720p.mp4`,
  560. },
  561. {
  562. name: "パコパコママ",
  563. match: `https://fms.pacopacomama.com/hls/sample/pacopacomama.com/${REP}/720p.mp4`,
  564. },
  565. ];
  566. let res = matchList.find(({ name }) => name === studio);
  567. if (!res) return re;
  568.  
  569. res = res.match.replaceAll(REP, res.trans ? res.trans(code) : code);
  570. if (await request(res, {}, "HEAD")) re.video = res;
  571. return re;
  572. }
  573. // fetch video by guess for list
  574. static async fetchVBGFL(code) {
  575. const re = { video: "" };
  576.  
  577. code = code.replace(/HEYZO-/gi, "").toLowerCase();
  578. const list = [
  579. `https://my.cdn.tokyo-hot.com/media/samples/${code}.mp4`,
  580. `https://smovie.caribbeancom.com/sample/movies/${code}/720p.mp4`,
  581. `http://smovie.1pondo.tv/sample/movies/${code}/1080p.mp4`,
  582. `https://sample.heyzo.com/contents/3000/${code}/heyzo_hd_${code}_sample.mp4`,
  583. `https://smovie.10musume.com/sample/movies/${code}/720p.mp4`,
  584. `https://fms.pacopacomama.com/hls/sample/pacopacomama.com/${code}/720p.mp4`,
  585. ];
  586.  
  587. const res = await Promise.allSettled(list.map(item => request(item, {}, "HEAD")));
  588. for (let index = 0, { length } = res; index < length; index++) {
  589. const { status, value } = res[index];
  590. if (status !== "fulfilled" || !value) continue;
  591.  
  592. re.video = list[index];
  593. break;
  594. }
  595. return re;
  596. }
  597. // fetch video by local
  598. static async fetchVBL({ node, isVR }) {
  599. const re = { video: "" };
  600.  
  601. let res = await request(node.href);
  602. if (!res) return re;
  603.  
  604. if (Domain === "JavBus") {
  605. let cid = res.querySelector("#sample-waterfall a.sample-box")?.href;
  606. cid = cid?.includes("pics.dmm.co.jp") ? cid.split("/").at(-2) : "";
  607. if (!cid) return re;
  608.  
  609. res = await this.fetchVideoByGuess({ cid, isVR });
  610. if (res.video) re.video = res.video;
  611. }
  612. if (Domain === "JavDB") {
  613. res = res.querySelector("#preview-video source")?.getAttribute("src") ?? "";
  614. if (res && (await request(res, {}, "HEAD"))) re.video = res;
  615. }
  616.  
  617. return re;
  618. }
  619. static async fetchJavSpyl(code) {
  620. const re = { video: "" };
  621.  
  622. let res = await request(`https://api.javspyl.tk/api/?${code}`, {}, "GET", {
  623. headers: { origin: "https://javspyl.tk" },
  624. responseType: "text",
  625. });
  626. if (!res?.msg || res?.code) return re;
  627.  
  628. res = res.msg;
  629. if (res.trim() === "no" || res.endsWith(".m3u8")) return re;
  630.  
  631. res = res.includes("//") ? res : `https://${res}`;
  632. if (await request(res, {}, "HEAD")) re.video = res;
  633. return re;
  634. }
  635. static async fetchAVPreview(code) {
  636. const re = { video: "" };
  637.  
  638. let res = await request(`https://avpreview.com/zh/search?keywords=${code}`);
  639. if (!res) return re;
  640.  
  641. res = Array.from(res.querySelectorAll(".container .videobox"))
  642. .find(item => code === item.querySelector("h2 strong")?.textContent)
  643. ?.querySelector("a")
  644. ?.getAttribute("href");
  645. if (!res) return re;
  646.  
  647. res = await request(
  648. "https://avpreview.com/API/v1.0/index.php",
  649. {
  650. system: "videos",
  651. action: "detail",
  652. contentid: res.split("/").at(-1),
  653. sitecode: "avpreview",
  654. ip: "",
  655. token: "",
  656. },
  657. "GET",
  658. { responseType: "json" }
  659. );
  660. if (!res) return re;
  661.  
  662. res = res?.videos?.trailer?.replace("/hlsvideo/", "/litevideo/")?.replace("/playlist.m3u8", "");
  663. if (!res) return re;
  664.  
  665. const contentId = res.split("/").at(-1);
  666. res = [
  667. `${res}/${contentId}_dmb_w.mp4`,
  668. `${res}/${contentId}_mhb_w.mp4`,
  669. `${res}/${contentId}_dm_w.mp4`,
  670. `${res}/${contentId}_sm_w.mp4`,
  671. ];
  672. const list = await Promise.allSettled(res.map(item => request(item, {}, "HEAD")));
  673. for (let index = 0, { length } = list; index < length; index++) {
  674. const { status, value } = list[index];
  675. if (status !== "fulfilled" || !value) continue;
  676.  
  677. re.video = res[index];
  678. break;
  679. }
  680. return re;
  681. }
  682. static async fetchFC2(code) {
  683. code = code.split("-").at(-1);
  684.  
  685. const HOST = "https://adult.xiaojiadianmovie.be/";
  686. const re = { video: "" };
  687.  
  688. let res = await request(`${HOST}article/${code}/`);
  689. if (!res) return re;
  690.  
  691. res = res.head
  692. .querySelector("script:last-child")
  693. .innerHTML?.match(/(?<=ae', ').*?(?=')/)
  694. ?.at(0);
  695. if (!res) return re;
  696.  
  697. res = await request(`${HOST}api/v2/videos/${code}/sample`, {}, "GET", {
  698. responseType: "json",
  699. headers: { "X-FC2-Contents-Access-Token": res },
  700. });
  701. if (res?.path && (await request(res.path, {}, "HEAD"))) re.video = res.path;
  702. return re;
  703. }
  704. static async fetchNetflav(code) {
  705. const HOST = "https://netflav.com";
  706. const re = { player: [] };
  707.  
  708. let res = await request(`${HOST}/search?type=title&keyword=${code}`);
  709. if (!res) return re;
  710.  
  711. res = res.querySelectorAll(".grid_root .grid_cell");
  712. if (!res.length) return re;
  713.  
  714. const { regex } = codeParse(code);
  715. code = code.toUpperCase();
  716. res = Array.from(res)
  717. .find(item => {
  718. const str = item.querySelector(".grid_title").textContent.toUpperCase();
  719. return str.includes(code) && regex.test(str);
  720. })
  721. ?.querySelector("a")
  722. ?.getAttribute("href");
  723. if (!res) return re;
  724.  
  725. res = await request(`${HOST}${res}`);
  726. if (!res) return re;
  727.  
  728. res = res.querySelector("#__NEXT_DATA__")?.textContent;
  729. if (!res) return re;
  730.  
  731. res = JSON.parse(res)?.props?.initialState?.video?.data?.srcs;
  732. if (!res?.length) return re;
  733.  
  734. const matchList = [
  735. {
  736. regex: /\/\/(mm9842\.com|www\.avple\.video|asianclub\.tv)/,
  737. parse: async url => {
  738. const [protocol, href] = url.split("//");
  739. const [host, ...pathname] = href.split("/");
  740.  
  741. const res = await request(
  742. `${protocol}//${host}/api/source/${pathname.pop()}`,
  743. { r: "", d: host },
  744. "POST"
  745. );
  746.  
  747. if (!res?.success) return [];
  748. return (res?.data ?? []).map(({ file, label = "320p", type }) => {
  749. return { src: file, title: label, type: `video/${type}` };
  750. });
  751. },
  752. },
  753. {
  754. regex: /\/\/(embedgram\.com|vidoza\.net)/,
  755. parse: async url => {
  756. const res = await request(url);
  757. if (!res) return [];
  758. return Array.from(res?.querySelectorAll("video source") ?? []).map(
  759. ({ src, title = "320p", type }) => {
  760. return { src, title, type };
  761. }
  762. );
  763. },
  764. },
  765. ];
  766. res = await Promise.allSettled(res.map(url => matchList.find(({ regex }) => regex.test(url))?.parse(url)));
  767. for (let index = 0, { length } = res; index < length; index++) {
  768. const { status, value } = res[index];
  769. if (status === "fulfilled" && value?.length) re.player = re.player.concat(value);
  770. }
  771. return re;
  772. }
  773. static async fetchTranslate(str) {
  774. const re = { title: "" };
  775.  
  776. const res = await request(
  777. "https://www.google.com/async/translate?vet=12ahUKEwixq63V3Kn3AhUCJUQIHdMJDpkQqDh6BAgCECw..i&ei=CbNjYvGCPYLKkPIP05O4yAk&yv=3",
  778. {
  779. async: `translate,sl:auto,tl:zh-CN,st:${encodeURIComponent(
  780. str.trim()
  781. )},id:1650701080679,qc:true,ac:false,_id:tw-async-translate,_pms:s,_fmt:pc`,
  782. },
  783. "POST",
  784. { responseType: "" }
  785. );
  786. if (res) re.title = res?.querySelector("#tw-answ-target-text")?.textContent ?? "";
  787.  
  788. return re;
  789. }
  790. static async _fetchMagnet(code, { site, host, search, selectors, filter }) {
  791. const key = `${site.substring(0, 3).toLowerCase()}_magnet`;
  792. const re = { [key]: [] };
  793.  
  794. let res = await request(`${host}${search}`);
  795. if (!res) return re;
  796.  
  797. res = res.querySelectorAll(selectors);
  798. if (!res.length) return re;
  799.  
  800. const { regex } = codeParse(code);
  801. for (const item of res) {
  802. const name = (filter.name(item) ?? "").replace(/[\u200B-\u200D\uFEFF]/g, "");
  803. if (!regex.test(name)) continue;
  804.  
  805. const size = filter.size(item);
  806. let href = filter.href(item);
  807. if (href && !href.includes("//")) href = `${host}${href.replace(/^\//, "")}`;
  808.  
  809. re[key].push({
  810. name,
  811. zh: ZH_REGEX.test(name),
  812. link: filter.link(item).split("&")[0],
  813. size,
  814. bytes: transToBytes(size),
  815. date: filter.date(item),
  816. href,
  817. from: site,
  818. });
  819. }
  820. return re;
  821. }
  822. static fetchSukebei(code) {
  823. return this._fetchMagnet(code, {
  824. site: "Sukebei",
  825. host: "https://sukebei.nyaa.si/",
  826. search: `?f=0&c=0_0&q=${code}`,
  827. selectors: ".table-responsive table tbody tr",
  828. filter: {
  829. name: e => e.querySelector("td:nth-child(2) a").textContent,
  830. link: e => e.querySelector("td:nth-child(3) a:last-child").href,
  831. size: e => e.querySelector("td:nth-child(4)").textContent,
  832. date: e => e.querySelector("td:nth-child(5)").textContent.split(" ")[0],
  833. href: e => e.querySelector("td:nth-child(2) a").getAttribute("href"),
  834. },
  835. });
  836. }
  837. static fetchBTSOW(code) {
  838. return this._fetchMagnet(code, {
  839. site: "BTSOW",
  840. host: "https://btsow.com/",
  841. search: `search/${code}`,
  842. selectors: ".data-list .row:not(.hidden-xs)",
  843. filter: {
  844. name: e => e.querySelector(".file").textContent,
  845. link: e => `magnet:?xt=urn:btih:${e.querySelector("a").href.split("/").pop()}`,
  846. size: e => e.querySelector(".size").textContent,
  847. date: e => e.querySelector(".date").textContent,
  848. href: e => e.querySelector("a").getAttribute("href"),
  849. },
  850. });
  851. }
  852. static fetchBTDigg(code, index = 0) {
  853. return this._fetchMagnet(code, {
  854. site: "BTDigg",
  855. host: `https://${index ? "www." : ""}btdig.com/`,
  856. search: `search?order=0&q=${code}`,
  857. selectors: ".one_result",
  858. filter: {
  859. name: e => e.querySelector(".torrent_name").textContent,
  860. link: e => e.querySelector(".torrent_magnet a").href,
  861. size: e => e.querySelector(".torrent_size").textContent,
  862. date: e => e.querySelector(".torrent_age").textContent,
  863. href: e => e.querySelector(".torrent_name a").href,
  864. },
  865. });
  866. }
  867. static async fetchMGS({ code, title }) {
  868. const HOST = "https://www.mgstage.com";
  869. const re = { mgs_score: [], video: "" };
  870.  
  871. let res = await request(`${HOST}/search/cSearch.php?search_word=${title}&list_cnt=120`);
  872. if (!res) return re;
  873.  
  874. res = res.querySelectorAll(".rank_list li");
  875. if (!res.length) return re;
  876.  
  877. const { regex } = codeParse(code);
  878. code = code.toUpperCase();
  879. res = Array.from(res).find(item => {
  880. const str = item.querySelector("a").getAttribute("href").toUpperCase();
  881. return str.includes(code) && regex.test(str);
  882. });
  883. if (!res) return re;
  884.  
  885. let [score, video] = await Promise.allSettled([
  886. request(`${HOST}${res.querySelector("a").getAttribute("href")}`),
  887. request(
  888. `${HOST}${res
  889. .querySelector(".sample_movie_btn a")
  890. .getAttribute("href")
  891. .replace("player.html/", "Respons.php?pid=")}`,
  892. {},
  893. "GET",
  894. { responseType: "json" }
  895. ),
  896. ]);
  897. if (score.status === "fulfilled" && score.value) {
  898. score = score.value.querySelector(".detail_data .review")?.textContent?.match(NUM_REGEX);
  899. if (score?.length) re.mgs_score.push({ score: score[0], total: 5, num: score[1], from: "MGS" });
  900. }
  901. if (video.status === "fulfilled" && video.value) {
  902. video = video.value?.url.split("?")[0].replace("ism/request", "mp4");
  903. if (await request(video, {}, "HEAD")) re.video = video;
  904. }
  905. return re;
  906. }
  907. static async fetchLib(code) {
  908. const HOST = "https://www.javlibrary.com/cn/";
  909. const re = { lib_score: [], star: [] };
  910.  
  911. let res = await request(`${HOST}vl_searchbyid.php?keyword=${code}`);
  912. if (!res) return re;
  913.  
  914. if (res.querySelector(".videothumblist")) {
  915. res = res.querySelectorAll(".videothumblist .videos .video > a");
  916. if (!res.length) return re;
  917.  
  918. const { regex } = codeParse(code);
  919. code = code.toUpperCase();
  920. res = Array.from(res).find(({ title }) => {
  921. const str = title.toUpperCase();
  922. return str.includes(code) && regex.test(str);
  923. });
  924. if (!res) return re;
  925.  
  926. res = await request(`${HOST}${res.getAttribute("href")}`);
  927. }
  928.  
  929. const score = res.querySelector("#video_review .text .score")?.textContent?.replace(/\(|\)/g, "") ?? "";
  930. if (score) re.lib_score.push({ score, total: 10, from: "JavLibrary" });
  931.  
  932. re.star = Array.from(res.querySelectorAll("#video_cast .text .star")).map(item => item.textContent);
  933. return re;
  934. }
  935. static async fetchDMM({ code, title }) {
  936. const re = { fetchVideo: "", fetchInfo: "" };
  937.  
  938. let res = await request(`https://jav.land/tw/id_search.php?keys=${code.toUpperCase()}`);
  939. if (!res) return re;
  940.  
  941. res = res.querySelector("table.videotextlist tbody tr");
  942. if (!res) return re;
  943.  
  944. res = res.querySelectorAll("td");
  945. if (!res?.length || res[0].textContent !== "內容 ID:") return re;
  946. const cid = res[1].textContent;
  947.  
  948. re.fetchVideo = async () => {
  949. const result = { video: "" };
  950.  
  951. const first = cid[0];
  952. const second = cid.substring(0, 3);
  953. const list = [
  954. `https://cc3001.dmm.co.jp/litevideo/freepv/${first}/${second}/${cid}/${cid}_dmb_w.mp4`,
  955. `https://cc3001.dmm.co.jp/litevideo/freepv/${first}/${second}/${cid}/${cid}_mhb_w.mp4`,
  956. `https://cc3001.dmm.co.jp/litevideo/freepv/${first}/${second}/${cid}/${cid}_dm_w.mp4`,
  957. `https://cc3001.dmm.co.jp/litevideo/freepv/${first}/${second}/${cid}/${cid}_sm_w.mp4`,
  958. `https://cc3001.dmm.co.jp/vrsample/${first}/${second}/${cid}/${cid}vrlite.mp4`,
  959. ];
  960.  
  961. const res = await Promise.allSettled(list.map(item => request(item, {}, "HEAD")));
  962. for (let index = 0, { length } = res; index < length; index++) {
  963. const { status, value } = res[index];
  964. if (status !== "fulfilled" || !value) continue;
  965.  
  966. result.video = list[index];
  967. break;
  968. }
  969. return result;
  970. };
  971.  
  972. re.fetchInfo = async () => {
  973. const result = { dmm_score: [], star: [], video: "" };
  974.  
  975. const res = await request(`https://www.dmm.co.jp/digital/videoa/-/detail/=/cid=${cid}/`, {}, "GET", {
  976. headers: { "accept-language": "ja-JP" },
  977. });
  978. if (!res) return result;
  979.  
  980. let params = res.head.querySelector("script[type='application/ld+json']")?.textContent;
  981. if (!params) return result;
  982.  
  983. params = JSON.parse(params);
  984. if (!params?.name || (title && !title.includes(params.name))) return result;
  985.  
  986. if (params.aggregateRating) {
  987. result.dmm_score.push({
  988. score: params.aggregateRating.ratingValue,
  989. total: 5,
  990. num: params.aggregateRating.ratingCount,
  991. from: "DMM",
  992. });
  993. }
  994. result.star = Array.from(res.querySelectorAll("#performer a")).map(item => item.textContent);
  995. const video = params.subjectOf?.contentUrl;
  996. if (video && (await request(video, {}, "HEAD"))) result.video = video;
  997. return result;
  998. };
  999.  
  1000. return re;
  1001. }
  1002. static async fetchDB(code) {
  1003. const HOST = "https://javdb.com";
  1004. const re = { db_score: [], star: [], video: "", sub: [] };
  1005.  
  1006. let res = await request(`${HOST}/search?q=${code}&sb=0`);
  1007. if (!res) return re;
  1008.  
  1009. res = res.querySelectorAll(".movie-list .item a");
  1010. if (!res.length) return re;
  1011.  
  1012. const { regex } = codeParse(code);
  1013. code = code.toUpperCase();
  1014. res = Array.from(res).find(item => {
  1015. const str = item.querySelector("strong").textContent.toUpperCase();
  1016. return str.includes(code) && regex.test(str);
  1017. });
  1018. if (!res) return re;
  1019.  
  1020. const href = `${HOST}${res.getAttribute("href")}`;
  1021. res = await request(href);
  1022. if (!res) return re;
  1023.  
  1024. const scoreReg = /評分|Rating/;
  1025. const starReg = /演員|Actor/;
  1026. for (const item of res.querySelectorAll(".movie-panel-info .panel-block")) {
  1027. let [label, value] = item.querySelectorAll("strong, .value");
  1028. if (!label || !value) continue;
  1029.  
  1030. label = label.textContent;
  1031. value = value.textContent;
  1032. if (scoreReg.test(label)) {
  1033. const [score, num] = value.match(NUM_REGEX);
  1034. re.db_score.push({ score, total: 5, num, from: "JavDB" });
  1035. continue;
  1036. }
  1037. if (!starReg.test(label)) continue;
  1038.  
  1039. re.star = value
  1040. .split("\n")
  1041. .filter(item => item.includes("♀"))
  1042. .map(item => item.replace("♀", "").trim());
  1043. }
  1044.  
  1045. if (res.querySelector("a.preview-video-container")) {
  1046. const video = res.querySelector("#preview-video source")?.src || "";
  1047. if (video && (await request(video, {}, "HEAD"))) re.video = video;
  1048. }
  1049.  
  1050. for (const item of res.querySelectorAll("#magnets-content .item")) {
  1051. const first = item.querySelector("a");
  1052. if (!first) continue;
  1053.  
  1054. const size = first.querySelector(".meta")?.textContent?.trim() ?? "";
  1055. re.sub.push({
  1056. from: "JavDB",
  1057. href,
  1058. name: first.querySelector(".name").textContent,
  1059. link: first.href.split("&")[0],
  1060. size,
  1061. bytes: transToBytes(size),
  1062. zh: !!first.querySelector(".tag.is-warning.is-small.is-light"),
  1063. date: item.querySelector(".time")?.textContent ?? "",
  1064. });
  1065. }
  1066. return re;
  1067. }
  1068. static async _driveSearch(params, keys = []) {
  1069. if (typeof params === "string") params = { search_value: params };
  1070.  
  1071. const res = await request(
  1072. "https://webapi.115.com/files/search",
  1073. {
  1074. offset: 0,
  1075. limit: 10000,
  1076. date: "",
  1077. aid: 1,
  1078. cid: 0,
  1079. pick_code: "",
  1080. type: 4,
  1081. source: "",
  1082. format: "json",
  1083. o: "user_ptime",
  1084. asc: 0,
  1085. star: "",
  1086. suffix: "",
  1087. ...params,
  1088. },
  1089. "GET",
  1090. { responseType: "json" }
  1091. );
  1092. if (!res) return;
  1093. if (!res.state) return notify({ title: res.error });
  1094.  
  1095. return res.data.map(({ n, pc, fid, cid, ...item }) => {
  1096. const _item = { n, pc, fid, cid };
  1097. for (const key of keys) _item[key] = item[key];
  1098. return _item;
  1099. });
  1100. }
  1101. static async _driveCid(name, type) {
  1102. let res = await this.driveFile();
  1103. if (!res) return;
  1104. if (!res.state) return notify({ title: res?.errNo === 20130827 ? "文件排序不支持" : res.error });
  1105.  
  1106. res = res.data.find(({ n }) => n === name)?.cid ?? "";
  1107. if (res || type === "find") return res;
  1108.  
  1109. res = await request("https://webapi.115.com/files/add", { pid: 0, cname: name }, "POST");
  1110. if (!res) return;
  1111. if (!res.state) return notify({ title: res.error });
  1112. return res?.cid ?? "";
  1113. }
  1114. static driveFile(params = {}) {
  1115. if (typeof params === "string") params = { cid: params };
  1116.  
  1117. return request(
  1118. "https://webapi.115.com/files",
  1119. {
  1120. aid: 1,
  1121. cid: 0,
  1122. o: "user_ptime",
  1123. asc: 0,
  1124. offset: 0,
  1125. show_dir: 1,
  1126. limit: 115,
  1127. code: "",
  1128. scid: "",
  1129. snap: 0,
  1130. natsort: 1,
  1131. record_open_time: 1,
  1132. source: "",
  1133. format: "json",
  1134. ...params,
  1135. },
  1136. "GET",
  1137. { responseType: "json" }
  1138. );
  1139. }
  1140. static async driveVideo(cid, keys = []) {
  1141. if (!cid) return;
  1142.  
  1143. const res = await this.driveFile({ cid, custom_order: 0, star: "", suffix: "", type: 4 });
  1144. if (!res?.data) return;
  1145.  
  1146. return res.data.map(({ n, pc, fid, cid, t, ...item }) => {
  1147. const _item = { n, pc, fid, cid, t };
  1148. for (const key of keys) _item[key] = item[key];
  1149. return _item;
  1150. });
  1151. }
  1152. static async driveSign() {
  1153. const res = await request(
  1154. "http://115.com/",
  1155. { ct: "offline", ac: "space", _: new Date().getTime() },
  1156. "GET",
  1157. { responseType: "json" }
  1158. );
  1159. if (res?.state) return { sign: res.sign, time: res.time };
  1160. }
  1161. static driveAddTask({ url, wp_path_id, sign, time }) {
  1162. return request(
  1163. "https://115.com/web/lixian/?ct=lixian&ac=add_task_url",
  1164. { url, wp_path_id, sign, time },
  1165. "POST"
  1166. );
  1167. }
  1168. static driveRename(res) {
  1169. const data = {};
  1170. for (const { fid, file_name } of res) data[`files_new_name[${fid}]`] = file_name;
  1171.  
  1172. return request("https://webapi.115.com/files/batch_rename", data, "POST");
  1173. }
  1174. static driveClear({ pid, fids }) {
  1175. const data = { pid, ignore_warn: 1 };
  1176. fids.forEach(({ fid, cid }, index) => {
  1177. data[`fid[${index}]`] = fid ?? cid;
  1178. });
  1179.  
  1180. return request("https://webapi.115.com/rb/delete", data, "POST");
  1181. }
  1182. static driveInitUpload(params) {
  1183. return request("https://uplb.115.com/3.0/sampleinitupload.php", { userid: "", ...params }, "POST");
  1184. }
  1185. static driveUpload({ host, object, policy, accessid, callback, signature }, blob, name) {
  1186. const formdata = new FormData();
  1187. formdata.append("file", blob, name);
  1188. formdata.append("signature", signature);
  1189. formdata.append("callback", callback);
  1190. formdata.append("success_action_status", 200);
  1191. formdata.append("OSSAccessKeyId", accessid);
  1192. formdata.append("policy", policy);
  1193. formdata.append("key", object);
  1194. formdata.append("name", name);
  1195. return GM_xmlhttpRequest({ method: "POST", url: host, data: formdata });
  1196. }
  1197. static async driveLabel() {
  1198. const res = await request("https://webapi.115.com/label/list?keyword=&limit=115", {}, "GET", {
  1199. responseType: "json",
  1200. });
  1201. if (res?.state) return res.data.list;
  1202. }
  1203. static driveTag({ file_ids, file_label }) {
  1204. return request("https://webapi.115.com/files/batch_label", { file_ids, file_label, action: "add" }, "POST");
  1205. }
  1206. static driveDetail(fid) {
  1207. return request(`https://webapi.115.com/category/get?cid=${fid}`, {}, "GET", {
  1208. responseType: "json",
  1209. });
  1210. }
  1211. }
  1212. class Common {
  1213. menus = [
  1214. {
  1215. title: "站点设置",
  1216. key: "global",
  1217. prefix: "G",
  1218. options: [
  1219. {
  1220. name: "暗黑模式",
  1221. key: "DARK",
  1222. type: "switch",
  1223. info: "常用页面暗黑模式",
  1224. defaultVal: window.matchMedia("(prefers-color-scheme: dark)").matches,
  1225. hotkey: "d",
  1226. },
  1227. {
  1228. name: "快捷搜索",
  1229. key: "SEARCH",
  1230. type: "switch",
  1231. info: "快捷键 <kbd>/</kbd> 获取搜索框焦点,<kbd>Ctrl</kbd> + <kbd>/</kbd> 快速搜索粘贴板首项",
  1232. defaultVal: true,
  1233. hotkey: "k",
  1234. },
  1235. {
  1236. name: "点击事件",
  1237. key: "CLICK",
  1238. type: "switch",
  1239. info: "<code>影片</code> / <code>演员</code> / <code>站点跳转</code> 点击新窗口 (左键前台,右键后台) 打开",
  1240. defaultVal: true,
  1241. hotkey: "c",
  1242. },
  1243. ],
  1244. },
  1245. {
  1246. title: "列表页设置",
  1247. key: "list",
  1248. prefix: "L",
  1249. options: [
  1250. {
  1251. name: "预览替换",
  1252. key: "MIT",
  1253. type: "switch",
  1254. info: "影片预览图替换为封面图",
  1255. defaultVal: true,
  1256. },
  1257. {
  1258. name: "悬停预览",
  1259. key: "MV",
  1260. type: "number",
  1261. info: '设置封面悬停时长 (ms) 以预览视频,建议 300+,0 禁用预览<br>仅 <strong>预览替换</strong> / <strong>(JavDB)大封面</strong> 模式下生效,获取自 <a href="https://javspyl.tk/" class="link-primary">JavSpyl</a> / <a href="https://avpreview.com/zh/" class="link-primary">AVPreview</a> / <a href="https://adult.xiaojiadianmovie.be/" class="link-primary">FC2</a>',
  1262. placeholder: "仅支持整数 ≥ 0",
  1263. defaultVal: 300,
  1264. },
  1265. {
  1266. name: "标题等高",
  1267. key: "MTH",
  1268. type: "switch",
  1269. info: "影片标题强制等高",
  1270. defaultVal: true,
  1271. },
  1272. {
  1273. name: "标题最大行",
  1274. key: "MTL",
  1275. type: "number",
  1276. info: "影片标题最大显示行数,超出省略。0 不限制 (等高模式下最小有效值 1)",
  1277. placeholder: "仅支持整数 ≥ 0",
  1278. defaultVal: 2,
  1279. },
  1280. {
  1281. name: "滚动加载",
  1282. key: "SCROLL",
  1283. type: "switch",
  1284. info: "滚动加载下一页",
  1285. defaultVal: true,
  1286. },
  1287. {
  1288. name: "合并列表",
  1289. key: "MERGE",
  1290. type: "textarea",
  1291. info: "列表名不可重复,同一列表内地址不可重复 (仅支持影片列表相对地址)<br>合并列表每页按 <code>影片评分</code> (如有) > <code>影片日期</code> > <code>填写顺序</code> 综合排序,并自动去重<br>多列表需以空行分隔",
  1292. placeholder: "[列表1]\n/genre/28#连裤袜\n/star/two#星宮一花\n\n[列表2]\n/\n/uncensored",
  1293. defaultVal: "",
  1294. },
  1295. {
  1296. name: "影片筛选",
  1297. key: "FILTER",
  1298. type: "textarea",
  1299. info: '支持 <code>[code]</code> / <code>[title]</code> / <code>[score]</code> / <code>[tags]</code> 分组的 <code>屏蔽</code> (优先) & <code>高亮</code> 规则设置<br>规则类型默认为屏蔽规则,高亮需以 <code>^</code> 开头标识<br>规则语法默认全字符查找,支持追加参数:<code>#start</code> 仅匹配开头,<code>#end</code> 仅匹配结尾<br>规则语法兼容 <a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions" class="link-primary">正则</a> (不同时支持追加参数),格式如 <code>reg:/^stars-/i</code><br><code>[score]</code> 仅 <strong>JavDB</strong>,提取格式如 <code>5.0分, 由6人評價</code><br><code>[tags]</code> 提取格式如 <code>高清,字幕,3天前新種</code><br>格式参考『<strong>合并列表</strong>』',
  1300. placeholder: "[title]\n排泄\n失禁\n\n[code]\n^SSIS-#start\nIPX#start",
  1301. defaultVal: "",
  1302. },
  1303. ],
  1304. },
  1305. {
  1306. title: "详情页设置",
  1307. key: "movie",
  1308. prefix: "M",
  1309. options: [
  1310. {
  1311. name: "在线资源",
  1312. key: "RES",
  1313. type: "input",
  1314. info: '自定义资源配置,支持参数:<br><code>#img</code> 预览大图,<code>#video</code> 视频预览,<code>#player</code> 在线视频<br>获取自 <a href="https://blogjav.net/" class="link-primary">BlogJav</a> / <a href="https://javstore.net/" class="link-primary">JavStore</a>,<a href="https://javspyl.tk/" class="link-primary">JavSpyl</a> / <a href="https://avpreview.com/zh/" class="link-primary">AVPreview</a> / <a href="https://adult.xiaojiadianmovie.be/" class="link-primary">FC2</a> / <a href="https://www.mgstage.com/" class="link-primary">MGS</a> / <a href="https://www.dmm.co.jp/" class="link-primary">DMM</a> / <a href="https://javdb.com/" class="link-primary">JavDB</a>,<a href="https://netflav.com/" class="link-primary">Netflav</a>',
  1315. placeholder: "为空时展示页面默认",
  1316. defaultVal: "#video#img#player",
  1317. },
  1318. {
  1319. name: "快捷复制",
  1320. key: "COPY",
  1321. type: "switch",
  1322. info: "为 <code>标题</code> / <code>番号</code> / <code>演员</code> (右键) / <code>磁链</code> 提供快捷复制",
  1323. defaultVal: true,
  1324. },
  1325. {
  1326. name: "标题机翻",
  1327. key: "TITLE",
  1328. type: "switch",
  1329. info: '翻自 <a href="https://translate.google.com/" class="link-primary">Google</a>',
  1330. defaultVal: true,
  1331. },
  1332. {
  1333. name: "演员匹配",
  1334. key: "STAR",
  1335. type: "switch",
  1336. info: '如无,获取自 <a href="https://www.javlibrary.com/cn/" class="link-primary">JavLibrary</a> / <a href="https://www.dmm.co.jp/" class="link-primary">DMM</a> / <a href="https://javdb.com/" class="link-primary">JavDB</a>',
  1337. defaultVal: true,
  1338. },
  1339. {
  1340. name: "影片评分",
  1341. key: "SCORE",
  1342. type: "input",
  1343. info: '自定义评分配置,支持参数:<br><code>#db</code> 获取自 <a href="https://javdb.com/" class="link-primary">JavDB</a>,<code>#lib</code> 获取自 <a href="https://www.javlibrary.com/cn/" class="link-primary">JavLibrary</a>,<code>#dmm</code> 获取自 <a href="https://www.dmm.co.jp/" class="link-primary">DMM</a>,<code>#mgs</code> 获取自 <a href="https://www.mgstage.com/" class="link-primary">MGS</a>',
  1344. placeholder: "为空时展示页面默认",
  1345. defaultVal: "#db#lib#dmm",
  1346. },
  1347. {
  1348. name: "站点跳转",
  1349. key: "JUMP",
  1350. type: "textarea",
  1351. info: `番号关键词以 <code>${REP}</code> 表示<br>支持追加参数:<code>#query</code> 预查询资源及字幕,<code>#jump</code> 跳转后自动匹配首项<br>格式参考『<strong>合并列表</strong>』`,
  1352. placeholder: `[数据库]\nhttps://javdb.com/search?q=${REP}&f=all#jump\nhttps://www.javlibrary.com/cn/vl_searchbyid.php?keyword=${REP}\n\n[在线视频]\nhttps://www3.bestjavporn.com/search/${REP}/#query#jump\nhttps://jable.tv/search/${REP}/#query#jump\n\n[磁力链接]\nhttps://btdig.com/search?q=${REP}#query\nhttps://idope.se/torrent-list/${REP}/#query`,
  1353. defaultVal: `[跳转]\nhttps://www.JavLibrary.com/cn/vl_searchbyid.php?keyword=${REP}#query#jump\nhttps://${
  1354. Domain === "JavDB" ? `www.JavBus.com/search/${REP}` : `JavDB.com/search?f=all&q=${REP}&sb=0`
  1355. }#query#jump`,
  1356. },
  1357. {
  1358. name: "磁链最大行",
  1359. key: "LINE",
  1360. type: "number",
  1361. info: "磁力链接最大显示行数,超出以滚动显示。0 不限制",
  1362. placeholder: "仅支持整数 ≥ 0",
  1363. defaultVal: 10,
  1364. },
  1365. {
  1366. name: "字幕筛选",
  1367. key: "SUB",
  1368. type: "switch",
  1369. info: '替换为 <a href="https://javdb.com/" class="link-primary">JavDB</a> 磁链数据',
  1370. defaultVal: false,
  1371. },
  1372. {
  1373. name: "磁链排序",
  1374. key: "SORT",
  1375. type: "switch",
  1376. info: "综合排序 <code>字幕</code> > <code>大小</code> > <code>日期</code>",
  1377. defaultVal: true,
  1378. },
  1379. {
  1380. name: "磁链搜索",
  1381. key: "MAGNET",
  1382. type: "input",
  1383. info: '自定义搜索配置并自动去重,支持参数:<br><code>#suk</code> 获取自 <a href="https://sukebei.nyaa.si/" class="link-primary">Sukebei</a>,<code>#bts</code> 获取自 <a href="https://btsow.com/" class="link-primary">BTSOW</a>,<code>#btd</code> 获取自 <a href="https://btdig.com/" class="link-primary">BTDigg</a>',
  1384. placeholder: "为空时展示页面默认",
  1385. defaultVal: "#btd#bts#suk",
  1386. },
  1387. ],
  1388. },
  1389. {
  1390. title: "115 相关",
  1391. key: "drive",
  1392. prefix: "D",
  1393. options: [
  1394. {
  1395. name: "网盘资源",
  1396. key: "MATCH",
  1397. type: "switch",
  1398. info: '<strong>需要 <a href="https://115.com/" class="link-primary">网盘</a> 已登录,并调整文件排序方式为 <code>修改时间</code></strong><br>列表页:网盘资源匹配<br>详情页:网盘资源匹配 & (一键) 离线按钮开关<br>(完整体验建议允许弹窗通知权限)',
  1399. defaultVal: true,
  1400. },
  1401. {
  1402. name: "列表离线",
  1403. key: "LOL",
  1404. type: "switch",
  1405. info: "影片列表支持简易『<strong>一键离线</strong>』执行动作:<br>『<strong>磁链搜索</strong>』『<strong>磁链排序</strong>』『<strong>离线验证</strong>』『<strong>最大失败数</strong>』『<strong>离线清理</strong>』『<strong>文件重命名</strong>』",
  1406. defaultVal: true,
  1407. },
  1408. {
  1409. name: "下载目录",
  1410. key: "CID",
  1411. type: "input",
  1412. info: "设置离线下载目录 <strong>cid</strong> 或 <strong>动态目录</strong> (未找到时动态创建),建议直接填写 <strong>cid</strong> 效率更高<br><strong>动态目录</strong> 支持填写 <strong>目录名称</strong> 和 <strong>动态参数</strong>:<br><code>${#star}</code> (首位) 女演员<br><code>${#series}</code> 系列<br><code>${#studio}</code> 制造商 / 片商 / 卖家<br><strong>目录名称</strong> & <strong>动态参数</strong> 可组合使用,如 <code>${#series/#star/云下载}</code>",
  1413. placeholder: "cid 或 动态目录",
  1414. defaultVal: "${云下载}",
  1415. },
  1416. {
  1417. name: "离线验证",
  1418. key: "VERIFY",
  1419. type: "number",
  1420. info: "添加离线后执行,查询以验证离线下载结果,每次间隔一秒<br>设置验证次数上限,上限次数越多验证越精准<br>建议 3 ~ 5,默认 5",
  1421. placeholder: "仅支持整数 ≥ 0",
  1422. defaultVal: 5,
  1423. },
  1424. {
  1425. name: "最大失败数",
  1426. key: "FAIL",
  1427. type: "number",
  1428. info: "『<strong>一键离线</strong>』时累计验证失败的磁链数,最大值时终止本次任务。0 不限制",
  1429. placeholder: "仅支持整数 ≥ 0",
  1430. defaultVal: 5,
  1431. },
  1432. {
  1433. name: "离线清理",
  1434. key: "CLEAR",
  1435. type: "switch",
  1436. info: "『<strong>离线验证</strong>』成功后执行,匹配番号以清理无关文件",
  1437. defaultVal: true,
  1438. },
  1439. {
  1440. name: "文件重命名",
  1441. key: "RENAME",
  1442. type: "input",
  1443. info: '『<strong>离线验证</strong>』成功后执行,支持参数:<br><code>${字幕}</code> "【中文字幕】",非字幕资源则为空<br><code>${番号}</code> 页面番号 (番号为必须值,如重命名未包含将自动追加前缀)<br><code>${标题}</code> 页面标题,已去除番号<br><code>${序号}</code> 仅作用于视频文件,数字 1 起',
  1444. placeholder: "勿填写后缀,可能导致资源不可用",
  1445. defaultVal: "${字幕}${番号} ${标题}",
  1446. },
  1447. {
  1448. name: "自动打标",
  1449. key: "TAG",
  1450. type: "input",
  1451. info: "『<strong>离线验证</strong>』成功后执行,根据设置值匹配网盘已有标签自动打标,支持参数:<br><code>#genre</code> 类别,<code>#star</code> 演员",
  1452. placeholder: "如 #genre#star",
  1453. defaultVal: "#genre#star",
  1454. },
  1455. {
  1456. name: "图片上传",
  1457. key: "UPLOAD",
  1458. type: "input",
  1459. info: "『<strong>离线验证</strong>』成功后执行 (弹窗通知),支持参数:<br><code>#cover</code> 封面图,<code>#img</code> 预览大图 (通常较大,确保网络通畅并耐心等待上传)",
  1460. placeholder: "如 #cover#img",
  1461. defaultVal: "#cover#img",
  1462. },
  1463. {
  1464. name: "资源调整",
  1465. key: "MODIFY",
  1466. type: "input",
  1467. info: "针对详情页网盘匹配资源的自定义调整配置,支持参数 (顺序不分先后):<br><code>#delete</code> 删除对应视频文件,并忽略其他参数<br><code>#rename</code> 详见『<strong>文件重命名</strong>』<br><code>#upload</code> 详见『<strong>图片上传</strong>』<br><code>#clear</code> 详见『<strong>离线清理</strong>』<br><code>#tag</code> 详见『<strong>自动打标</strong>』",
  1468. placeholder: "如 #rename#clear#tag#upload",
  1469. defaultVal: "#rename#clear#tag#upload",
  1470. },
  1471. ],
  1472. },
  1473. {
  1474. title: "进阶",
  1475. key: "advanced",
  1476. prefix: "A",
  1477. options: [
  1478. {
  1479. name: "资源跳转",
  1480. key: "LINK",
  1481. type: "textarea",
  1482. info: "自定义网盘资源跳转链接,兼容列表及详情页,仅支持分组 <code>[left]</code> / <code>[right]</code>,链接参数:<br><code>${#pickcode}</code> 可用于跳转播放<br><code>${#cid}</code> 可用于跳转目录<br><code>${#path}</code> 资源路径<br><code>${#name}</code> 资源名称<br>格式参考『<strong>合并列表</strong>』",
  1483. placeholder:
  1484. "[left]\nhttps://v.anxia.com/?pickcode=${#pickcode}\n\n[right]\nhttps://115.com/?cid=${#cid}&offset=0&mode=wangpan",
  1485. defaultVal: "",
  1486. },
  1487. ],
  1488. },
  1489. ];
  1490. style = {
  1491. custom: `
  1492. :root {
  1493. --x-bgc: #121212;
  1494. --x-sub-bgc: #202020;
  1495. --x-ftc: #fffffff2;
  1496. --x-sub-ftc: #aaa;
  1497. --x-grey: #313131;
  1498. --x-blue: #0a84ff;
  1499. --x-orange: #ff9f0a;
  1500. --x-green: #30d158;
  1501. --x-red: #ff453a;
  1502. --x-yellow: #ffd60a;
  1503. --x-line-h: 22px;
  1504. --x-thumb-w: 190px;
  1505. --x-cover-w: 360px;
  1506. --x-thumb-ratio: 147 / 200;
  1507. --x-cover-ratio: 400 / 269;
  1508. --x-avatar-ratio: 1;
  1509. --x-sprite-ratio: 4 / 3;
  1510. }
  1511. .x-hide, .x-scrollbar-hide body::-webkit-scrollbar {
  1512. display: none !important;
  1513. }
  1514. .x-show {
  1515. display: block !important;
  1516. }
  1517. #x-mask {
  1518. position: fixed;
  1519. top: 0;
  1520. left: 0;
  1521. z-index: 9999;
  1522. display: none;
  1523. box-sizing: border-box;
  1524. width: 100vw;
  1525. height: 100vh;
  1526. margin: 0;
  1527. padding: 0;
  1528. background: transparent;
  1529. border: none;
  1530. }
  1531. .x-in {
  1532. opacity: 1 !important;
  1533. transition: opacity .25s linear !important;
  1534. }
  1535. .x-cover {
  1536. width: var(--x-cover-w) !important;
  1537. }
  1538. .x-cover > :first-child {
  1539. aspect-ratio: var(--x-cover-ratio) !important;
  1540. }
  1541. .x-cover img {
  1542. object-fit: contain !important;
  1543. }
  1544. .x-ellipsis {
  1545. display: -webkit-box !important;
  1546. overflow: hidden;
  1547. white-space: unset !important;
  1548. text-overflow: ellipsis;
  1549. -webkit-line-clamp: 1;
  1550. -webkit-box-orient: vertical;
  1551. word-break: break-all;
  1552. }
  1553. .x-line {
  1554. overflow: hidden;
  1555. white-space: nowrap;
  1556. text-overflow: ellipsis;
  1557. }
  1558. #x-status {
  1559. margin-bottom: 20px;
  1560. color: var(--x-sub-ftc);
  1561. font-size: 14px !important;
  1562. text-align: center;
  1563. }
  1564. .x-highlight {
  1565. box-shadow: 0 0 0 4px var(--x-red) !important;
  1566. }
  1567. .x-ml {
  1568. margin-left: 10px;
  1569. }
  1570. .x-side {
  1571. position: absolute;
  1572. top: 50%;
  1573. z-index: 7;
  1574. display: flex;
  1575. align-items: center;
  1576. justify-content: center;
  1577. width: 60px;
  1578. height: 60px;
  1579. color: var(--x-sub-bgc);
  1580. font-size: 30px;
  1581. background: #fff;
  1582. border-radius: 50%;
  1583. transform: translateY(-50%);
  1584. cursor: pointer;
  1585. opacity: .4;
  1586. transition: opacity .2s linear;
  1587. user-select: none;
  1588. }
  1589. .x-side:hover {
  1590. opacity: .8;
  1591. }
  1592. .x-side > * {
  1593. top: 0;
  1594. }
  1595. .x-side.prev {
  1596. left: 30px;
  1597. }
  1598. .x-side.next {
  1599. right: 30px;
  1600. }
  1601. .x-flex-center {
  1602. display: flex !important;
  1603. align-items: center;
  1604. }
  1605. .x-grid {
  1606. display: grid !important;
  1607. }
  1608. *:has(> .x-jump) {
  1609. margin-right: -5px !important;
  1610. }
  1611. .x-jump {
  1612. min-width: 44px;
  1613. margin: 0 5px 5px 0 !important;
  1614. cursor: pointer;
  1615. }
  1616. .x-title {
  1617. line-height: var(--x-line-h) !important;
  1618. }
  1619. *:has(> .x-player) .x-title {
  1620. color: var(--x-blue) !important;
  1621. font-weight: bold;
  1622. }
  1623. .x-preview,
  1624. .x-loading *:has(> img),
  1625. .x-player {
  1626. position: relative;
  1627. display: block;
  1628. overflow: hidden;
  1629. }
  1630. .x-loading *:has(> img)::before,
  1631. .x-player::before,
  1632. .x-player::after {
  1633. position: absolute;
  1634. top: 50%;
  1635. left: 50%;
  1636. cursor: pointer;
  1637. opacity: .8;
  1638. content: "";
  1639. }
  1640. .x-loading *:has(> img):not(.x-player)::before,
  1641. .x-player::before {
  1642. z-index: 8;
  1643. width: 60px;
  1644. height: 60px;
  1645. background: #0a5ee0;
  1646. border-radius: 50%;
  1647. filter: drop-shadow(2px 5px 10px rgb(0 0 0 / 50%));
  1648. translate: -50% -50%;
  1649. }
  1650. .x-loading *:has(> img)::before,
  1651. .x-zh.x-player::before {
  1652. border: 6px solid var(--x-yellow);
  1653. }
  1654. .x-player::after {
  1655. z-index: 9;
  1656. border-top: 15px solid transparent;
  1657. border-bottom: 15px solid transparent;
  1658. border-left: 30px solid #fff;
  1659. transform: translate(-40%, -50%);
  1660. }
  1661. .x-loading *:has(> img)::before {
  1662. border-color: transparent;
  1663. border-bottom-color: var(--x-orange) !important;
  1664. animation: rotation 1s linear infinite;
  1665. }
  1666. .x-loading *:has(> img):not(.x-player)::before {
  1667. background: transparent;
  1668. border-color: #000c;
  1669. }
  1670. .x-loading.success *:has(> img)::before {
  1671. border-color: var(--x-green) !important;
  1672. }
  1673. .x-loading.timeout *:has(> img)::before {
  1674. border-color: var(--x-orange) !important;
  1675. }
  1676. .x-loading.fail *:has(> img)::before {
  1677. border-color: var(--x-red) !important;
  1678. }
  1679. @keyframes rotation {
  1680. 0% {
  1681. rotate: 0deg;
  1682. }
  1683. 100% {
  1684. rotate: 360deg;
  1685. }
  1686. }
  1687. .x-preview :is(img, video) {
  1688. position: absolute;
  1689. top: 0;
  1690. left: 0;
  1691. width: 100%;
  1692. height: 100%;
  1693. object-fit: contain;
  1694. }
  1695. .x-preview video {
  1696. z-index: 10;
  1697. background-color: inherit;
  1698. opacity: 0;
  1699. transition: opacity .25s ease-in !important;
  1700. }
  1701. .x-preview video::-webkit-media-controls-fullscreen-button {
  1702. display: none;
  1703. }
  1704. .x-btn {
  1705. display: none;
  1706. margin-right: 4px;
  1707. padding: 1px 4px;
  1708. color: #fff !important;
  1709. font-weight: normal;
  1710. font-size: calc(1em - 2px);
  1711. background: var(--x-blue);
  1712. border-radius: 2px;
  1713. cursor: pointer;
  1714. }
  1715. .x-btn::after {
  1716. content: "调整";
  1717. }
  1718. .x-btn.active {
  1719. cursor: wait;
  1720. opacity: .8;
  1721. }
  1722. .x-btn.active::after {
  1723. content: "请求中...";
  1724. }
  1725. .x-btn.pending::after {
  1726. content: "校验中...";
  1727. }
  1728. `,
  1729. common: "::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-thumb{background:var(--x-sub-ftc,#aaa);border-radius:4px}*{text-decoration:none!important;text-shadow:none!important;outline:0!important}",
  1730. dark: "::-webkit-scrollbar-thumb,button{background:var(--x-grey)!important}*{box-shadow:none!important}:not(span[class]){border-color:var(--x-grey)!important}body,html,input{background:var(--x-bgc)!important}::placeholder,body{color:var(--x-sub-ftc)!important}nav{background:var(--x-sub-bgc)!important}a,button,h3,h4,input,p{color:var(--x-ftc)!important}img,video{filter:brightness(.9) contrast(.9)!important}",
  1731. };
  1732.  
  1733. init() {
  1734. Store.init();
  1735. const key = Object.keys(this.routes).find(key => this.routes[key].test(location.pathname));
  1736. this.registerMenu(key);
  1737. return { ...this, ...this[key] };
  1738. }
  1739. registerMenu(active) {
  1740. const exclude = this.excludeMenu ?? [];
  1741. const menus = this.menus.filter(item => !exclude.includes(`${item.prefix}_`));
  1742. const { length } = menus;
  1743. if (!length) return;
  1744.  
  1745. let tabStr = "";
  1746. let panelStr = "";
  1747. const commands = [];
  1748. if (!menus.some(item => item.key === active)) active = menus[0].key;
  1749. for (let index = 0; index < length; index++) {
  1750. const { title, key, prefix, options } = menus[index];
  1751.  
  1752. let sections = "";
  1753. for (let idx = 0, len = options.length; idx < len; idx++) {
  1754. let { name, key: curKey, type, info, placeholder = "", defaultVal, hotkey = "" } = options[idx];
  1755. curKey = `${prefix}_${curKey}`;
  1756. if (exclude.includes(curKey)) continue;
  1757.  
  1758. commands.push(curKey);
  1759. const uniKey = `${Domain}_${curKey}`;
  1760. const val = GM_getValue(uniKey, defaultVal);
  1761. this[curKey] = val;
  1762.  
  1763. let section = "";
  1764. if (type === "switch") {
  1765. if (hotkey && hotkey !== "s") {
  1766. GM_registerMenuCommand(
  1767. `${val ? "关闭" : "开启"}${name}`,
  1768. () => {
  1769. GM_setValue(uniKey, !val);
  1770. location.reload();
  1771. },
  1772. hotkey
  1773. );
  1774. }
  1775. section = `
  1776. <div class="form-check form-switch">
  1777. <input
  1778. type="checkbox"
  1779. class="form-check-input"
  1780. role="switch"
  1781. id="${curKey}"
  1782. aria-describedby="${curKey}_Help"
  1783. ${val ? "checked" : ""}
  1784. name="${curKey}"
  1785. >
  1786. <label class="form-check-label" for="${curKey}">${name}</label>
  1787. </div>
  1788. `;
  1789. } else if (type === "textarea") {
  1790. section = `
  1791. <label class="form-label" for="${curKey}">${name}</label>
  1792. <textarea
  1793. rows="5"
  1794. class="form-control"
  1795. id="${curKey}"
  1796. aria-describedby="${curKey}_Help"
  1797. placeholder="${placeholder}"
  1798. name="${curKey}"
  1799. >${val ?? ""}</textarea>
  1800. `;
  1801. } else {
  1802. section = `
  1803. <label class="form-label" for="${curKey}">${name}</label>
  1804. <input
  1805. type="${type}"
  1806. class="form-control"
  1807. id="${curKey}"
  1808. aria-describedby="${curKey}_Help"
  1809. value="${val ?? ""}"
  1810. placeholder="${placeholder}"
  1811. name="${curKey}"
  1812. >
  1813. `;
  1814. }
  1815. if (info) section += `<div id="${curKey}_Help" class="form-text">${info}</div>`;
  1816. sections += `<div class="mb-3">${section}</div>`;
  1817. }
  1818. if (!sections) continue;
  1819.  
  1820. const isActive = key === active;
  1821. tabStr += `
  1822. <button
  1823. class="nav-link${isActive ? " active" : ""} text-start"
  1824. id="${key}-tab"
  1825. data-bs-toggle="pill"
  1826. data-bs-target="#${key}"
  1827. type="button"
  1828. role="tab"
  1829. aria-controls="${key}"
  1830. aria-selected="${isActive}"
  1831. >${title}</button>
  1832. `;
  1833. panelStr += `
  1834. <div
  1835. class="tab-pane fade${isActive ? " show active" : ""}"
  1836. id="${key}"
  1837. role="tabpanel"
  1838. aria-labelledby="${key}-tab"
  1839. tabindex="0"
  1840. >
  1841. ${sections}
  1842. </div>
  1843. `;
  1844. }
  1845. if (!tabStr || !panelStr) return;
  1846.  
  1847. GM_addStyle(this.style.custom);
  1848. DOC.addEventListener(
  1849. "XContentLoaded",
  1850. () => {
  1851. const title = `${GM_info.script.name} v${GM_info.script.version}`;
  1852. DOC.body.insertAdjacentHTML(
  1853. "beforeend",
  1854. `<iframe id="x-mask" src="about:blank" title="${title}"></iframe>`
  1855. );
  1856. const iframe = DOC.querySelector("#x-mask");
  1857. const _DOC = iframe.contentWindow.document;
  1858. const { body } = _DOC;
  1859.  
  1860. _DOC.head.insertAdjacentHTML(
  1861. "beforeend",
  1862. `<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous"><style>${this.style.common}*{overscroll-behavior-y:contain}</style><base target="_blank">`
  1863. );
  1864. GM_addElement(body, "script", {
  1865. src: "https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.min.js",
  1866. integrity: "sha384-IDwe1+LCz02ROU9k972gdyvl+AESN10+x7tBKgc9I5HFtuNz0wWnPclzo6p9vxnk",
  1867. crossorigin: "anonymous",
  1868. });
  1869.  
  1870. body.classList.add("bg-transparent");
  1871. body.insertAdjacentHTML(
  1872. "afterbegin",
  1873. `<button
  1874. id="openControlPanel"
  1875. type="button"
  1876. class="d-none"
  1877. data-bs-toggle="modal"
  1878. data-bs-target="#controlPanel"
  1879. >openControlPanel</button>
  1880. <div
  1881. class="modal fade"
  1882. id="controlPanel"
  1883. tabindex="-1"
  1884. aria-labelledby="controlPanelLabel"
  1885. aria-hidden="true"
  1886. >
  1887. <div class="modal-dialog modal-lg modal-fullscreen-lg-down modal-dialog-scrollable">
  1888. <div class="modal-content">
  1889. <div class="modal-header">
  1890. <h5 class="modal-title fs-5" id="controlPanelLabel">控制面板
  1891. - <a
  1892. href="https://sleazyfork.org/zh-CN/scripts/435360-javscript"
  1893. class="link-secondary"
  1894. >${title}</a>
  1895. </h5>
  1896. <button
  1897. type="button"
  1898. class="btn-close"
  1899. data-bs-dismiss="modal"
  1900. aria-label="Close"
  1901. ></button>
  1902. </div>
  1903. <div class="modal-body">
  1904. <form class="mb-0">
  1905. <div class="d-flex align-items-start">
  1906. <div
  1907. class="nav flex-column nav-pills me-4 sticky-top"
  1908. id="v-pills-tab"
  1909. role="tablist"
  1910. aria-orientation="vertical"
  1911. >
  1912. ${tabStr}
  1913. </div>
  1914. <div class="tab-content flex-fill" id="v-pills-tabContent">
  1915. ${panelStr}
  1916. </div>
  1917. </div>
  1918. </form>
  1919. </div>
  1920. <div class="modal-footer">
  1921. <div class="flex-fill">
  1922. <div class="btn-group" role="group" aria-label="Import and Export">
  1923. <button type="button" class="btn btn-link" data-action="import">导入</button>
  1924. <button type="button" class="btn btn-link" data-action="export">导出</button>
  1925. </div>
  1926. </div>
  1927. <button
  1928. type="button"
  1929. class="btn btn-danger"
  1930. data-bs-dismiss="modal"
  1931. data-action="restart"
  1932. >重置脚本</button>
  1933. <button
  1934. type="button"
  1935. class="btn btn-secondary"
  1936. data-bs-dismiss="modal"
  1937. data-action="clear"
  1938. >清除缓存</button>
  1939. <button
  1940. type="button"
  1941. class="btn btn-secondary"
  1942. data-bs-dismiss="modal"
  1943. data-action="reset"
  1944. >默认设置</button>
  1945. <button
  1946. type="button"
  1947. class="btn btn-primary"
  1948. data-bs-dismiss="modal"
  1949. data-action="save"
  1950. >保存设置</button>
  1951. </div>
  1952. </div>
  1953. </div>
  1954. </div>`
  1955. );
  1956. body.querySelector("#controlPanel .modal-footer").addEventListener("click", e => {
  1957. const { action } = e.target.dataset;
  1958. if (!action) return;
  1959.  
  1960. e.preventDefault();
  1961. e.stopPropagation();
  1962.  
  1963. const prefixes = MatchDomains.slice(0, -1).map(item => item.domain);
  1964. if (action === "import") {
  1965. const upConfig = file => {
  1966. const fileReader = new FileReader();
  1967. fileReader.readAsText(file);
  1968. fileReader.onload = () => {
  1969. for (const [key, val] of Object.entries(JSON.parse(fileReader.result))) {
  1970. if (prefixes.includes(key.split("_")[0])) GM_setValue(key, val);
  1971. }
  1972. location.reload();
  1973. };
  1974. };
  1975.  
  1976. const upload = DOC.create("input", { type: "file", accept: ".json" });
  1977. upload.addEventListener(
  1978. "change",
  1979. e => {
  1980. const file = e.target.files[0];
  1981. if (file?.type !== "application/json") return;
  1982. if (file.name.split(".json")[0] === title) return upConfig(file);
  1983. if (window.confirm("导入配置可能与当前版本不符,是否继续?")) return upConfig(file);
  1984. },
  1985. false
  1986. );
  1987. return upload.click();
  1988. }
  1989. if (action === "export") {
  1990. const config = {};
  1991. GM_listValues().forEach(key => {
  1992. if (prefixes.includes(key.split("_")[0])) config[key] = GM_getValue(key);
  1993. });
  1994. const blob = new Blob([JSON.stringify(config, null, 2)], { type: "application/json" });
  1995.  
  1996. const download = DOC.create("a", {
  1997. download: `${title}.json`,
  1998. href: URL.createObjectURL(blob),
  1999. });
  2000. return download.click();
  2001. }
  2002. if (action === "save") {
  2003. const data = Object.fromEntries(
  2004. new FormData(body.querySelector("#controlPanel form")).entries()
  2005. );
  2006. commands.forEach(key => GM_setValue(`${Domain}_${key}`, data[key] ?? ""));
  2007. }
  2008. if (action === "reset") {
  2009. GM_listValues().forEach(name => name.startsWith(Domain) && GM_deleteValue(name));
  2010. }
  2011. if (action === "clear") {
  2012. GM_setValue("DETAILS", {});
  2013. GM_setValue("RESOURCE", {});
  2014. localStorage.clear();
  2015. }
  2016. if (action === "restart") GM_listValues().forEach(name => GM_deleteValue(name));
  2017.  
  2018. location.reload();
  2019. });
  2020.  
  2021. const toggleIframe = () => {
  2022. DOC.body.parentNode.classList.toggle("x-scrollbar-hide");
  2023. iframe.classList.toggle("x-show");
  2024. };
  2025. const openModal = () => {
  2026. if (iframe.classList.contains("x-show")) return;
  2027. toggleIframe();
  2028. _DOC.querySelector("#openControlPanel").click();
  2029. };
  2030. GM_registerMenuCommand("控制面板", openModal, "s");
  2031. _DOC.querySelector("#controlPanel").addEventListener("hidden.bs.modal", toggleIframe);
  2032. },
  2033. { once: true }
  2034. );
  2035. }
  2036.  
  2037. // G_DARK
  2038. globalDark = (style = "", dmStyle = "") => {
  2039. if (!style && !dmStyle) return;
  2040.  
  2041. const { common, dark } = this.style;
  2042. if (style && common) style = `${common}${style}`;
  2043. if (!this.G_DARK) dmStyle = "";
  2044. if (dmStyle && dark) dmStyle = `${dark}${dmStyle}`;
  2045.  
  2046. const css = `${style}${dmStyle}`;
  2047. if (css) GM_addStyle(css);
  2048. };
  2049. // G_SEARCH
  2050. globalSearch = () => {
  2051. if (!this.G_SEARCH) return;
  2052.  
  2053. const { selectors, pathname } = this.search;
  2054. if (selectors) {
  2055. DOC.addEventListener("keyup", ({ code }) => {
  2056. if (code !== "Slash" || ["INPUT", "TEXTAREA"].includes(DOC.activeElement.nodeName)) return;
  2057. DOC.querySelector(selectors)?.focus();
  2058. });
  2059. }
  2060. if (pathname) {
  2061. DOC.addEventListener("keydown", async e => {
  2062. if (e.ctrlKey && e.code === "Slash") {
  2063. const text = await navigator.clipboard.readText();
  2064. if (text) openInTab(`${location.origin}${pathname}#jump#${REP}`.replaceAll(REP, text));
  2065. }
  2066. });
  2067. }
  2068. };
  2069. // G_CLICK
  2070. globalClick = () => {
  2071. const { selectors, codeQuery, upQuery } = this.click;
  2072. if (!selectors?.length) return;
  2073.  
  2074. selectors.push(".x-jump");
  2075. const getTarget = ({ target }) => target.closest(selectors) || false;
  2076.  
  2077. DOC.addEventListener("click", e => {
  2078. const closest = getTarget(e);
  2079. if (!closest) return;
  2080.  
  2081. let url = "";
  2082. let code = "";
  2083. const { classList, dataset } = e.target;
  2084.  
  2085. if (classList.contains("x-player") && dataset.pc) {
  2086. return this.advancedLink(e, { type: "left" });
  2087. } else if (classList.contains("x-btn") && dataset.code) {
  2088. return this.driveListOffLine(e, dataset);
  2089. } else if (classList.contains("x-jump") && dataset.href) {
  2090. url = dataset.href;
  2091. } else if (closest.href) {
  2092. url = closest.href;
  2093. if (codeQuery) code = closest.querySelector(codeQuery)?.textContent;
  2094. }
  2095. if (!url) return;
  2096.  
  2097. e.preventDefault();
  2098. e.stopPropagation();
  2099. if (this.G_CLICK) {
  2100. const tab = openInTab(url);
  2101. if (code) tab.onclose = () => this.driveMatchForList([{ item: closest, code }], upQuery);
  2102. return;
  2103. }
  2104. location.href = url;
  2105. });
  2106. if (!this.G_CLICK) return;
  2107.  
  2108. let _event;
  2109. DOC.addEventListener("mousedown", e => {
  2110. if (e.button !== 2) return;
  2111.  
  2112. const target = getTarget(e);
  2113. if (!target) return;
  2114.  
  2115. e.preventDefault();
  2116. target.oncontextmenu = e => e.preventDefault();
  2117. _event = e;
  2118. });
  2119. DOC.addEventListener("mouseup", e => {
  2120. if (e.button !== 2 || !_event) return;
  2121.  
  2122. const target = getTarget(e);
  2123. if (!target) return;
  2124.  
  2125. e.preventDefault();
  2126. const { clientX, clientY } = e;
  2127. const { clientX: _clientX, clientY: _clientY } = _event;
  2128. if (Math.abs(clientX - _clientX) + Math.abs(clientY - _clientY) > 5) return;
  2129. if (target.dataset.href) return openInTab(target.dataset.href, false);
  2130.  
  2131. const tab = openInTab(target.href, false);
  2132. const code = codeQuery ? target.querySelector(codeQuery)?.textContent : "";
  2133. if (code) tab.onclose = () => this.driveMatchForList([{ item: target, code }], upQuery);
  2134. });
  2135. };
  2136.  
  2137. // L_MIT
  2138. listMovieImgType = (node, condition) => {
  2139. if (!this.L_MIT) return;
  2140.  
  2141. const img = node.querySelector("img");
  2142. if (!img) return;
  2143.  
  2144. node.classList.add("x-cover");
  2145. const { src = "" } = img;
  2146. img.src = condition.find(({ regex }) => regex.test(src))?.replace(src) ?? src;
  2147. };
  2148. // L_MV
  2149. listMovieVideo = container => {
  2150. if (!container.querySelector(".movie-list:is(.h, .cols-3) .cover, .movie-box.x-cover")) return;
  2151.  
  2152. const DELAY = parseInt(this.L_MV ?? 0, 10);
  2153. if (DELAY <= 0) return;
  2154.  
  2155. let locking = null;
  2156. unsafeWindow.addEventListener("scroll", () => {
  2157. if (locking) clearTimeout(locking);
  2158.  
  2159. if (!container.style.pointerEvents) container.style.pointerEvents = "none";
  2160.  
  2161. locking = setTimeout(() => {
  2162. container.style.pointerEvents = "";
  2163. }, 100);
  2164. });
  2165.  
  2166. const { selectors, codeQuery, upQuery } = this.click;
  2167. const ITEM_NODE = selectors[0];
  2168. const LOCK_NODE = "x-loading";
  2169. const HOLD_NODE = "x-holding";
  2170. let current = null;
  2171. let timer = null;
  2172.  
  2173. DOC.addEventListener("mouseover", ({ relatedTarget, target }) => {
  2174. if (current) {
  2175. if (timer && relatedTarget?.nodeName === "IMG" && target.contains(relatedTarget)) {
  2176. clearTimeout(timer);
  2177. current = null;
  2178. }
  2179. return;
  2180. }
  2181.  
  2182. target = target.closest(upQuery);
  2183. if (!target) return;
  2184.  
  2185. if (!container.contains(target)) return;
  2186.  
  2187. current = target;
  2188. showPreview(current);
  2189. });
  2190. DOC.addEventListener("mouseout", ({ relatedTarget }) => {
  2191. if (!current) return;
  2192.  
  2193. while (relatedTarget) {
  2194. if (relatedTarget === current) return;
  2195. relatedTarget = relatedTarget.parentNode;
  2196. }
  2197.  
  2198. hidePreview(current);
  2199. current = null;
  2200. });
  2201.  
  2202. const showPreview = cover => {
  2203. cover.classList.add("x-preview", HOLD_NODE);
  2204. timer = setTimeout(() => getVideo(cover), DELAY < 100 ? 100 : DELAY);
  2205. };
  2206. const hidePreview = cover => {
  2207. cover.classList.remove(HOLD_NODE);
  2208. if (timer) clearTimeout(timer);
  2209.  
  2210. const video = cover.querySelector("video");
  2211. if (!video) return;
  2212.  
  2213. video.classList.remove("x-in");
  2214. setTimeout(() => video.remove(), 250);
  2215. };
  2216.  
  2217. const getVideo = cover => {
  2218. const closest = cover.closest(ITEM_NODE);
  2219. if (!closest || closest.classList.contains(LOCK_NODE)) return;
  2220.  
  2221. let code = closest.querySelector(codeQuery)?.textContent.trim() ?? "";
  2222. if (!code) return;
  2223.  
  2224. code = /^FC2-\d/i.test(code) ? code.replace("-", "-PPV-") : code;
  2225. let { video, poster } = cover.dataset;
  2226.  
  2227. if (!video) {
  2228. const detail = Store.getDetail(code);
  2229. if (detail.video) {
  2230. video = detail.video;
  2231. cover.setAttribute("data-video", video);
  2232. }
  2233. }
  2234. if (!poster) {
  2235. poster = cover.querySelector("img")?.src ?? "";
  2236. cover.setAttribute("data-poster", poster);
  2237. }
  2238. if (video) return setVideo(cover);
  2239.  
  2240. closest.classList.add(LOCK_NODE);
  2241. const _timer = setTimeout(() => cancelLock("timeout"), 8000);
  2242. let count = FC2_REGEX.test(code) ? 7 : 6;
  2243.  
  2244. const cancelLock = status => {
  2245. if (_timer) clearTimeout(_timer);
  2246. count = 0;
  2247.  
  2248. if (status === "success" && cover.classList.contains(HOLD_NODE)) {
  2249. return closest.classList.remove(LOCK_NODE);
  2250. }
  2251. closest.classList.add(status);
  2252. setTimeout(() => closest.classList.remove(status, LOCK_NODE), 800);
  2253. };
  2254. const callback = ({ video }) => {
  2255. if (count <= 0) return;
  2256.  
  2257. if (!video) {
  2258. count--;
  2259. if (count <= 0) cancelLock("fail");
  2260. } else {
  2261. cancelLock("success");
  2262. cover.setAttribute("data-video", video);
  2263. Store.upDetail(code, { video });
  2264. setVideo(cover);
  2265. }
  2266. };
  2267.  
  2268. if (count === 7) Apis.fetchFC2(code).then(callback);
  2269. Apis.fetchAVPreview(code).then(callback);
  2270. Apis.fetchJavSpyl(code).then(callback);
  2271. Apis.fetchVBGFL(code).then(callback);
  2272. Apis.fetchDMM({ code }).then(({ fetchVideo }) => {
  2273. if (fetchVideo) fetchVideo().then(callback);
  2274. });
  2275.  
  2276. const isVR = VR_REGEX.test(closest.textContent);
  2277. Apis.fetchVideoByGuess({ code, isVR }).then(callback);
  2278. Apis.fetchVBL({ node: closest, isVR }).then(callback);
  2279. };
  2280. const setVideo = cover => {
  2281. if (!cover.classList.contains(HOLD_NODE) || cover.querySelector("video")) return;
  2282.  
  2283. let { video, poster } = cover.dataset;
  2284. video = DOC.create("video", {
  2285. poster,
  2286. src: video,
  2287. "x-webkit-airplay": "deny",
  2288. controlslist: "nodownload nofullscreen noremoteplayback noplaybackrate",
  2289. preload: "metadata",
  2290. title: "",
  2291. });
  2292. video.autoplay = true;
  2293. video.autoPictureInPicture = false;
  2294. video.controls = true;
  2295. video.currentTime = 3;
  2296. video.disablePictureInPicture = true;
  2297. video.disableRemotePlayback = true;
  2298. video.loop = true;
  2299. video.muted = true;
  2300. video.playsInline = true;
  2301. video.volume = localStorage.getItem("volume") ?? 0.2;
  2302. video.addEventListener("keyup", ({ code, target }) => {
  2303. if (code === "KeyM") target.muted = !target.muted;
  2304. });
  2305. cover.append(video);
  2306. video?.focus();
  2307. video?.load();
  2308. setTimeout(() => video?.classList?.add("x-in"), 50);
  2309. };
  2310. };
  2311. // L_MTH, L_MTL
  2312. listMovieTitle = () => {
  2313. let num = parseInt(this.L_MTL ?? 0, 10);
  2314. if (this.L_MTH && num < 1) num = 1;
  2315.  
  2316. return `.x-ellipsis {
  2317. -webkit-line-clamp: ${num <= 0 ? "unset" : num};
  2318. ${this.L_MTH ? `height: calc(var(--x-line-h) * ${num}) !important;` : ""}
  2319. }`;
  2320. };
  2321. // L_SCROLL
  2322. listScroll = async function ({ container, itemSelector = ".item", path, start, showPage, onLoad }) {
  2323. let { list: domList = [DOC], active: isMerge = false } = this.merge;
  2324.  
  2325. const getItems = async list => {
  2326. list = await Promise.all(list.map(item => (typeof item !== "string" ? item : request(item))));
  2327. list = list.filter(Boolean);
  2328. if (!list.length) return list;
  2329.  
  2330. domList = list;
  2331. list = list.map(item => [...item.querySelectorAll(itemSelector)]).flat();
  2332. if (!list.length) return list;
  2333.  
  2334. return this.modifyItem(list, isMerge);
  2335. };
  2336. const items = await getItems(domList);
  2337. const { length } = items;
  2338. start(items);
  2339.  
  2340. if (typeof container === "string") container = DOC.querySelector(container);
  2341. container.classList.add("x-in");
  2342.  
  2343. if (length) this.listMovieVideo(container);
  2344. if (!isMerge && !this.L_SCROLL) return showPage();
  2345.  
  2346. const hasMore = "加载中...";
  2347. const noMore = "没有更多了";
  2348. const status = DOC.create("div", { id: "x-status" }, length ? hasMore : noMore);
  2349. container.insertAdjacentElement("afterend", status);
  2350. if (!length) return;
  2351.  
  2352. let urls = [];
  2353. const getNext = list => {
  2354. urls = list.map(item => item.querySelector(path)?.href).filter(Boolean);
  2355. addPrefetch(urls);
  2356. };
  2357. getNext(domList);
  2358. if (!urls.length) {
  2359. status.textContent = noMore;
  2360. return;
  2361. }
  2362.  
  2363. let isLoading = false;
  2364. let observer = new IntersectionObserver(async entries => {
  2365. if (!urls.length) {
  2366. status.textContent = noMore;
  2367. return observer.disconnect();
  2368. }
  2369. if (!entries[0].isIntersecting || isLoading) return;
  2370. status.textContent = hasMore;
  2371.  
  2372. isLoading = true;
  2373. const _items = await getItems(urls);
  2374. isLoading = false;
  2375.  
  2376. if (!_items.length) {
  2377. status.textContent = "请求失败,检查后滚动以重试";
  2378. return;
  2379. }
  2380. getNext(domList);
  2381. onLoad(_items);
  2382. });
  2383. observer.observe(status);
  2384. };
  2385. // L_MERGE
  2386. listMerge = () => {
  2387. let merge = this.L_MERGE.trim();
  2388. if (!merge) return;
  2389.  
  2390. merge = merge.split("\n\n").filter(Boolean);
  2391. if (!merge.length) return;
  2392.  
  2393. const list = {};
  2394. const regex = /^\[.+\]$/;
  2395. const replace = /\[|\]/g;
  2396. for (const item of merge) {
  2397. const res = unique(item.split("\n").filter(Boolean));
  2398. if (res.length <= 1) continue;
  2399.  
  2400. const first = res.shift();
  2401. if (!regex.test(first)) continue;
  2402.  
  2403. list[first.replace(replace, "")] = res;
  2404. }
  2405. const keys = Object.keys(list);
  2406. if (!keys.length) return;
  2407.  
  2408. let active = "";
  2409. const { activePath = "/", start } = this.merge;
  2410. if (location.pathname === activePath) {
  2411. const { search } = location;
  2412. if (search.startsWith("?merge=")) {
  2413. active = decodeURIComponent(search.split("=").at(-1));
  2414. if (!keys.includes(active)) active = "";
  2415. }
  2416. }
  2417. DOC.addEventListener("XContentLoaded", () => start(keys, active), { once: true });
  2418. if (!active) return;
  2419.  
  2420. this.merge.active = active;
  2421. this.merge.list = list[active].map(item => (item.split("#")[0] === activePath ? DOC : item));
  2422. DOC.title = `${active} - 合并列表 - ${Domain}`;
  2423. };
  2424. // L_FILTER
  2425. listFilter = ({ code = "", title = "", score, tags }) => {
  2426. const filter = this.L_FILTER.trim();
  2427. if (!filter || (!code && !title)) return;
  2428.  
  2429. const hlRegex = /^\^/;
  2430. tags = tags?.length
  2431. ? Array.from(tags)
  2432. .map(item => item.textContent)
  2433. .join(",")
  2434. : "";
  2435. const match = (rule, word) => {
  2436. if (rule.endsWith("#start")) {
  2437. return word.startsWith(rule.replace(/#start$/, ""));
  2438. } else if (rule.endsWith("#end")) {
  2439. return word.endsWith(rule.replace(/#end$/, ""));
  2440. } else {
  2441. if (!rule.startsWith("reg:")) return word.includes(rule);
  2442.  
  2443. rule = rule.replace(/^reg:/, "");
  2444. return rule ? eval(rule)?.test(word) : rule;
  2445. }
  2446. };
  2447.  
  2448. let res = "";
  2449. for (const item of filter.split("\n\n")) {
  2450. let word = "";
  2451. if (item.startsWith("[code]")) word = code;
  2452. if (item.startsWith("[title]")) word = title;
  2453. if (item.startsWith("[score]")) word = score;
  2454. if (item.startsWith("[tags]")) word = tags;
  2455. if (!word && word !== "") continue;
  2456.  
  2457. const rules = unique(item.split("\n").filter(Boolean));
  2458. if (rules.length <= 1) continue;
  2459.  
  2460. const highlight = [];
  2461. for (const rule of rules.slice(1)) {
  2462. if (hlRegex.test(rule)) {
  2463. highlight.push(rule.replace(hlRegex, ""));
  2464. continue;
  2465. }
  2466. if (match(rule, word)) res = "x-hide";
  2467. if (res === "x-hide") break;
  2468. }
  2469. if (res === "x-hide") break;
  2470.  
  2471. for (const rule of highlight) {
  2472. if (match(rule, word)) res = "x-highlight";
  2473. if (res === "x-highlight") break;
  2474. }
  2475. }
  2476. return res;
  2477. };
  2478.  
  2479. // M_RES, M_TITLE, M_STAR, M_SCORE, M_SUB, M_MAGNET
  2480. getMovieResource = function ({ video, transTitle, star, code, cid, studio, isVR, title }) {
  2481. let res = [];
  2482.  
  2483. if (this.M_RES?.trim()) {
  2484. res = paramParse(this.M_RES, ["img", "video", "player"]);
  2485. this.params.res = res;
  2486. }
  2487. if (this.M_SCORE?.trim()) {
  2488. const param = paramParse(this.M_SCORE, ["db", "lib", "dmm", "mgs"]);
  2489. const _res = param.filter(item => Domain !== "JavDB" || item !== "db").map(item => `${item}_score`);
  2490. res = [...res, ..._res];
  2491. if (_res.length) this.params.score = param;
  2492. }
  2493. if (this.M_MAGNET?.trim()) {
  2494. const param = paramParse(this.M_MAGNET, ["suk", "bts", "btd"]);
  2495. res = [...res, ...param.map(item => `${item}_magnet`)];
  2496. this.params.magnet = param;
  2497. }
  2498. if (this.M_TITLE) res.push("title");
  2499. if (!star?.length && this.M_STAR) res.push("star");
  2500. if (this.M_SUB) res.push("sub");
  2501.  
  2502. const needs = [];
  2503. const detail = Store.getDetail(code);
  2504. const resource = { video, title: transTitle };
  2505. for (const key of res) {
  2506. let val = detail[key];
  2507. this.params[key] = val;
  2508. if (val?.length) continue;
  2509.  
  2510. val = resource[key];
  2511. if (val?.length) {
  2512. this.setMovieResource({ [key]: val });
  2513. continue;
  2514. }
  2515.  
  2516. needs.push(key);
  2517. }
  2518. if (!needs.length) return;
  2519.  
  2520. if (needs.includes("img")) {
  2521. DOC.head.insertAdjacentHTML("beforeend", '<meta name="referrer" content="never">');
  2522. let _code = code;
  2523. if (/^HEYZO-\d/i.test(_code)) _code = _code.replace("-", " ");
  2524.  
  2525. Apis.fetchJavStore(_code).then(res => res.img && this.setMovieResource(res));
  2526. Apis.fetchBlogJav(_code).then(res => this.setMovieResource(res));
  2527. }
  2528. if (needs.includes("video")) {
  2529. Apis.fetchVideoByGuess({ code, isVR, cid }).then(res => res.video && this.setMovieResource(res));
  2530. Apis.fetchVideoByStudio({ code, studio }).then(res => res.video && this.setMovieResource(res));
  2531. Apis.fetchJavSpyl(code).then(res => this.setMovieResource(res));
  2532. Apis.fetchAVPreview(code).then(res => this.setMovieResource(res));
  2533. if (FC2_REGEX.test(code)) Apis.fetchFC2(code).then(res => this.setMovieResource(res));
  2534. }
  2535. if (needs.includes("player")) Apis.fetchNetflav(code).then(res => this.setMovieResource(res));
  2536. if (needs.includes("title")) Apis.fetchTranslate(title).then(res => this.setMovieResource(res));
  2537. if (needs.includes("suk_magnet")) Apis.fetchSukebei(code).then(res => this.setMovieResource(res));
  2538. if (needs.includes("bts_magnet")) Apis.fetchBTSOW(code).then(res => this.setMovieResource(res));
  2539. if (needs.includes("btd_magnet")) {
  2540. Apis.fetchBTDigg(code).then(res => {
  2541. if (res.btd_magnet.length) return this.setMovieResource(res);
  2542. Apis.fetchBTDigg(code, 1).then(re => this.setMovieResource(re));
  2543. });
  2544. }
  2545.  
  2546. const isMGS = ["mgs_score", "video"];
  2547. if (needs.some(item => isMGS.includes(item))) {
  2548. Apis.fetchMGS({ code, title }).then(res => this.setMovieResource(res));
  2549. }
  2550.  
  2551. const isLib = ["lib_score", "star"];
  2552. if (needs.some(item => isLib.includes(item))) Apis.fetchLib(code).then(res => this.setMovieResource(res));
  2553.  
  2554. const isDMM = ["dmm_score", "star", "video"];
  2555. if (needs.some(item => isDMM.includes(item))) {
  2556. Apis.fetchDMM({ code, title }).then(({ fetchVideo, fetchInfo }) => {
  2557. if (!fetchVideo) return this.setMovieResource({ dmm_score: [], star: [], video: "" });
  2558. if (needs.includes("video")) fetchVideo().then(re => this.setMovieResource(re));
  2559. if (needs.includes("dmm_score")) fetchInfo().then(re => this.setMovieResource(re));
  2560. });
  2561. }
  2562.  
  2563. if (Domain === "JavDB") return;
  2564. const isDB = ["db_score", "star", "video", "sub"];
  2565. if (needs.some(item => isDB.includes(item))) Apis.fetchDB(code).then(res => this.setMovieResource(res));
  2566. };
  2567. setMovieResource = function (res) {
  2568. if (!res) return;
  2569. const { code } = this.info;
  2570. const detail = Store.getDetail(code);
  2571. for (const [key, val] of Object.entries(res)) {
  2572. if (detail[key]?.length) continue;
  2573. if (val?.length) Store.upDetail(code, { [key]: val });
  2574. if (this.params.hasOwnProperty(key)) this.params[key] = val;
  2575. }
  2576. };
  2577. upMovieResource = function (key, update, start) {
  2578. if (!this.params.hasOwnProperty(key)) return;
  2579.  
  2580. start?.();
  2581. if (this.params[key]?.length) return update(this.params[key]);
  2582. Object.defineProperty(this.params, key, { set: update, get: undefined });
  2583. };
  2584. // M_JUMP
  2585. movieJump = ({ code }, start, update) => {
  2586. if (!code || !start || !update) return;
  2587.  
  2588. let jump = this.M_JUMP?.trim().split("\n\n").filter(Boolean);
  2589. let { length } = jump;
  2590. if (!length) return;
  2591.  
  2592. const regex = /^\[.+\]$/;
  2593. const replace = /\[|\]/g;
  2594. const urlReg = /^https?:\/\/[a-z0-9]+/i;
  2595.  
  2596. const group = [];
  2597. for (let index = 0; index < length; index++) {
  2598. const items = unique(jump[index].split("\n").filter(Boolean));
  2599. if (items.length <= 1 || !regex.test(items[0])) continue;
  2600.  
  2601. const list = items.filter(item => urlReg.test(item));
  2602. if (!list.length) continue;
  2603.  
  2604. group.push({
  2605. group: items[0].replace(replace, ""),
  2606. list: list.map(item => {
  2607. return {
  2608. url: `${item.replaceAll(REP, code).trim()}#${code}`,
  2609. query: item.includes("#query"),
  2610. name: item.split("//")[1].split("/")[0].split(".").at(-2),
  2611. };
  2612. }),
  2613. });
  2614. }
  2615. if (group.length) start(group);
  2616.  
  2617. const nodeList = DOC.querySelectorAll(".x-jump");
  2618. length = nodeList.length;
  2619. if (!length) return;
  2620.  
  2621. jump = Store.getDetail(code)?.jump ?? [];
  2622. for (let index = 0; index < length; index++) {
  2623. const node = nodeList[index];
  2624. const { query, href } = node.dataset;
  2625. if (query !== "true") continue;
  2626.  
  2627. const key = href.split("#")[0];
  2628. let item = jump.find(item => item.key.toLowerCase() === key.toLowerCase());
  2629. if (item) {
  2630. if (item.href) update(item, node);
  2631. continue;
  2632. }
  2633. request(key).then(dom => {
  2634. if (!dom) return;
  2635.  
  2636. item = captureQuery(code, dom);
  2637. if (!item?.href) return;
  2638.  
  2639. update(item, node);
  2640. jump.push({ ...item, key });
  2641. Store.upDetail(code, { jump });
  2642. });
  2643. }
  2644. };
  2645. // M_SORT
  2646. movieSort = (magnets, start) => {
  2647. if (!this.M_SORT) return magnets;
  2648.  
  2649. start?.();
  2650. return magnets.length <= 1
  2651. ? magnets
  2652. : magnets.sort((pre, next) => {
  2653. if (pre.zh === next.zh) {
  2654. if (pre.bytes === next.bytes) return next.date - pre.date;
  2655. return next.bytes - pre.bytes;
  2656. } else {
  2657. return pre.zh > next.zh ? -1 : 1;
  2658. }
  2659. });
  2660. };
  2661.  
  2662. // D_MATCH
  2663. driveMatchForList = async (items, selectors) => {
  2664. if (!this.D_MATCH) return;
  2665.  
  2666. const update = ({ item }, res) => {
  2667. const node = item.querySelector(selectors);
  2668. if (!node) return;
  2669.  
  2670. const keys = ["n", "pc", "fid", "cid"];
  2671. const { classList, dataset } = node;
  2672.  
  2673. if (!res.length) {
  2674. keys.forEach(key => delete dataset[key]);
  2675. node.removeAttribute("title");
  2676. return classList.remove("x-zh", "x-player");
  2677. }
  2678.  
  2679. classList.add("x-player");
  2680. let str = "已有";
  2681. let _item = res[0];
  2682. const zh = res.find(({ n }) => ZH_REGEX.test(n));
  2683. if (zh) {
  2684. classList.add("x-zh");
  2685. str = "字幕";
  2686. _item = zh;
  2687. }
  2688. node.setAttribute("title", `${str}资源`);
  2689. keys.forEach(key => {
  2690. dataset[key] = _item[key];
  2691. });
  2692. };
  2693.  
  2694. const params = {};
  2695. for (let index = 0, { length } = items; index < length; index++) {
  2696. const item = items[index];
  2697. let { code } = item;
  2698. code = /^FC2-\d/i.test(code) ? code.replace("-", "-PPV-") : code;
  2699. item.code = code;
  2700.  
  2701. const { res } = Store.getDetail(code);
  2702. if (res) {
  2703. update(item, res);
  2704. continue;
  2705. }
  2706.  
  2707. const key = code.split("-")[0];
  2708. params.hasOwnProperty(key) ? params[key].push(item) : (params[key] = [item]);
  2709. }
  2710. for (const [prefix, items] of Object.entries(params)) {
  2711. let res = Store.getResource(prefix);
  2712. if (!res) {
  2713. res = await Apis._driveSearch(prefix);
  2714. if (!res) break;
  2715. Store.upResource(prefix, res);
  2716. }
  2717. if (!res.length) continue;
  2718.  
  2719. for (let index = 0, { length } = items; index < length; index++) {
  2720. const item = items[index];
  2721. const { regex } = codeParse(item.code);
  2722. const _res = res.filter(({ n }) => regex.test(n));
  2723. if (_res.length) update(item, _res);
  2724. }
  2725. }
  2726. };
  2727. driveMatchForMovie = async function ({ code }, update, start) {
  2728. if (!this.D_MATCH) return;
  2729.  
  2730. start?.();
  2731. const cid = await this.driveCid();
  2732. if (cid === undefined) return update([]);
  2733.  
  2734. const { prefix, regex } = codeParse(code);
  2735. const list = await Promise.allSettled([Apis._driveSearch(prefix, ["t"]), Apis.driveVideo(cid)]);
  2736.  
  2737. let res;
  2738. for (let index = 0, { length } = list; index < length; index++) {
  2739. const { status, value } = list[index];
  2740. if (status !== "fulfilled" || !value?.length) continue;
  2741.  
  2742. if (!res) res = [];
  2743. for (let idx = 0, len = value.length; idx < len; idx++) {
  2744. const item = value[idx];
  2745. if (res.some(re => re.fid === item.fid) || !regex.test(item.n)) continue;
  2746. res.push(item);
  2747. }
  2748. }
  2749. update(res || []);
  2750. if (res) Store.upDetail(code, { res });
  2751. };
  2752. // D_LOL
  2753. upLOLTarget = () => {
  2754. if (!this.D_MATCH || !this.D_LOL) return;
  2755. GM_addStyle('.x-btn{display:revert}.x-btn::after{content:"离线"}');
  2756. };
  2757. driveListOffLine = async (e, { code, title }) => {
  2758. e.preventDefault();
  2759. e.stopPropagation();
  2760.  
  2761. const LOCK = "active";
  2762. const { classList } = e.target;
  2763. if (classList.contains(LOCK)) return;
  2764. classList.add(LOCK);
  2765.  
  2766. const magnet = paramParse(this.M_MAGNET, ["suk", "bts", "btd"]);
  2767. if (!magnet.length) return classList.remove(LOCK);
  2768.  
  2769. const detail = Store.getDetail(code);
  2770. let magnets = magnet.map(item => detail[`${item}_magnet`] ?? []).flat();
  2771. if (!magnets.length) {
  2772. const list = {
  2773. suk: () => Apis.fetchSukebei(code),
  2774. bts: () => Apis.fetchBTSOW(code),
  2775. btd: () => Apis.fetchBTDigg(code),
  2776. };
  2777.  
  2778. const res = await Promise.allSettled(magnet.map(item => list[item]()));
  2779. for (let index = 0, { length } = res; index < length; index++) {
  2780. const { status, value } = res[index];
  2781. if (status !== "fulfilled" || !value) continue;
  2782.  
  2783. Store.upDetail(code, value);
  2784. magnets.push(...value[`${magnet[index]}_magnet`]);
  2785. }
  2786. }
  2787. if (!magnets.length) return classList.remove(LOCK);
  2788.  
  2789. magnets = this.movieSort(magnets);
  2790. magnets = this.driveFail(magnets);
  2791.  
  2792. if (/^\$\{.+\}$/.test(this.D_CID)) this.D_CID = "";
  2793. const [wp_path_id, sign] = await Promise.all([this.driveCid("create"), Apis.driveSign()]);
  2794. if (!wp_path_id || !sign) return classList.remove(LOCK);
  2795.  
  2796. for (let index = 0, { length } = magnets; index < length; index++) {
  2797. const isLast = index + 1 === length;
  2798. const { link: url, zh } = magnets[index];
  2799.  
  2800. let res = await Apis.driveAddTask({ url, wp_path_id, ...sign });
  2801. if (!res) break;
  2802.  
  2803. const { state, errcode, error_msg } = res;
  2804. if (!state) {
  2805. if ([10008, 10007].includes(errcode)) {
  2806. if (errcode === 10008 && !isLast) continue;
  2807. notify({ type: "warn", title: error_msg });
  2808. break;
  2809. }
  2810. if (errcode === 911) {
  2811. classList.add("pending");
  2812.  
  2813. if (Store.getVerifyStatus() !== "pending") {
  2814. notify({ type: "warn", title: `${code} 任务暂停,等待校验` });
  2815. verify();
  2816. }
  2817. const listener = GM_addValueChangeListener(
  2818. "VERIFY_STATUS",
  2819. (name, old_value, new_value, remote) => {
  2820. if (!remote || !["verified", "failed"].includes(new_value)) return;
  2821. GM_removeValueChangeListener(listener);
  2822. classList.remove(LOCK, "pending");
  2823. if (new_value === "verified") this.driveListOffLine(e, { code, title });
  2824. }
  2825. );
  2826. break;
  2827. }
  2828. }
  2829.  
  2830. const cid = wp_path_id;
  2831. const clickUrl = FILE_RUL.replace(REP, cid);
  2832. res = await this.driveVerify({ code, cid });
  2833. if (!res) {
  2834. if (!isLast) continue;
  2835. notify({ type: "info", title: `${code} 验证失败`, clickUrl });
  2836. break;
  2837. }
  2838. if (res?.length) {
  2839. notify({
  2840. type: "success",
  2841. title: `${code} 离线成功`,
  2842. text: `点击跳转目录`,
  2843. clickUrl: FILE_RUL.replace(REP, res[0].cid),
  2844. });
  2845.  
  2846. const list = [() => this.driveClear({ cid, res, code })];
  2847. let { file_name, fetch } = this.driveRename({ cid, res, zh, code, title });
  2848. if (fetch) {
  2849. res[0].n = file_name;
  2850. list.push(() => fetch());
  2851. }
  2852.  
  2853. Store.upDetail(code, { res });
  2854. const { selectors, upQuery } = this.click;
  2855. const item = e.target.closest(selectors);
  2856. if (item) this.driveMatchForList([{ item, code }], upQuery);
  2857.  
  2858. await Promise.allSettled(list.map(item => item()));
  2859. } else {
  2860. notify({ type: "info", title: `${code} 任务结束`, clickUrl });
  2861. }
  2862. break;
  2863. }
  2864. if (!classList.contains("pending")) classList.remove(LOCK);
  2865. };
  2866. // D_CID
  2867. driveCid = async function (type = "find") {
  2868. let cid = this.D_CID.trim() || "${云下载}";
  2869.  
  2870. if (/^\$\{.+\}$/.test(cid)) {
  2871. let isFirst = true;
  2872. const arr = cid
  2873. .replace(/\$|\{|\}/g, "")
  2874. .split("/")
  2875. .map(item => item.trim())
  2876. .filter(Boolean);
  2877.  
  2878. for (let index = 0, { length } = arr; index < length; index++) {
  2879. let item = arr[index];
  2880. if (!item.startsWith("#")) {
  2881. cid = item;
  2882. break;
  2883. }
  2884.  
  2885. item = item.replace(/^#/, "");
  2886. if (!item) continue;
  2887.  
  2888. cid = this.info?.[item];
  2889. if (!cid?.length) {
  2890. isFirst = false;
  2891. continue;
  2892. }
  2893.  
  2894. if (typeof cid !== "string") cid = cid[0];
  2895. break;
  2896. }
  2897. if (!cid?.length) cid = "云下载";
  2898.  
  2899. cid = await Apis._driveCid(cid, type);
  2900. if (cid && (isFirst || type !== "find")) this.D_CID = cid;
  2901. }
  2902.  
  2903. return cid;
  2904. };
  2905. // D_VERIFY
  2906. driveVerify = async ({ code, cid }) => {
  2907. let verify = this.D_VERIFY <= 0;
  2908.  
  2909. const { regex } = codeParse(code);
  2910. const exist = Store.getDetail(code)?.res ?? [];
  2911. for (let idx = 0; idx < this.D_VERIFY; idx++) {
  2912. await delay();
  2913.  
  2914. let res = await Apis.driveVideo(cid, ["ico"]);
  2915. res = res.filter(({ n, t }) => regex.test(n) && t.startsWith(getDate()));
  2916. if (!res?.length) continue;
  2917.  
  2918. res = res.filter(item => !exist.find(e => e.fid === item.fid));
  2919. if (!res.length) continue;
  2920.  
  2921. verify = res;
  2922. break;
  2923. }
  2924. return verify;
  2925. };
  2926. // D_FAIL
  2927. driveFail = magnets => {
  2928. const num = parseInt(this.D_FAIL ?? 0, 10);
  2929. return num <= 0 ? magnets : magnets.slice(0, num);
  2930. };
  2931. // D_CLEAR
  2932. driveClear = ({ cid, res, code }) => {
  2933. if (!this.D_CLEAR) return;
  2934.  
  2935. const { regex } = codeParse(code);
  2936. unique(res.map(item => item.cid).filter(item => item !== cid)).forEach(async pid => {
  2937. let fids = await Apis.driveFile(pid);
  2938. if (!fids?.data) return;
  2939.  
  2940. fids = fids.data.filter(({ n }) => !regex.test(n));
  2941. if (fids.length) Apis.driveClear({ pid, fids });
  2942. });
  2943. };
  2944. // D_RENAME
  2945. driveRename = ({ cid, res, zh, code, title }) => {
  2946. let file_name = this.D_RENAME?.trim();
  2947. if (!file_name) return { file_name: `${code} ${title}` };
  2948.  
  2949. file_name = file_name
  2950. .replace(/\$\{字幕\}/g, zh ? "【中文字幕】" : "")
  2951. .replace(/\$\{番号\}/g, code)
  2952. .replace(/\$\{标题\}/g, title);
  2953.  
  2954. if (!codeParse(code).regex.test(file_name)) file_name = `${code} - ${file_name}`;
  2955.  
  2956. res = res.filter(item => item.ico);
  2957. const noRegex = /\$\{序号\}/g;
  2958. const data = [];
  2959.  
  2960. unique(res.map(item => `${item.cid}/${item.ico}`)).forEach(key => {
  2961. const [_cid, _ico] = key.split("/");
  2962. res.filter(item => item.cid === _cid && item.ico === _ico).forEach((item, index) => {
  2963. data.push({ ...item, file_name: `${file_name.replace(noRegex, index + 1)}.${_ico}` });
  2964. });
  2965. });
  2966.  
  2967. file_name = file_name.replace(noRegex, "");
  2968. unique(res.map(item => item.cid).filter(item => item !== cid)).forEach(fid => {
  2969. data.push({ fid, file_name });
  2970. });
  2971.  
  2972. return { file_name, fetch: () => Apis.driveRename(data) };
  2973. };
  2974. // D_TAG
  2975. driveTag = async function (file_ids) {
  2976. if (!file_ids?.length || !this.D_TAG?.trim()) return;
  2977.  
  2978. let tag = paramParse(this.D_TAG, ["genre", "star"]);
  2979. if (!tag.length) return;
  2980.  
  2981. tag = tag.map(key => this.info[key] ?? []);
  2982. tag = tag
  2983. .flat()
  2984. .map(item => item.trim())
  2985. .filter(Boolean);
  2986. if (!tag.length) return;
  2987.  
  2988. const label = await Apis.driveLabel();
  2989. if (!label?.length) return;
  2990.  
  2991. let file_label = unique(tag).map(item => label.find(({ name }) => name === item)?.id ?? "");
  2992. file_label = file_label.filter(Boolean);
  2993. if (file_label.length) Apis.driveTag({ file_ids, file_label: file_label.join(",") });
  2994. };
  2995. // D_UPLOAD
  2996. driveUpload = async function ({ cid, name, res }) {
  2997. const keys = res;
  2998. res = res.map(key => this.info[key]).filter(Boolean);
  2999. const list = await Promise.allSettled(res.map(item => request(item, {}, "GET", { responseType: "blob" })));
  3000.  
  3001. const target = `U_1_${cid}`;
  3002. for (let index = 0, { length } = list; index < length; index++) {
  3003. const { status, value } = list[index];
  3004. if (status === "rejected" || !value?.size) continue;
  3005.  
  3006. const filename = `${name}_${keys[index]}_.${res[index].split(".").at(-1)}`;
  3007. const init = await Apis.driveInitUpload({ filename, filesize: value.size, target });
  3008. if (!init?.host) continue;
  3009.  
  3010. await Apis.driveUpload(init, value, filename);
  3011. }
  3012. notify({ text: "", type: "", title: "图传任务结束" });
  3013. };
  3014. // D_MODIFY
  3015. upModifyTarget = () => {
  3016. const modify = paramParse(this.D_MODIFY, ["clear", "rename", "tag", "upload", "delete"]);
  3017. if (!modify.length) return modify;
  3018.  
  3019. GM_addStyle(".x-btn{display:revert}");
  3020. if (!modify.includes("delete")) return modify;
  3021.  
  3022. GM_addStyle(".x-btn{background:var(--x-red)}.x-btn::after{content:'删除'}");
  3023. return modify;
  3024. };
  3025. driveModify = async function (e, modify) {
  3026. e.preventDefault();
  3027. e.stopPropagation();
  3028.  
  3029. const { classList, parentNode } = e.target;
  3030. if (classList.contains("active")) return;
  3031.  
  3032. classList.add("active");
  3033. const { cid, fid, n } = parentNode.dataset;
  3034. const list = [];
  3035.  
  3036. if (modify.includes("delete")) {
  3037. list.push(() => Apis.driveClear({ pid: cid, fids: [{ fid }] }));
  3038. } else {
  3039. const { code, title } = this.info;
  3040. const { regex } = codeParse(code);
  3041.  
  3042. let file_name = this.D_RENAME?.trim();
  3043. if (file_name) {
  3044. file_name = file_name
  3045. .replace(/\$\{字幕\}/g, ZH_REGEX.test(n) ? "【中文字幕】" : "")
  3046. .replace(/\$\{番号\}/g, code)
  3047. .replace(/\$\{标题\}/g, title)
  3048. .replace(/\$\{序号\}/g, "");
  3049. if (!regex.test(file_name)) file_name = `${code} - ${file_name}`;
  3050. }
  3051.  
  3052. if (modify.includes("rename") && file_name) {
  3053. let name = n.split(".");
  3054. name.pop();
  3055. if (name.join("") !== file_name) list.push(() => Apis.driveRename([{ fid, file_name }]));
  3056. }
  3057. if (modify.includes("tag")) list.push(() => this.driveTag(fid));
  3058. if (modify.some(item => ["clear", "upload"].includes(item))) {
  3059. const { data } = await Apis.driveFile(cid);
  3060.  
  3061. if (modify.includes("clear")) {
  3062. const fids = data.filter(({ n }) => !regex.test(n));
  3063. if (fids.length) list.push(() => Apis.driveClear({ pid: cid, fids }));
  3064. }
  3065. if (modify.includes("upload")) {
  3066. let uploads = paramParse(this.D_UPLOAD, ["cover", "img"]);
  3067. if (uploads.length) {
  3068. const items = data.filter(item => regex.test(item.n) && item.class === "PIC");
  3069. uploads = uploads.filter(item => !items.some(({ n }) => n.includes(`_${item}_`)));
  3070. if (uploads.length) {
  3071. file_name = file_name || `${code} ${title}`;
  3072. list.push(() => this.driveUpload({ cid, name: file_name, res: uploads }));
  3073. }
  3074. }
  3075. }
  3076. }
  3077. }
  3078.  
  3079. if (list.length) await Promise.allSettled(list.map(item => item()));
  3080. classList.remove("active");
  3081. if (!DOC.querySelector(".x-btn.active")) this.driveMatch();
  3082. };
  3083. // OFFLINE
  3084. driveOffLine = async function (e, { code, title, magnets }) {
  3085. const { target } = e;
  3086. const { magnet: type } = target.dataset;
  3087. if (!type) return;
  3088.  
  3089. e.preventDefault();
  3090. e.stopPropagation();
  3091.  
  3092. const setTab = type === "all";
  3093. magnets = setTab ? this.driveFail(magnets) : magnets.filter(item => item.link === type);
  3094. const length = magnets?.length ?? 0;
  3095. if (!length) return;
  3096.  
  3097. const { classList } = target;
  3098. classList.remove("pending");
  3099. classList.add("active");
  3100. const originText = setTab ? "一键离线" : "添加离线";
  3101. target.textContent = "请求中...";
  3102. target.inert = true;
  3103.  
  3104. const handleComplete = () => {
  3105. classList.remove("active");
  3106. target.textContent = originText;
  3107. target.inert = false;
  3108. };
  3109.  
  3110. const [wp_path_id, sign] = await Promise.all([this.driveCid("create"), Apis.driveSign()]);
  3111. if (!wp_path_id || !sign) return handleComplete();
  3112.  
  3113. const warnTitle = `${code} 一键离线失败`;
  3114. if (setTab) setTabBar({ title: `${code} 一键离线中...` });
  3115. for (let index = 0; index < length; index++) {
  3116. const isLast = index + 1 === length;
  3117. const { link: url, zh } = magnets[index];
  3118.  
  3119. let res = await Apis.driveAddTask({ url, wp_path_id, ...sign });
  3120. if (!res) {
  3121. if (!index) return handleComplete();
  3122. break;
  3123. }
  3124.  
  3125. const { state, errcode, error_msg } = res;
  3126. if (!state) {
  3127. if ([10008, 10007].includes(errcode)) {
  3128. if (errcode === 10008 && !isLast) continue;
  3129. notify({ type: "warn", title: error_msg });
  3130. if (setTab) setTabBar({ type: "warn", title: warnTitle });
  3131. break;
  3132. }
  3133. if (errcode === 911) {
  3134. classList.add("pending");
  3135. target.textContent = "校验中...";
  3136. const msg = { type: "warn", title: `${code} 任务暂停,等待校验` };
  3137.  
  3138. if (setTab) setTabBar(msg);
  3139. if (Store.getVerifyStatus() !== "pending") {
  3140. notify(msg);
  3141. verify();
  3142. }
  3143. const listener = GM_addValueChangeListener(
  3144. "VERIFY_STATUS",
  3145. (name, old_value, new_value, remote) => {
  3146. if (!remote || !["verified", "failed"].includes(new_value)) return;
  3147. GM_removeValueChangeListener(listener);
  3148. if (new_value !== "verified") return handleComplete();
  3149. this.driveOffLine(e, { magnets: magnets.slice(index), code, title });
  3150. }
  3151. );
  3152. break;
  3153. }
  3154. }
  3155.  
  3156. const cid = wp_path_id;
  3157. const clickUrl = FILE_RUL.replace(REP, cid);
  3158. res = await this.driveVerify({ code, cid });
  3159. if (!res) {
  3160. if (!isLast) continue;
  3161. notify({ type: "info", title: `${code} 验证失败`, clickUrl, setTab });
  3162. break;
  3163. }
  3164. if (res?.length) {
  3165. const _cid = res[0].cid;
  3166. const uploads = paramParse(this.D_UPLOAD, ["cover", "img"]);
  3167. notify({
  3168. type: "success",
  3169. title: `${code} 离线成功`,
  3170. setTab,
  3171. text: `点击跳转目录${uploads.length ? ",尝试图传中..." : ""}`,
  3172. clickUrl: FILE_RUL.replace(REP, _cid),
  3173. });
  3174. const { file_name, fetch } = this.driveRename({ cid, res, zh, code, title });
  3175. if (fetch) await fetch();
  3176.  
  3177. if (uploads.length) this.driveUpload({ cid: _cid, name: file_name, res: uploads });
  3178. this.driveTag(
  3179. res
  3180. .map(({ fid }) => fid)
  3181. .filter(Boolean)
  3182. .join(",")
  3183. );
  3184. this.driveClear({ cid, res, code });
  3185. } else {
  3186. notify({ type: "info", title: `${code} 任务结束`, clickUrl, setTab });
  3187. }
  3188. break;
  3189. }
  3190.  
  3191. if (classList.contains("pending")) return;
  3192. await delay();
  3193. this.driveMatch();
  3194. handleComplete();
  3195. };
  3196.  
  3197. // A_LINK
  3198. advancedLink = async (e, { type = "left", defaultLink }) => {
  3199. e.preventDefault();
  3200. e.stopPropagation();
  3201.  
  3202. const { n: name, pc: pickcode, fid, cid } = e.target.dataset;
  3203. defaultLink = defaultLink ?? type === "left" ? `${PICK_RUL}${pickcode}` : FILE_RUL.replace(REP, cid);
  3204.  
  3205. if (!fid || fid === "undefined") return openInTab(defaultLink);
  3206.  
  3207. let config = this.A_LINK?.trim()?.split("\n");
  3208. let index = config.findIndex(item => item === `[${type}]`);
  3209. if (index === -1) return openInTab(defaultLink);
  3210.  
  3211. config = config[index + 1]?.trim();
  3212. if (!config) return openInTab(defaultLink);
  3213.  
  3214. config = config
  3215. .replaceAll("${#pickcode}", pickcode)
  3216. .replaceAll("${#cid}", cid)
  3217. .replaceAll("${#name}", encodeURIComponent(name));
  3218. if (!config.includes("${#path}")) return openInTab(config);
  3219.  
  3220. let path = await Apis.driveDetail(fid);
  3221. if (!path?.paths?.length) return;
  3222.  
  3223. path = path.paths
  3224. .map(item => item.file_name)
  3225. .splice(1)
  3226. .join("/");
  3227. openInTab(config.replaceAll("${#path}", encodeURIComponent(path)));
  3228. };
  3229. }
  3230.  
  3231. class JavDB extends Common {
  3232. constructor() {
  3233. super();
  3234. return super.init();
  3235. }
  3236.  
  3237. excludeMenu = ["G_DARK", "L_MIT", "M_SUB"];
  3238. routes = {
  3239. list: /^\/($|guess|(un)?censored|western|fc2|anime|(advanced_)?search|video_codes|tags|rankings|actors|series|makers|directors|publishers|lists|users)/i,
  3240. movie: /^\/v\/\w+/i,
  3241. others: /.*/i,
  3242. };
  3243. _style = {
  3244. common: `
  3245. html {
  3246. overflow: overlay;
  3247. padding-bottom: 0 !important;
  3248. }
  3249. body {
  3250. min-height: 100%;
  3251. }
  3252. .section {
  3253. padding: 20px;
  3254. }
  3255. #search-bar-container {
  3256. margin-bottom: 8px !important;
  3257. }
  3258. .search-panel button {
  3259. border: none;
  3260. }
  3261. #search-type, #video-search {
  3262. z-index: auto;
  3263. border: none;
  3264. box-shadow: none;
  3265. }
  3266. .title:not(:last-child) {
  3267. margin-bottom: 20px;
  3268. }
  3269. .main-title {
  3270. padding-top: 0;
  3271. }
  3272. .app-desktop-banner, #footer {
  3273. display: none !important;
  3274. }
  3275. :root[data-theme="dark"] ::-webkit-scrollbar-thumb {
  3276. background: var(--x-grey) !important;
  3277. }
  3278. a.box:is(:focus, :hover) {
  3279. box-shadow: none !important;
  3280. }
  3281. :root[data-theme="dark"] .box:hover {
  3282. background: unset;
  3283. }
  3284. :root[data-theme="dark"] img {
  3285. filter: brightness(.9) contrast(.9) !important;
  3286. }
  3287. nav.pagination {
  3288. display: none;
  3289. margin: 0 -4px 20px !important;
  3290. padding: 0;
  3291. border: none;
  3292. }
  3293. :root[data-theme="dark"] nav.pagination {
  3294. border: none !important;
  3295. }
  3296. .float-buttons {
  3297. right: 8px;
  3298. }
  3299. `,
  3300. };
  3301. search = {
  3302. selectors: "#video-search",
  3303. pathname: `/search?q=${REP}&f=all`,
  3304. };
  3305. click = {
  3306. selectors: [":is(.movie-list, .actors, .section-container) a:has(strong)"],
  3307. codeQuery: ".video-title strong",
  3308. upQuery: ".cover",
  3309. };
  3310. merge = {
  3311. start: list => {
  3312. DOC.querySelector("#navbar-menu-hero .navbar-start")?.insertAdjacentHTML(
  3313. "beforeend",
  3314. `<div class="navbar-item has-dropdown is-hoverable">
  3315. <a class="navbar-link" href="/?merge=${list[0]}">合并列表</a>
  3316. <div class="navbar-dropdown is-boxed">
  3317. ${list.map(item => `<a class="navbar-item" href="/?merge=${item}">${item}</a>`).join("")}
  3318. </div>
  3319. </div>`
  3320. );
  3321. },
  3322. };
  3323.  
  3324. list = {
  3325. docStart() {
  3326. const style = `
  3327. .awards,
  3328. .form-panel .user-profile,
  3329. .section:has(.actors, .movie-list, .section-container, .user-container .common-list) {
  3330. padding-bottom: 0;
  3331. }
  3332. :is(.tabs, .message):not(:last-child) {
  3333. margin-bottom: 20px;
  3334. }
  3335. .movie-list {
  3336. opacity: 0;
  3337. }
  3338. .actors, .movie-list, .section-container {
  3339. gap: 20px !important;
  3340. margin: 0 0 20px !important;
  3341. padding-bottom: 0;
  3342. }
  3343. .container > br,
  3344. .actor-filter hr,
  3345. .movie-list:has(.tags),
  3346. .user-container > .column.is-10 > .message.is-warning {
  3347. display: none;
  3348. }
  3349. .main-tabs, .box:has(> form) {
  3350. margin-bottom: 20px !important;
  3351. }
  3352. .toolbar {
  3353. margin-top: -10px;
  3354. padding-bottom: 0;
  3355. word-spacing: -20px;
  3356. }
  3357. .toolbar * {
  3358. word-spacing: 0;
  3359. }
  3360. .toolbar .button-group, .actor-tags .content .tag {
  3361. margin: 0 10px 10px 0;
  3362. }
  3363. #t {
  3364. height: 2.2rem;
  3365. }
  3366. #tags {
  3367. margin: -20px 0 20px;
  3368. }
  3369. #tags dt a.tag-expand {
  3370. margin-top: .44rem;
  3371. }
  3372. .section:has(> .awards, > .user-container) {
  3373. padding: 0;
  3374. }
  3375. .divider-title {
  3376. margin-bottom: 16px !important;
  3377. padding-bottom: 0;
  3378. border-bottom: none;
  3379. }
  3380. .actors .box {
  3381. margin-bottom: 0;
  3382. }
  3383. .actor-filter-toolbar {
  3384. padding-bottom: 20px;
  3385. }
  3386. .section-columns {
  3387. margin-bottom: 8px !important;
  3388. padding-top: 0;
  3389. }
  3390. .columns:has(> .section-addition) {
  3391. margin-bottom: 8px;
  3392. }
  3393. .actor-tags {
  3394. margin-bottom: 20px !important;
  3395. padding-bottom: 0;
  3396. font-size: 0;
  3397. border-bottom: none;
  3398. }
  3399. .actor-tags .content:not(.collapse) {
  3400. margin-bottom: -10px;
  3401. }
  3402. .user-container {
  3403. margin: -10px -10px 0 !important;
  3404. }
  3405. .user-container > .column {
  3406. padding: 10px 10px 0;
  3407. }
  3408. .user-container > .column:first-child {
  3409. padding-bottom: 10px;
  3410. }
  3411. .user-container .common-list ul {
  3412. margin-bottom: 20px;
  3413. }
  3414. .list-item:not(:last-child) {
  3415. border-bottom: 1px solid #dbdbdb;
  3416. }
  3417. .user-container .common-list .list-item {
  3418. align-items: center;
  3419. margin: 0;
  3420. padding: 10px 2px;
  3421. }
  3422. .user-container .common-list .list-item:first-child {
  3423. padding-top: 0;
  3424. }
  3425. .user-container .common-list .list-item:last-child {
  3426. padding-bottom: 0;
  3427. }
  3428. .user-container .common-list .list-item .column {
  3429. padding: 0;
  3430. }
  3431. .user-container .common-list .list-item .column:first-child {
  3432. flex: 1;
  3433. }
  3434. .user-container .common-list .list-item .column:last-child {
  3435. width: auto;
  3436. }
  3437. `;
  3438. const layout = `
  3439. @media (width < 576px) {
  3440. .movie-list.v, .actors {
  3441. grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  3442. }
  3443. .movie-list.h {
  3444. grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  3445. }
  3446. }
  3447. @media (width >= 576px) {
  3448. .movie-list.v, .actors {
  3449. grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  3450. }
  3451. .movie-list.h {
  3452. grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  3453. }
  3454. }
  3455. @media (width >= 768px) {
  3456. .movie-list.v, .actors {
  3457. grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  3458. }
  3459. .movie-list.h {
  3460. grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  3461. }
  3462. }
  3463. @media (width >= 992px) {
  3464. .movie-list.v, .actors {
  3465. grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  3466. }
  3467. .movie-list.h {
  3468. grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  3469. }
  3470. }
  3471. @media (width >= 1200px) {
  3472. .movie-list.v, .actors {
  3473. grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  3474. }
  3475. .movie-list.h {
  3476. grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  3477. }
  3478. }
  3479. @media (width >= 1400px) {
  3480. .movie-list.v, .actors {
  3481. grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  3482. }
  3483. .movie-list.h {
  3484. grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  3485. }
  3486. }
  3487. .user-container .column:has(.movie-list, .actors) {
  3488. container-type: inline-size;
  3489. }
  3490. @container (width < 576px) {
  3491. .column .movie-list {
  3492. grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  3493. }
  3494. .column .movie-list.v, .actors {
  3495. grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  3496. }
  3497. }
  3498. @container (width >= 576px) {
  3499. .column .movie-list {
  3500. grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  3501. }
  3502. .column .movie-list.v, .actors {
  3503. grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  3504. }
  3505. }
  3506. @container (width >= 768px) {
  3507. .column .movie-list {
  3508. grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  3509. }
  3510. .column .movie-list.v, .actors {
  3511. grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  3512. }
  3513. }
  3514. @container (width >= 992px) {
  3515. .column .movie-list {
  3516. grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  3517. }
  3518. .column .movie-list.v, .actors {
  3519. grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  3520. }
  3521. }
  3522. @container (width >= 1200px) {
  3523. .column .movie-list {
  3524. grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  3525. }
  3526. .column .movie-list.v, .actors {
  3527. grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  3528. }
  3529. }
  3530. @container (width >= 1400px) {
  3531. .column .movie-list {
  3532. grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  3533. }
  3534. .column .movie-list.v, .actors {
  3535. grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  3536. }
  3537. }
  3538. `;
  3539. const card = `
  3540. :is(.movie-list, .actors) .box {
  3541. padding: 0 0 10px;
  3542. }
  3543. .movie-list .item .cover, .actor-box a figure {
  3544. background: var(--x-sub-ftc);
  3545. }
  3546. :root[data-theme="dark"] :is(.movie-list .item .cover, .actor-box a figure) {
  3547. background: var(--x-grey);
  3548. }
  3549. .movie-list .item .cover {
  3550. padding: 0 !important;
  3551. aspect-ratio: var(--x-cover-ratio);
  3552. }
  3553. .actors .box img {
  3554. height: 100%;
  3555. object-fit: cover;
  3556. opacity: 0;
  3557. }
  3558. .movie-list .item .cover img {
  3559. width: 100%;
  3560. object-fit: contain;
  3561. opacity: 0;
  3562. }
  3563. .movie-list .item .cover:hover img {
  3564. z-index: auto;
  3565. transform: none;
  3566. }
  3567. .movie-list.v .item .cover {
  3568. aspect-ratio: var(--x-thumb-ratio);
  3569. }
  3570. .movie-list.v .item .cover img {
  3571. object-fit: cover !important;
  3572. }
  3573. .movie-list .item .video-title, .actor-box a strong, .section-container .box {
  3574. font-size: 14px;
  3575. line-height: var(--x-line-h);
  3576. }
  3577. .movie-list .item .video-title {
  3578. box-sizing: content-box;
  3579. padding: 10px 0 0;
  3580. }
  3581. .movie-list .item .score {
  3582. padding: 0;
  3583. }
  3584. .movie-list .item .box :is(.video-title, .score, .tags, .meta-buttons), .actor-box a strong {
  3585. padding: 10px 10px 0;
  3586. }
  3587. .movie-list .item .meta {
  3588. padding: 0 10px;
  3589. }
  3590. .movie-list .box .tags {
  3591. min-height: 44px;
  3592. margin-bottom: -10px;
  3593. }
  3594. .movie-list .box .tags .tag {
  3595. margin-bottom: 10px;
  3596. }
  3597. .actor-box a figure {
  3598. aspect-ratio: var(--x-avatar-ratio);
  3599. }
  3600. .actor-box a.button.is-danger {
  3601. width: auto;
  3602. margin: 10px 10px 0 !important;
  3603. }
  3604. .movie-list .box .meta-buttons a.button.is-danger {
  3605. margin: 0 !important;
  3606. }
  3607. .section-container a:has(> strong) {
  3608. display: flex;
  3609. }
  3610. .section-container .box strong {
  3611. flex: 1;
  3612. padding-right: 10px;
  3613. overflow: hidden;
  3614. white-space: nowrap;
  3615. text-overflow: ellipsis;
  3616. }
  3617. `;
  3618. this.globalDark(`${this._style.common}${style}${layout}${card}${this.listMovieTitle()}`);
  3619. this.listMerge();
  3620. this.upLOLTarget();
  3621. },
  3622. contentLoaded() {
  3623. this.globalSearch();
  3624. if (location.pathname === "/users/favorite_lists") {
  3625. this.click.selectors.push(".common-list .column.is-10 a");
  3626. }
  3627. this.globalClick();
  3628. this.modifyLayout();
  3629. },
  3630. modifyLayout() {
  3631. const tags = DOC.querySelector("#tags:not(select)");
  3632. if (tags) {
  3633. const toggle = DOC.create("button", { class: "button is-info", type: "button" }, "折叠");
  3634. const tabs = DOC.querySelector(".tabs.is-boxed");
  3635. tabs.classList.add("is-align-items-flex-end");
  3636. tabs.append(toggle);
  3637. toggle.addEventListener("click", () => tags.classList.toggle("is-hidden"));
  3638. }
  3639.  
  3640. for (const list of DOC.querySelectorAll(".movie-list:not(:has(.tags))")) {
  3641. const _list = list.cloneNode(true);
  3642. const items = this.modifyItem([..._list.querySelectorAll(".item")]);
  3643. _list.innerHTML = "";
  3644. _list.append(...items);
  3645. _list.classList.add("x-in");
  3646. list.replaceWith(_list);
  3647. }
  3648.  
  3649. let container;
  3650. const lists = DOC.querySelectorAll(".actors");
  3651. const { length } = lists;
  3652. if (length) {
  3653. if (length === 1) {
  3654. container = lists[0];
  3655. } else {
  3656. for (let index = 0; index < length; index++) {
  3657. for (const item of lists[index].querySelectorAll(".box")) fadeInImg(item);
  3658. }
  3659. }
  3660. }
  3661. container =
  3662. container ??
  3663. DOC.querySelector([
  3664. ".movie-list:has(.tags)",
  3665. ".section-container:has(.box)",
  3666. ".user-container:has(nav.pagination) .common-list ul",
  3667. ]);
  3668. if (!container) {
  3669. if (DOC.querySelector(".movie-list:is(.h, .cols-3) .cover")) this.listMovieVideo(DOC);
  3670. return;
  3671. }
  3672.  
  3673. this.listScroll({
  3674. container,
  3675. itemSelector: [
  3676. ".movie-list:has(.tags) .item",
  3677. ".actors .box",
  3678. ".section-container .box",
  3679. ".common-list ul .list-item",
  3680. ],
  3681. path: ".pagination-next",
  3682. start: items => {
  3683. container.innerHTML = "";
  3684. container.append(...items);
  3685. container.classList.add("x-grid");
  3686. },
  3687. showPage: () => DOC.querySelector("nav.pagination")?.classList.add("x-flex-center"),
  3688. onLoad: items => container.append(...items),
  3689. });
  3690. },
  3691. modifyItem(items, isMerge) {
  3692. const isMovieList = items.some(item => item.querySelector(".video-title"));
  3693. const res = [];
  3694. const hlUrls = [];
  3695.  
  3696. for (let index = 0, { length } = items; index < length; index++) {
  3697. const item = items[index];
  3698. let code = "";
  3699. let date = "";
  3700. let score = 0;
  3701. let highlight = false;
  3702.  
  3703. if (isMovieList) {
  3704. code = item.querySelector(".video-title strong");
  3705. if (!code) continue;
  3706.  
  3707. code = code.textContent.trim();
  3708. date = item.querySelector(".meta")?.textContent ?? "";
  3709. date = date.replaceAll("-", "").trim();
  3710.  
  3711. if (isMerge) {
  3712. if (res.some(t => t.code === code && t.date === date)) continue;
  3713. score = (item.querySelector(".score")?.textContent ?? "").match(NUM_REGEX)[0] ?? 0;
  3714. item.querySelector(".meta-buttons")?.remove();
  3715. }
  3716.  
  3717. this.modifyMovieCard(item);
  3718. if (item.matches(".x-hide")) continue;
  3719.  
  3720. highlight = item.matches(".x-highlight");
  3721. if (highlight) hlUrls.push(item.querySelector("a").href);
  3722. }
  3723.  
  3724. fadeInImg(item);
  3725. res.push({ code, date, score, highlight, item });
  3726. }
  3727. if (!res.length) return res;
  3728.  
  3729. if (isMovieList) {
  3730. this.driveMatchForList(res, this.click.upQuery);
  3731. addPrefetch(hlUrls);
  3732. if (isMerge) {
  3733. res.sort((pre, next) => {
  3734. return pre.score === next.score ? next.date - pre.date : next.score - pre.score;
  3735. });
  3736. }
  3737. res.sort((pre, next) => (pre.highlight > next.highlight ? -1 : 1));
  3738. }
  3739. return res.map(({ item }) => item);
  3740. },
  3741. modifyMovieCard(item) {
  3742. const titleNode = item.querySelector(".video-title");
  3743. const code = titleNode.querySelector("strong").textContent.trim();
  3744. const title = titleNode.textContent.replace(code, "").trim();
  3745. const score = item
  3746. .querySelector(".score .value")
  3747. .textContent.replace(/&nbsp;/g, "")
  3748. .trim();
  3749. const tags = item.querySelectorAll(".tags .tag");
  3750.  
  3751. const filterClass = this.listFilter({ code, title, score, tags });
  3752. if (filterClass) item.classList.add(filterClass);
  3753. if (filterClass === "x-hide") return;
  3754.  
  3755. titleNode.insertAdjacentHTML(
  3756. "afterbegin",
  3757. `<span class="x-btn" title="列表离线" data-code="${code}" data-title="${title}"></span>`
  3758. );
  3759. if (item.querySelector(".tags")) titleNode.classList.add("x-ellipsis");
  3760. titleNode.classList.add("x-title");
  3761. },
  3762. };
  3763. movie = {
  3764. info: {},
  3765. params: {},
  3766. magnets: [],
  3767.  
  3768. docStart() {
  3769. const style = `
  3770. .video-meta-panel {
  3771. margin: -10px 0 20px;
  3772. padding: 0;
  3773. }
  3774. .video-meta-panel > .columns {
  3775. margin: 0;
  3776. align-items: start;
  3777. }
  3778. .video-meta-panel > .columns > .column {
  3779. padding: 0 10px;
  3780. }
  3781. .video-meta-panel > .columns > .column-video-cover {
  3782. margin: 10px;
  3783. padding: 0;
  3784. aspect-ratio: var(--x-cover-ratio);
  3785. }
  3786. .column-video-cover a:has(> :is(img, video)),
  3787. .column-video-cover .cover-container::after,
  3788. .preview-video-container::after {
  3789. width: 100%;
  3790. height: 100%;
  3791. }
  3792. img, video {
  3793. vertical-align: top;
  3794. }
  3795. :is(.column-video-cover, .tile-images) a:has(> :is(img, video)) {
  3796. display: block;
  3797. background: var(--x-sub-ftc);
  3798. }
  3799. .tile-images a:has(> img) {
  3800. aspect-ratio: var(--x-thumb-ratio);
  3801. }
  3802. .preview-images a:has(> img) {
  3803. aspect-ratio: var(--x-sprite-ratio);
  3804. }
  3805. :root[data-theme="dark"] :is(.column-video-cover, .tile-images) a:has(> :is(img, video)) {
  3806. background: var(--x-grey) !important;
  3807. }
  3808. :is(.column-video-cover, .tile-images) :is(img, video) {
  3809. width: 100% !important;
  3810. height: 100% !important;
  3811. max-height: unset !important;
  3812. object-fit: contain;
  3813. }
  3814. .movie-panel-info div.panel-block {
  3815. padding: 10px 0;
  3816. font-size: 14px;
  3817. line-height: var(--x-line-h);
  3818. }
  3819. :root[data-theme="dark"] .panel .panel-block:last-child {
  3820. border-bottom: none;
  3821. }
  3822. .panel-block:has(#x-res) {
  3823. padding-bottom: 0;
  3824. border-bottom: 0;
  3825. }
  3826. .panel-block:has(#x-match) {
  3827. border-bottom: 0;
  3828. }
  3829. .panel-block:has(#toolbar) {
  3830. padding-top: 0;
  3831. }
  3832. .movie-panel-info .copy-to-clipboard {
  3833. height: var(--x-line-h);
  3834. }
  3835. .video-detail > .columns {
  3836. margin-bottom: 8px;
  3837. }
  3838. .message-header,
  3839. .message-body,
  3840. #magnets-content > .columns > .column {
  3841. padding: 10px;
  3842. }
  3843. .video-panel .tile-images, .plain-grid-list {
  3844. gap: 10px;
  3845. }
  3846. .video-panel .tile-images .tile-item .video-number {
  3847. padding-top: 6px;
  3848. }
  3849. .columns[data-controller="movie-tab"],
  3850. #magnets-content > .columns,
  3851. .plain-grid-list a.box {
  3852. margin: 0;
  3853. }
  3854. .columns[data-controller="movie-tab"] > .column,
  3855. .video-panel .message-body .top-meta {
  3856. padding: 0;
  3857. }
  3858. #tabs-container .message {
  3859. margin-bottom: 20px !important;
  3860. }
  3861. .top-meta :is(.button.is-info, .moj-content) {
  3862. display: none;
  3863. }
  3864. #reviews .review-items .review-item {
  3865. padding: 10px 0;
  3866. }
  3867. #reviews .review-items .review-item:first-child {
  3868. padding-top: 0;
  3869. }
  3870. #reviews .review-items .review-item:last-child {
  3871. padding-bottom: 0;
  3872. }
  3873. .plain-grid-list .item,
  3874. nav.pagination.no-line:has(a) {
  3875. display: flex;
  3876. }
  3877. .plain-grid-list .item {
  3878. align-items: baseline;
  3879. }
  3880. .plain-grid-list .item strong {
  3881. flex: 1;
  3882. padding-right: 10px;
  3883. overflow: hidden;
  3884. white-space: nowrap;
  3885. text-overflow: ellipsis;
  3886. }
  3887. .column-video-cover .cover-container {
  3888. position: absolute;
  3889. top: 50%;
  3890. left: 50%;
  3891. transform: translate(-50%, -50%);
  3892. }
  3893. .isPlayer .cover-container {
  3894. top: 25%;
  3895. }
  3896. .column-video-cover .cover-container .play-button {
  3897. position: unset;
  3898. transform: none;
  3899. }
  3900. .column-video-cover a[id] {
  3901. opacity: 0;
  3902. position: absolute;
  3903. top: 0;
  3904. left: 0;
  3905. }
  3906. .column-video-cover a[id].active {
  3907. z-index: 1;
  3908. opacity: 1;
  3909. transition: opacity .25s linear;
  3910. }
  3911. .column-video-cover video {
  3912. display: inline !important;
  3913. }
  3914. #x-res, #toolbar {
  3915. width: 100%;
  3916. }
  3917. :is(#x-res, #toolbar) button {
  3918. flex: 1;
  3919. }
  3920. .tags:has(.x-jump) {
  3921. margin-bottom: -5px;
  3922. }
  3923. html:has(.fancybox-is-open) {
  3924. overflow: hidden;
  3925. }
  3926. .fancybox-slide--image.fancybox-slide--current {
  3927. overflow: overlay;
  3928. }
  3929. .fancybox-slide--image.fancybox-slide--current .fancybox-content {
  3930. left: 50%;
  3931. width: fit-content !important;
  3932. height: auto !important;
  3933. padding: 44px 0;
  3934. transform: translateX(-50%) !important;
  3935. }
  3936. .fancybox-slide--image.fancybox-slide--current .fancybox-content img {
  3937. position: static;
  3938. width: auto;
  3939. max-width: calc(100vw - 140px);
  3940. height: auto;
  3941. }
  3942. .top-meta:has(.tag) {
  3943. margin-bottom: 10px;
  3944. padding-right: 10px !important;
  3945. }
  3946. .top-meta .tags {
  3947. flex: 1;
  3948. margin: 0 0 -8px;
  3949. }
  3950. #magnets-content {
  3951. ${this.M_LINE > 0 ? `max-height: calc(45px * ${this.M_LINE});` : ""}
  3952. overscroll-behavior-y: contain;
  3953. overflow: overlay;
  3954. }
  3955. :root[data-theme="dark"] #magnets-content::-webkit-scrollbar-thumb {
  3956. background: #4a4a4a !important;
  3957. }
  3958. #magnets-content .item {
  3959. height: 45px;
  3960. border-bottom: 1px solid #ededed;
  3961. }
  3962. :root[data-theme=dark] #magnets-content .item {
  3963. border-color: #4a4a4a;
  3964. }
  3965. #magnets-content .item:last-child {
  3966. border: none;
  3967. }
  3968. #magnets-content .item .column:first-child {
  3969. flex: 3;
  3970. font-weight: bold;
  3971. }
  3972. #magnets-content .item .column:is(:nth-child(1), :nth-child(2), :nth-child(3)) {
  3973. text-align: left;
  3974. }
  3975. #magnets-content .item .column.x-line {
  3976. max-width: 180px;
  3977. }
  3978. #magnets-content .x-from {
  3979. min-width: 65px;
  3980. }
  3981. #magnets-content .item .column:last-child {
  3982. flex: none;
  3983. text-align: right;
  3984. }
  3985. #x-total {
  3986. padding: 10px 10px 0;
  3987. text-align: right;
  3988. }
  3989. #toolbar button.active,
  3990. #magnets-content a[data-magnet].active {
  3991. opacity: .5;
  3992. }
  3993. `;
  3994. this.globalDark(`${this._style.common}${style}`);
  3995. this.listMerge();
  3996. },
  3997. async contentLoaded() {
  3998. this.globalSearch();
  3999. this.modifyLayout();
  4000.  
  4001. const titleNode = DOC.querySelector("h2.title");
  4002. const currentTitle = titleNode.querySelector(".current-title");
  4003. const originTitle = titleNode.querySelector(".origin-title");
  4004. const code = DOC.querySelector(".first-block .value").textContent;
  4005. const title = (originTitle ?? currentTitle).textContent.replace(code, "").trim();
  4006. this.info = {
  4007. code: /^FC2-\d/i.test(code) ? code.replace("-", "-PPV-") : code,
  4008. title,
  4009. transTitle: originTitle ? currentTitle.textContent.trim() : "",
  4010. cover: DOC.querySelector(".column-video-cover img").src,
  4011. isVR: VR_REGEX.test(title),
  4012. studio: "",
  4013. series: "",
  4014. genre: [],
  4015. star: [],
  4016. video: "",
  4017. };
  4018. const video = DOC.querySelector("#preview-video source")?.getAttribute("src") ?? "";
  4019. if (video && (await request(video, {}, "HEAD"))) this.info.video = video;
  4020. for (const item of DOC.querySelectorAll(".movie-panel-info > .panel-block")) {
  4021. let [label, value] = item.querySelectorAll(["strong", ".value"]);
  4022. if (!label || !value) continue;
  4023.  
  4024. label = label?.textContent?.trim();
  4025. if (!label) continue;
  4026.  
  4027. if (["片商:", "賣家:"].includes(label)) this.info.studio = value.textContent.trim();
  4028. if (label === "系列:") this.info.series = value.textContent.trim();
  4029. if (label === "評分:") item.classList.add("score");
  4030. if (label === "類別:") {
  4031. item.classList.add("genre");
  4032. if (!value.querySelector("a")) continue;
  4033. this.info.genre = Array.from(value.querySelectorAll("a")).map(item => item.textContent);
  4034. }
  4035. if (label === "演員:") {
  4036. item.classList.add("star");
  4037. if (!value.querySelector("a")) continue;
  4038. const male = [];
  4039. const female = [];
  4040. value.textContent
  4041. .split("\n")
  4042. .map(item => item.trim())
  4043. .filter(Boolean)
  4044. .forEach(item => {
  4045. (item.includes("♂") ? male : female).push(item.replace(/♂|♀/, ""));
  4046. });
  4047. this.info.star = [...female, ...male];
  4048. }
  4049. }
  4050. this.getMovieResource(this.info);
  4051. if (this.M_COPY) {
  4052. titleNode.insertAdjacentHTML(
  4053. "beforeend",
  4054. `&nbsp;<a class="copy-to-clipboard" title="原始标题" data-clipboard-text="${code} ${title}">复制</a>`
  4055. );
  4056. GM_addStyle("#magnets-content a[data-copy]{display:inline-flex!important}");
  4057. DOC.querySelector(".panel-block.star .value").addEventListener("contextmenu", e => {
  4058. const { target } = e;
  4059. if (target.matches("a")) handleCopy(e, "", target.textContent);
  4060. });
  4061. }
  4062.  
  4063. this.movieRes();
  4064. this.movieTitle();
  4065. this._movieJump();
  4066. this.movieScore();
  4067. this.movieStar();
  4068. this.driveMatch();
  4069. this.refactorTable();
  4070. },
  4071. modifyLayout() {
  4072. if (history.scrollRestoration) history.scrollRestoration = "manual";
  4073. window.scrollTo({ top: 150, left: 0, behavior: "smooth" });
  4074. this.modifyItem();
  4075.  
  4076. unsafeWindow.$.fancybox.defaults.loop = true;
  4077. unsafeWindow.$.fancybox.defaults.smallBtn = false;
  4078. unsafeWindow.$.fancybox.defaults.toolbar = true;
  4079. unsafeWindow.$.fancybox.defaults.buttons = ["slideShow", "thumbs", "close"];
  4080. unsafeWindow.$.fancybox.defaults.animationEffect = "fade";
  4081. unsafeWindow.$.fancybox.defaults.animationDuration = 300;
  4082. unsafeWindow.$.fancybox.defaults.transitionDuration = 150;
  4083. unsafeWindow.$.fancybox.defaults.touch = { vertical: false };
  4084. unsafeWindow.$.fancybox.defaults.wheel = false;
  4085. unsafeWindow.$.fancybox.defaults.clickContent = false;
  4086.  
  4087. const cover = DOC.querySelector(".cover-container");
  4088. if (!cover) return;
  4089.  
  4090. const _cover = cover.cloneNode();
  4091. const playBtn = cover.querySelector(".play-button");
  4092. _cover.append(playBtn.cloneNode(true));
  4093. playBtn.replaceWith(_cover);
  4094. _cover.addEventListener("click", e => e.stopPropagation());
  4095.  
  4096. cover.removeAttribute("rel");
  4097. cover.removeAttribute("class");
  4098. cover.removeAttribute("target");
  4099. cover.href = cover.querySelector("img").src;
  4100. cover.setAttribute("data-fancybox", "gallery");
  4101. },
  4102. modifyItem() {
  4103. const selectors = [".tile-images.tile-small .tile-item"];
  4104. const codeQuery = ".video-number";
  4105. const upQuery = "a:has(> img)";
  4106.  
  4107. const res = [];
  4108. for (const item of DOC.querySelectorAll(selectors)) {
  4109. const img = item.querySelector("img");
  4110. if (!img) continue;
  4111.  
  4112. img.replaceWith(DOC.create("a", { href: VOID }, img.cloneNode()));
  4113. const code = item.querySelector(codeQuery)?.textContent;
  4114. if (!code) continue;
  4115.  
  4116. item.querySelector(".video-title")?.classList.add("x-title");
  4117. res.push({ item, code });
  4118. }
  4119. this.driveMatchForList(res, upQuery);
  4120.  
  4121. this.click.selectors = selectors;
  4122. this.click.codeQuery = codeQuery;
  4123. this.click.upQuery = upQuery;
  4124. this.globalClick();
  4125. },
  4126. movieRes() {
  4127. const { res } = this.params;
  4128. if (!res?.length) return;
  4129.  
  4130. const box = DOC.querySelector(".column-video-cover");
  4131. const info = DOC.querySelector(".movie-panel-info");
  4132. const first = "x-cover";
  4133. const firstQuery = `button[for=${first}]`;
  4134.  
  4135. const cover = box.querySelector("a[data-fancybox]");
  4136. cover.setAttribute("data-fancybox", "tabbar");
  4137. cover.setAttribute("id", first);
  4138. cover.classList.add("active");
  4139. box.insertAdjacentHTML(
  4140. "afterbegin",
  4141. '<div class="x-side prev"><span>🔙</span></div><div class="x-side next"><span>🔜</span></div>'
  4142. );
  4143. info.insertAdjacentHTML(
  4144. "afterbegin",
  4145. `<div class="panel-block">
  4146. <div id="x-res" class="buttons has-addons are-small">
  4147. <button class="button is-light is-active" for="${first}">封面</button>
  4148. ${res
  4149. .map(
  4150. item =>
  4151. `<button class="button is-light is-loading" for="x-${item}" disabled>暂无</button>`
  4152. )
  4153. .join("")}
  4154. </div>
  4155. </div>`
  4156. );
  4157.  
  4158. box.addEventListener("click", e => {
  4159. const { target } = e;
  4160.  
  4161. const side = target.closest(".x-side");
  4162. if (side) {
  4163. e.stopPropagation();
  4164. e.preventDefault();
  4165.  
  4166. const navs = info.querySelectorAll("#x-res button:not([disabled])");
  4167. const { length } = navs;
  4168. if (length === 1) return;
  4169.  
  4170. let index = Array.from(navs).findIndex(item => item.classList.contains("is-active"));
  4171. index = side.classList.contains("next") ? index + 1 : index - 1;
  4172. if (index > length - 1) index = 0;
  4173. if (index === -1) index = length - 1;
  4174. return navs[index].click();
  4175. }
  4176.  
  4177. if (target.closest(".x-player")) {
  4178. e.stopPropagation();
  4179. e.preventDefault();
  4180. return box.querySelector(".x-side.next").click();
  4181. }
  4182. });
  4183. info.querySelector("#x-res").addEventListener("click", ({ target }) => {
  4184. const tag = target.getAttribute("for");
  4185. if (!tag) return;
  4186.  
  4187. const active = box.querySelector(`#${tag}`);
  4188. if (target.classList.contains("is-active")) return active.querySelector("video")?.focus();
  4189.  
  4190. const _target = info.querySelector("#x-res .is-active");
  4191. _target.classList.toggle("is-active");
  4192. if (_target.matches(firstQuery)) box.classList.remove("x-player");
  4193.  
  4194. target.classList.toggle("is-active");
  4195. if (target.matches(firstQuery) && box.classList.contains("isPlayer")) {
  4196. box.classList.add("x-player");
  4197. }
  4198.  
  4199. const _active = box.querySelector(".active");
  4200. _active.classList.toggle("active");
  4201. _active.querySelector("video")?.pause();
  4202.  
  4203. active.classList.toggle("active");
  4204. const video = active.querySelector("video");
  4205. if (!video) return;
  4206.  
  4207. video.focus();
  4208. video.play();
  4209. });
  4210. res.forEach(key => {
  4211. this.upMovieResource(key, val => {
  4212. const id = `x-${key}`;
  4213. const nav = info.querySelector(`button[for=${id}]`);
  4214. nav.classList.remove("is-loading");
  4215. if (!val.length) return;
  4216.  
  4217. this.info[key] = val;
  4218. nav.removeAttribute("disabled");
  4219. nav.innerHTML = TAB_NAME[key];
  4220.  
  4221. const targetId = `${id}-target`;
  4222. const node = key === "img" ? DOC.create(key, { src: val }) : createVideo(val, { id: targetId });
  4223. const container = DOC.create(
  4224. "a",
  4225. { "data-fancybox": "tabbar", id, href: key === "img" ? val : `#${targetId}` },
  4226. node
  4227. );
  4228. box.append(container);
  4229. if (key === "img" || !nav.previousElementSibling?.matches(firstQuery)) return;
  4230. box.classList.add("isPlayer", "x-player");
  4231. });
  4232. });
  4233. },
  4234. movieTitle() {
  4235. this.upMovieResource(
  4236. "title",
  4237. val => {
  4238. DOC.querySelector("#x-title").textContent = val.length ? val : "暂无数据";
  4239. },
  4240. () => {
  4241. DOC.querySelector(".panel-block.first-block").insertAdjacentHTML(
  4242. "beforebegin",
  4243. '<div class="panel-block"><strong>机翻:</strong>&nbsp;<span id="x-title" class="value">查询中...</span></div>'
  4244. );
  4245. }
  4246. );
  4247. },
  4248. _movieJump() {
  4249. this.movieJump(
  4250. this.info,
  4251. res => {
  4252. DOC.querySelector(".panel-block.first-block").insertAdjacentHTML(
  4253. "afterend",
  4254. res
  4255. .map(
  4256. ({ group, list }) =>
  4257. `<div class="panel-block"><strong>${group}:</strong>&nbsp;<div class="tags">${list
  4258. .map(
  4259. ({ url, query, name }) =>
  4260. `<span class="x-jump tag is-light${
  4261. query ? " is-info" : ""
  4262. }" data-query="${query}" data-href="${url}">${name}</span>`
  4263. )
  4264. .join("")}</div></div>`
  4265. )
  4266. .join("")
  4267. );
  4268. },
  4269. (res, { classList }) => {
  4270. classList.remove("is-light");
  4271. if (res.zh) classList.replace("is-info", "is-warning");
  4272. }
  4273. );
  4274. },
  4275. movieScore() {
  4276. const { score } = this.params;
  4277. if (!score?.length) return;
  4278.  
  4279. const scoreTarget = DOC.querySelector(".panel-block.score");
  4280. const insertTarget = scoreTarget ?? DOC.querySelector(".panel-block.genre, .panel-block.star");
  4281. const insertScore = (position, item) => {
  4282. insertTarget?.insertAdjacentHTML(
  4283. position,
  4284. `<div class="panel-block"><strong>${item.toUpperCase()}评分:</strong>&nbsp;<span id="x-${item}_score" class="value">查询中...</span></div>`
  4285. );
  4286. };
  4287.  
  4288. let position = "beforebegin";
  4289. for (const item of score) {
  4290. if (item === "db") {
  4291. if (scoreTarget) {
  4292. scoreTarget.querySelector("strong").innerHTML = "DB评分:";
  4293. position = "afterend";
  4294. }
  4295. continue;
  4296. }
  4297. insertScore(position, item);
  4298. }
  4299. score
  4300. .filter(key => key !== "db")
  4301. .forEach(key => {
  4302. key = `${key}_score`;
  4303. this.upMovieResource(key, val => {
  4304. const node = DOC.querySelector(`#x-${key}`);
  4305.  
  4306. if (!val.length) {
  4307. node.textContent = "暂无数据";
  4308. return;
  4309. }
  4310.  
  4311. const { score, total, num } = val[0];
  4312. let stars = Math.floor((score / total) * 5);
  4313. stars = Array(5).fill("", 0, stars).fill(" gray", stars, 5);
  4314.  
  4315. node.innerHTML = `<span class="score-stars">${stars
  4316. .map(item => `<i class="icon-star${item}"></i>`)
  4317. .join("")}</span>&nbsp;${score}分${num ? `, ${num}人评价` : ""}`;
  4318. });
  4319. });
  4320. },
  4321. movieStar() {
  4322. const target = DOC.querySelector(".panel-block.star .value");
  4323. this.upMovieResource(
  4324. "star",
  4325. val => {
  4326. this.info.star = val;
  4327. target.innerHTML = !val.length
  4328. ? "暂无数据"
  4329. : val
  4330. .map(
  4331. item =>
  4332. `<a href="/search?f=actor&q=${item}">${item}</a><strong class="symbol female">♀</strong>`
  4333. )
  4334. .join("&nbsp;");
  4335. },
  4336. () => {
  4337. target.innerHTML = "查询中...";
  4338. }
  4339. );
  4340. },
  4341. refactorTable() {
  4342. let caption = DOC.querySelector(".top-meta");
  4343. caption.classList.add("is-flex");
  4344. caption.insertAdjacentHTML("afterbegin", '<div class="tags"></div>');
  4345. caption = caption.querySelector(".tags");
  4346. const table = DOC.querySelector("#magnets-content");
  4347. table.parentElement.insertAdjacentHTML("beforeend", '<div id="x-total">总数 0</div>');
  4348.  
  4349. const magnets = [];
  4350. for (const item of table.querySelectorAll(".item")) {
  4351. const first = item.querySelector("a");
  4352. if (!first) continue;
  4353.  
  4354. const size = first.querySelector(".meta")?.textContent?.trim() ?? "";
  4355. magnets.push({
  4356. name: first.querySelector(".name").textContent,
  4357. link: first.href.split("&")[0],
  4358. size,
  4359. bytes: transToBytes(size),
  4360. zh: !!first.querySelector(".tag.is-warning.is-small.is-light"),
  4361. date: item.querySelector(".time")?.textContent ?? "",
  4362. });
  4363. }
  4364. table.innerHTML = "暂无数据";
  4365. this.refactorTbody(magnets);
  4366.  
  4367. (this.params?.magnet ?? []).forEach(key => {
  4368. key = `${key}_magnet`;
  4369. this.upMovieResource(
  4370. key,
  4371. res => this.refactorTbody(res, key),
  4372. () => {
  4373. caption.insertAdjacentHTML(
  4374. "beforeend",
  4375. `<span class="tag is-success is-light" id="x-${key}">${key
  4376. .split("_")[0]
  4377. .toUpperCase()}搜索</span>`
  4378. );
  4379. }
  4380. );
  4381. });
  4382. },
  4383. refactorTbody(magnets, key) {
  4384. if (!magnets.length) return;
  4385.  
  4386. if (key) DOC.querySelector(`#x-${key}`)?.classList.remove("is-light");
  4387. let start;
  4388.  
  4389. if (this.magnets.length) {
  4390. for (const item of magnets) {
  4391. const { link, zh } = item;
  4392. const index = this.magnets.findIndex(item => item.link.toLowerCase() === link.toLowerCase());
  4393. if (index === -1) {
  4394. this.magnets.push(item);
  4395. continue;
  4396. }
  4397. if (zh) this.magnets[index].zh = zh;
  4398. }
  4399. magnets = this.magnets;
  4400. } else {
  4401. const caption = DOC.querySelector(".top-meta");
  4402. start = () => {
  4403. caption
  4404. .querySelector(".tags")
  4405. .insertAdjacentHTML("beforeend", '<span class="tag is-success">磁力排序</span>');
  4406. };
  4407.  
  4408. if (this.M_COPY) {
  4409. caption.insertAdjacentHTML(
  4410. "beforeend",
  4411. `<a href="${VOID}" data-copy="all" title="复制全部磁链" class="tag is-info">复制全部</a>`
  4412. );
  4413. }
  4414.  
  4415. DOC.querySelector("#magnets .message-body").addEventListener("click", e => {
  4416. const { copy, magnet } = e.target.dataset;
  4417. if (!copy && !magnet) return;
  4418.  
  4419. if (magnet) return this._driveOffLine(e);
  4420. if (copy !== "all") return handleCopy(e);
  4421. handleCopy(e, "", this.magnets.map(item => item.link).join("\n"));
  4422. });
  4423. }
  4424. const total = DOC.querySelector("#x-total");
  4425. if (total) total.textContent = `总数 ${magnets.length}`;
  4426. magnets = this.movieSort(magnets, start);
  4427. this.magnets = magnets;
  4428. DOC.querySelector("#magnets-content").innerHTML = this.refactorTr(magnets);
  4429. },
  4430. refactorTr(magnets) {
  4431. return magnets
  4432. .map(
  4433. ({ name, link, size, date, from, href, zh }) =>
  4434. `<div class="item columns odd">
  4435. <div class="column" title="${name}">
  4436. <a href="${link}" class="x-ellipsis">${name}</a>
  4437. </div>
  4438. <div class="column x-line" title="${size}">${size}</div>
  4439. <div class="column x-line" title="${date}">${date}</div>
  4440. <div class="column">
  4441. <a
  4442. class="tag is-danger is-light x-from"
  4443. href="${href || VOID}"
  4444. ${href ? ' target="_blank" title="查看详情"' : ""}
  4445. >${from || Domain}</a>
  4446. </div>
  4447. <div class="column">
  4448. ${zh ? '<span class="tag is-warning is-light">字幕</span>' : ""}
  4449. </div>
  4450. <div class="column">
  4451. <a
  4452. href="${VOID}"
  4453. class="tag is-info is-hidden"
  4454. title="复制磁力链接"
  4455. data-copy="${link}"
  4456. >复制链接</a><a
  4457. href="${VOID}"
  4458. class="tag is-info x-ml is-hidden"
  4459. title="添加离线任务"
  4460. data-magnet="${link}"
  4461. >添加离线</a>
  4462. </div>
  4463. </div>`
  4464. )
  4465. .join("");
  4466. },
  4467. driveMatch() {
  4468. this.driveMatchForMovie(
  4469. this.info,
  4470. res => {
  4471. const refresh = DOC.querySelector("#x-refresh");
  4472. refresh.inert = false;
  4473. refresh.textContent = "刷新资源";
  4474. refresh.classList.remove("active");
  4475.  
  4476. DOC.querySelector("#x-match").innerHTML = !res.length
  4477. ? "暂无数据"
  4478. : res
  4479. .map(
  4480. ({ n, pc, fid, cid, t }) =>
  4481. `<a class="x-ellipsis" href="${VOID}" data-n="${n}" data-pc="${pc}" data-fid="${fid}" data-cid="${cid}" title="[${t}] ${n}"><span class="x-btn" title="资源调整"></span>${n}</a>`
  4482. )
  4483. .join("");
  4484. },
  4485. () => {
  4486. const refresh = DOC.querySelector("#x-refresh");
  4487. if (refresh) {
  4488. refresh.inert = true;
  4489. refresh.textContent = "请求中...";
  4490. return refresh.classList.add("active");
  4491. }
  4492.  
  4493. const { icon, resources } = GM_info.script;
  4494. addPrefetch([icon, ...resources.map(item => item.url)]);
  4495. GM_addStyle("#magnets-content a[data-magnet]{display:inline-flex!important}");
  4496. DOC.querySelector(".movie-panel-info").insertAdjacentHTML(
  4497. "beforeend",
  4498. '<div class="panel-block"><strong>资源:</strong>&nbsp;<span class="value" id="x-match">查询中...</span></div><div class="panel-block"><div id="toolbar" class="buttons has-addons are-small"><button class="button is-info" id="x-magnet" data-magnet="all">一键离线</button><button class="button is-info" id="x-refresh" inert>请求中...</button></div></div>'
  4499. );
  4500. DOC.querySelector("#x-refresh").addEventListener("click", () => this.driveMatch());
  4501. DOC.querySelector("#x-magnet").addEventListener("click", e => this._driveOffLine(e));
  4502. const modify = this.upModifyTarget();
  4503. DOC.querySelector("#x-match").addEventListener("click", e => {
  4504. if (e.target.dataset.pc) this.advancedLink(e, { type: "left" });
  4505. if (e.target.classList.contains("x-btn")) this.driveModify(e, modify);
  4506. });
  4507. DOC.querySelector("#x-match").addEventListener("contextmenu", e => {
  4508. if (e.target.dataset.cid) this.advancedLink(e, { type: "right" });
  4509. });
  4510. }
  4511. );
  4512. },
  4513. _driveOffLine(e) {
  4514. this.driveOffLine(e, { ...this.info, magnets: this.magnets });
  4515. },
  4516. };
  4517. others = {
  4518. docStart() {
  4519. this.globalDark(this._style.common);
  4520. this.listMerge();
  4521. },
  4522. contentLoaded() {
  4523. this.globalSearch();
  4524. },
  4525. };
  4526. }
  4527. class JavBus extends Common {
  4528. constructor() {
  4529. super();
  4530. return super.init();
  4531. }
  4532.  
  4533. routes = {
  4534. list: /^\/((uncensored\/?)?(page\/\d+)?$)|((uncensored\/)?(((search|star)+|genre|studio|label|series|director|member)+\/)|actresses(\/\d+)?)+/i,
  4535. genre: /^\/(uncensored\/)?genre$/i,
  4536. forum: /^\/forum\//i,
  4537. movie: /^\/[a-z0-9]+(-|\w)+/i,
  4538. };
  4539. _style = {
  4540. common: `
  4541. body {
  4542. overflow-y: overlay;
  4543. }
  4544. .ad-box,
  4545. footer {
  4546. display: none;
  4547. }
  4548. `,
  4549. card: `
  4550. a:is(.movie-box, .avatar-box) {
  4551. width: var(--x-thumb-w);
  4552. margin: 10px !important;
  4553. }
  4554. .photo-frame {
  4555. height: auto !important;
  4556. margin: 10px !important;
  4557. background: var(--x-sub-ftc);
  4558. border: none;
  4559. }
  4560. .movie-box .photo-frame {
  4561. aspect-ratio: var(--x-thumb-ratio);
  4562. }
  4563. .avatar-box .photo-frame {
  4564. aspect-ratio: var(--x-avatar-ratio);
  4565. }
  4566. .photo-frame img {
  4567. width: 100%;
  4568. max-width: none !important;
  4569. height: 100% !important;
  4570. max-height: none !important;
  4571. margin: 0 !important;
  4572. object-fit: cover;
  4573. }
  4574. .photo-info {
  4575. height: auto !important;
  4576. padding: 0 10px 10px;
  4577. line-height: var(--x-line-h);
  4578. background: unset;
  4579. border: none;
  4580. }
  4581. `,
  4582. dark: `
  4583. :is(.nav, .dropdown-menu) > li > a:is(:hover, :focus) {
  4584. background: var(--x-grey) !important;
  4585. }
  4586. .nav > :is(li.active, .open) > a,
  4587. .nav > .open > a:is(:hover, :focus),
  4588. .dropdown-menu {
  4589. background: var(--x-bgc) !important;
  4590. }
  4591. .modal-content, .alert {
  4592. background: var(--x-sub-bgc) !important;
  4593. }
  4594. .btn-primary {
  4595. background: var(--x-blue) !important;
  4596. border: none;
  4597. }
  4598. .btn-success {
  4599. background: var(--x-green) !important;
  4600. border: none;
  4601. }
  4602. .btn-warning {
  4603. background: var(--x-orange) !important;
  4604. border: none;
  4605. }
  4606. .btn-danger {
  4607. background: var(--x-red) !important;
  4608. border: none;
  4609. }
  4610. .btn-link {
  4611. background: none !important;
  4612. border: none;
  4613. }
  4614. .btn.disabled, .btn[disabled], fieldset[disabled] .btn {
  4615. opacity: .8 !important;
  4616. }
  4617. `,
  4618. dmCard: `
  4619. .movie-box, .avatar-box {
  4620. background: var(--x-sub-bgc) !important;
  4621. }
  4622. .photo-frame {
  4623. background: var(--x-grey);
  4624. }
  4625. .photo-info {
  4626. color: unset;
  4627. }
  4628. .photo-info span date {
  4629. color: var(--x-sub-ftc);
  4630. }
  4631. `,
  4632. };
  4633. search = {
  4634. selectors: "#search-input",
  4635. pathname: `/search/${REP}`,
  4636. };
  4637. click = {
  4638. selectors: [".movie-box", ".avatar-box"],
  4639. codeQuery: "date",
  4640. upQuery: ".photo-frame",
  4641. };
  4642. merge = {
  4643. start: (list, active) => {
  4644. if (active) {
  4645. active = " active";
  4646. DOC.querySelector("#navbar .active").classList.remove("active");
  4647. }
  4648. DOC.querySelector("#navbar > .nav.navbar-nav")?.insertAdjacentHTML(
  4649. "beforeend",
  4650. `<li id="merge" class="dropdown hidden-sm${active}">
  4651. <a
  4652. href="#"
  4653. class="dropdown-toggle"
  4654. data-toggle="dropdown"
  4655. data-hover="dropdown"
  4656. role="button"
  4657. aria-expanded="false"
  4658. >合并列表 <span class="caret"></span></a>
  4659. <ul class="dropdown-menu" role="menu">
  4660. ${list.reduce((prev, curr) => `${prev}<li><a href="/?merge=${curr}">${curr}</a></li>`, "")}
  4661. </ul>
  4662. </li>`
  4663. );
  4664. },
  4665. };
  4666.  
  4667. list = {
  4668. imgReplace: [
  4669. {
  4670. regex: /\/thumbs?\//i,
  4671. replace: val => val.replace(/\/thumbs?\//g, "/cover/").replace(".jpg", "_b.jpg"),
  4672. },
  4673. {
  4674. regex: /pics\.dmm\.co\.jp/i,
  4675. replace: val => val.replace("ps.jpg", "pl.jpg"),
  4676. },
  4677. ],
  4678.  
  4679. docStart() {
  4680. const { common, card, dark, dmCard } = this._style;
  4681. const style = `
  4682. .alert-common, .alert-page {
  4683. margin-top: 20px;
  4684. }
  4685. .search-header {
  4686. padding: 0;
  4687. background: none;
  4688. box-shadow: none;
  4689. }
  4690. .search-header .nav-tabs, #waterfall {
  4691. display: none;
  4692. }
  4693. #waterfall, #waterfall img {
  4694. opacity: 0;
  4695. }
  4696. .text-center.hidden-xs {
  4697. display: none;
  4698. line-height: 0;
  4699. }
  4700. .pagination {
  4701. margin-bottom: 40px;
  4702. }
  4703. .movie-box .x-title + div {
  4704. height: var(--x-line-h) !important;
  4705. margin: 4px 0;
  4706. }
  4707. .mleft {
  4708. display: flex !important;
  4709. align-items: center;
  4710. }
  4711. .mleft .btn-xs {
  4712. margin: 0 6px 0 0 !important;
  4713. }
  4714. `;
  4715. const dmStyle = `
  4716. .nav-pills > li.active > a {
  4717. background-color: var(--x-blue) !important;
  4718. }
  4719. .pagination > li > a {
  4720. color: var(--x-ftc) !important;
  4721. background-color: var(--x-sub-bgc) !important;
  4722. }
  4723. .pagination > li:not(.active) > a:hover {
  4724. background-color: var(--x-grey) !important;
  4725. }
  4726. `;
  4727. this.globalDark(`${common}${style}${card}${this.listMovieTitle()}`, `${dark}${dmStyle}${dmCard}`);
  4728. this.listMerge();
  4729. this.upLOLTarget();
  4730. },
  4731. contentLoaded() {
  4732. this.globalSearch();
  4733. this.globalClick();
  4734. this.modifyLayout();
  4735. },
  4736. modifyLayout() {
  4737. DOC.querySelector(".search-header .nav")?.classList.replace("nav-tabs", "nav-pills");
  4738.  
  4739. const container = unsafeWindow.$("#waterfall");
  4740. this.listScroll({
  4741. container: "#waterfall",
  4742. path: "#next",
  4743. start: items => container.empty().append(items).show().masonry("reload"),
  4744. showPage: () => DOC.querySelector(".text-center.hidden-xs")?.classList.add("x-show"),
  4745. onLoad: items => {
  4746. items = unsafeWindow.$(items);
  4747. container.append(items).masonry("appended", items);
  4748. },
  4749. });
  4750. },
  4751. modifyItem(items, isMerge) {
  4752. const isMovieList = items.some(item => item.querySelector(".movie-box"));
  4753. const res = [];
  4754. const hlUrls = [];
  4755.  
  4756. for (let index = 0, { length } = items; index < length; index++) {
  4757. const item = items[index];
  4758. let code = "";
  4759. let date = "";
  4760. let highlight = false;
  4761.  
  4762. if (isMovieList) {
  4763. [code, date] = item.querySelectorAll("date");
  4764. if (!code || !date) continue;
  4765.  
  4766. code = code?.textContent.trim();
  4767. date = date?.textContent.replaceAll("-", "").trim();
  4768. if (!code || !date) continue;
  4769.  
  4770. if (isMerge && res.some(t => t.code === code && t.date === date)) continue;
  4771.  
  4772. this.modifyMovieCard(item);
  4773. if (item.querySelector(".x-hide")) continue;
  4774.  
  4775. highlight = item.querySelector(".x-highlight");
  4776. if (highlight) hlUrls.push(highlight.href);
  4777. } else {
  4778. this.modifyAvatarCard(item);
  4779. }
  4780.  
  4781. fadeInImg(item);
  4782. res.push({ code, date, highlight: !!highlight, item });
  4783. }
  4784. if (!res.length) return res;
  4785.  
  4786. if (isMovieList) {
  4787. this.driveMatchForList(res, this.click.upQuery);
  4788. addPrefetch(hlUrls);
  4789. if (isMerge) res.sort((pre, next) => next.date - pre.date);
  4790. res.sort((pre, next) => (pre.highlight > next.highlight ? -1 : 1));
  4791. }
  4792. return res.map(({ item }) => item);
  4793. },
  4794. modifyMovieCard(item) {
  4795. item = item.querySelector(".movie-box");
  4796. if (!item) return;
  4797.  
  4798. const info = item.querySelector(".photo-info span");
  4799. info.querySelector(".__cf_email__")?.remove();
  4800. info.innerHTML = info.innerHTML.replace("<br>", "");
  4801.  
  4802. const titleNode = info.firstChild;
  4803. const title = titleNode.textContent.trim();
  4804. const code = info.querySelector("date").textContent.trim();
  4805. const tags = info.querySelectorAll(".item-tag button");
  4806.  
  4807. const filterClass = this.listFilter({ code, title, tags });
  4808. if (filterClass) item.classList.add(filterClass);
  4809. if (filterClass === "x-hide") return;
  4810.  
  4811. this.listMovieImgType(item, this.imgReplace);
  4812. const reTitle = DOC.create("div", { title, class: "x-ellipsis x-title" }, title);
  4813. reTitle.insertAdjacentHTML(
  4814. "afterbegin",
  4815. `<span class="x-btn" title="列表离线" data-code="${code}" data-title="${title}"></span>`
  4816. );
  4817. titleNode.replaceWith(reTitle);
  4818. },
  4819. modifyAvatarCard(item) {
  4820. item = item.querySelector(".avatar-box");
  4821. if (!item) return;
  4822.  
  4823. const info = item.querySelector("span");
  4824. if (!info.classList.contains("mleft")) return info.classList.add("x-line");
  4825.  
  4826. const titleNode = info.firstChild;
  4827. const title = titleNode.textContent.trim();
  4828. titleNode.replaceWith(DOC.create("div", { title, class: "x-line" }, title));
  4829. info.insertAdjacentElement("afterbegin", info.querySelector("button"));
  4830. },
  4831. };
  4832. genre = {
  4833. docStart() {
  4834. const { common, dark } = this._style;
  4835. const style =
  4836. ":root{accent-color:var(--x-blue)}.container-fluid{padding:0 20px!important}.alert-common{margin:20px 0 0!important}h4{margin:20px 0 10px 0!important}.genre-box{margin:10px 0 20px 0!important;padding:20px!important}.genre-box a{text-align:left!important;cursor:pointer!important;user-select:none!important}.genre-box input{margin:0 4px 0 0!important;vertical-align:middle!important}.x-last-box{margin-bottom:70px!important}button.btn.btn-danger.btn-block.btn-genre{position:fixed!important;bottom:0!important;left:0!important;margin:0!important;border:none!important;border-radius:0!important}";
  4837. const dmStyle = ".genre-box{background:var(--x-sub-bgc)!important}";
  4838. this.globalDark(`${common}${style}`, `${dark}${dmStyle}`);
  4839. this.listMerge();
  4840. },
  4841. contentLoaded() {
  4842. this.globalSearch();
  4843. if (!DOC.querySelector("button.btn.btn-danger.btn-block.btn-genre")) return;
  4844.  
  4845. const box = DOC.querySelectorAll(".genre-box");
  4846. box[box.length - 1].classList.add("x-last-box");
  4847.  
  4848. DOC.querySelector(".container-fluid.pt10").addEventListener("click", ({ target }) => {
  4849. if (target.nodeName !== "A" || !target.classList.contains("text-center")) return;
  4850. const checkbox = target.querySelector("input");
  4851. checkbox.checked = !checkbox.checked;
  4852. });
  4853. },
  4854. };
  4855. forum = {
  4856. docStart() {
  4857. const style =
  4858. "#nv_search #ft,.banner300,.banner728,.bcpic,.bcpic2,.jav-footer{display:none!important}#toptb{position:fixed!important;top:0!important;right:0!important;left:0!important;z-index:999!important;border-color:#e7e7e7;box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 5px rgba(0,0,0,.075)}#search-input{border-right:none!important}.jav-button{margin-top:-3px!important;margin-left:-4px!important}#wp{margin-top:55px!important}#ct:has(#scform){margin-top:38px}.biaoqicn_show a{width:20px!important;height:20px!important;line-height:20px!important;opacity:.7;user-select:none!important}#online .bm_h{border-bottom:none!important}#online .bm_h .o img{margin-top:48%}#moquu_top{right:20px;bottom:20px;box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 5px rgba(0,0,0,.075)}";
  4859. const ifDark = this.G_DARK
  4860. ? "::-webkit-scrollbar-thumb{background:var(--x-grey)!important}*{box-shadow:none!important;font-weight:600}#x-mask,html,img{filter:invert(1) hue-rotate(.5turn)}img{opacity:.85}"
  4861. : "";
  4862. this.globalDark(`${this._style.common}${style}${ifDark}`);
  4863.  
  4864. this.merge.start = list => {
  4865. DOC.querySelector("#toptb ul")?.insertAdjacentHTML(
  4866. "beforeend",
  4867. `<li class="nav-title nav-inactive"><a href="/?merge=${list[0]}">合并列表</a></li>`
  4868. );
  4869. };
  4870. this.listMerge();
  4871. },
  4872. contentLoaded() {
  4873. this.globalSearch();
  4874. },
  4875. };
  4876. movie = {
  4877. info: {},
  4878. params: {},
  4879. magnets: [],
  4880.  
  4881. docStart() {
  4882. const { common, card, dark, dmCard } = this._style;
  4883. const style = `
  4884. #mag-submit-show,
  4885. #mag-submit,
  4886. #magnet-table,
  4887. h4[style="position:relative"],
  4888. h4[style="position:relative"] + .row,
  4889. .info .glyphicon-info-sign {
  4890. display: none !important;
  4891. }
  4892. html {
  4893. padding-right: 0 !important;
  4894. }
  4895. .container {
  4896. margin-bottom: 40px;
  4897. }
  4898. @media (width >= 1270px) {
  4899. .container {
  4900. width: 1270px;
  4901. }
  4902. }
  4903. .row.movie {
  4904. padding: 10px 0;
  4905. }
  4906. @media (width <= 480px) {
  4907. .row.movie {
  4908. padding: 0 !important;
  4909. }
  4910. }
  4911. .screencap, .info {
  4912. border: none !important;
  4913. padding: 0 10px;
  4914. }
  4915. .bigImage {
  4916. position: relative;
  4917. overflow: hidden;
  4918. display: block;
  4919. background: var(--x-sub-ftc);
  4920. aspect-ratio: var(--x-cover-ratio);
  4921. }
  4922. .bigImage :is(img, video) {
  4923. width: 100%;
  4924. height: 100%;
  4925. object-fit: contain;
  4926. }
  4927. .bigImage [id] {
  4928. opacity: 0;
  4929. position: absolute;
  4930. top: 0;
  4931. left: 0;
  4932. }
  4933. .bigImage .active {
  4934. z-index: 1;
  4935. opacity: 1 !important;
  4936. transition: opacity .25s linear;
  4937. }
  4938. @media (width <= 992px) {
  4939. .info {
  4940. padding-top: 10px !important;
  4941. }
  4942. }
  4943. .info p {
  4944. line-height: var(--x-line-h) !important;
  4945. }
  4946. .info :is(.header, .star-show, ul) {
  4947. margin-bottom: 0;
  4948. }
  4949. .info :is(.glyphicon-plus, .glyphicon-minus) {
  4950. margin-left: 4px;
  4951. font-size: 13px;
  4952. }
  4953. .star-box li {
  4954. background: var(--x-sub-ftc) !important;
  4955. }
  4956. .star-box img {
  4957. width: 100% !important;
  4958. height: 100% !important;
  4959. aspect-ratio: var(--x-avatar-ratio) !important;
  4960. font-size: 0;
  4961. margin: 0 !important;
  4962. }
  4963. .star-box .star-name {
  4964. padding: 6px 4px !important;
  4965. background: #fff;
  4966. border: none !important;
  4967. }
  4968. .star-box .star-name,
  4969. :is(.avatar-box, .movie-box) span {
  4970. display: block;
  4971. overflow: hidden;
  4972. white-space: nowrap;
  4973. text-overflow: ellipsis;
  4974. }
  4975. #magneturlpost + .movie {
  4976. margin-top: 20px !important;
  4977. padding: 10px !important;
  4978. }
  4979. #avatar-waterfall,
  4980. #sample-waterfall,
  4981. #related-waterfall {
  4982. margin: -10px !important;
  4983. word-spacing: -20px;
  4984. }
  4985. .avatar-box,
  4986. .sample-box,
  4987. .movie-box {
  4988. vertical-align: top !important;
  4989. word-spacing: 0 !important;
  4990. }
  4991. .avatar-box span {
  4992. padding-top: 0 !important;
  4993. background-color: unset !important;
  4994. border: none !important;
  4995. }
  4996. .sample-box {
  4997. margin: 10px !important;
  4998. width: var(--x-thumb-w) !important;
  4999. }
  5000. .sample-box .photo-frame {
  5001. aspect-ratio: var(--x-sprite-ratio);
  5002. }
  5003. .is-loading {
  5004. animation: spinAround .7s linear infinite;
  5005. }
  5006. @keyframes spinAround {
  5007. 0% { transform: rotate(0deg) }
  5008. to { transform: rotate(359deg) }
  5009. }
  5010. .x-star {
  5011. color: var(--x-orange);
  5012. }
  5013. .x-table {
  5014. margin: 0 !important;
  5015. }
  5016. .x-caption .label {
  5017. position: unset !important;
  5018. }
  5019. .x-table tr {
  5020. display: table;
  5021. width: 100%;
  5022. table-layout: fixed;
  5023. }
  5024. .x-table tr > * {
  5025. vertical-align: middle !important;
  5026. border-left: none !important;
  5027. }
  5028. .x-table tr > *:first-child {
  5029. width: 50px;
  5030. }
  5031. .x-table tr > *:nth-child(2) {
  5032. width: 33.3%;
  5033. }
  5034. .x-table tr > *:last-child,
  5035. .x-table tfoot tr > th:not(:nth-child(3)) {
  5036. border-right: none !important;
  5037. }
  5038. .x-table tbody {
  5039. display: block;
  5040. ${this.M_LINE > 0 ? `max-height: calc(39px * ${this.M_LINE} - 1px);` : ""}
  5041. overscroll-behavior-y: contain;
  5042. overflow: overlay;
  5043. table-layout: fixed;
  5044. }
  5045. .x-table tbody tr > * {
  5046. border-top: none !important;
  5047. }
  5048. .x-table tbody tr:last-child > *,
  5049. .x-table tfoot tr > * {
  5050. border-bottom: none !important;
  5051. }
  5052. .x-table code {
  5053. display: inline-block;
  5054. min-width: 65px;
  5055. }
  5056. .x-table td a:not(:last-child) {
  5057. margin-right: 10px;
  5058. }
  5059. #x-match a {
  5060. color: #CC0000 !important;
  5061. }
  5062. `;
  5063. const dmStyle = `
  5064. .bigImage,
  5065. .btn-group a,
  5066. .star-box li,
  5067. tbody tr:hover,
  5068. .table-striped > tbody > tr:nth-of-type(odd):hover,
  5069. .x-table code {
  5070. background: var(--x-grey) !important;
  5071. }
  5072. .btn-group a.active {
  5073. background: var(--x-bgc) !important;
  5074. }
  5075. .movie,
  5076. .btn-group a[disabled],
  5077. .star-box .star-name,
  5078. .sample-box,
  5079. .table-striped > tbody > tr:nth-of-type(odd) {
  5080. background: var(--x-sub-bgc) !important;
  5081. }
  5082. .avatar-box span {
  5083. color: unset !important;
  5084. }
  5085. `;
  5086. this.globalDark(`${common}${style}${card}`, `${dark}${dmStyle}${dmCard}`);
  5087. this.listMerge();
  5088. },
  5089. contentLoaded() {
  5090. this.globalSearch();
  5091. this.modifyItem();
  5092.  
  5093. const infoNode = DOC.querySelector(".info");
  5094. const info = infoNode.textContent;
  5095. const codeNode = infoNode.querySelector("span[style='color:#CC0000;']");
  5096. const code = codeNode.textContent;
  5097. const titleNode = DOC.querySelector("h3");
  5098. const title = titleNode.textContent.replace(code, "").trim();
  5099.  
  5100. this.info = {
  5101. code,
  5102. title,
  5103. cover: DOC.querySelector(".bigImage img").src,
  5104. isVR: VR_REGEX.test(title),
  5105. studio: info.match(/(?<=製作商: ).+/g)?.pop(0),
  5106. star: Array.from(infoNode.querySelectorAll("ul + p a")).map(item => item.textContent),
  5107. series: info.match(/(?<=系列: ).+/g)?.pop(0),
  5108. genre: Array.from(infoNode.querySelectorAll("p.header + p a")).map(item => item.textContent),
  5109. };
  5110. const cid = DOC.querySelector("#sample-waterfall a.sample-box")?.href;
  5111. if (cid?.includes("pics.dmm.co.jp")) this.info.cid = cid.split("/").at(-2);
  5112. this.getMovieResource(this.info);
  5113.  
  5114. if (this.M_COPY) {
  5115. addCopy(titleNode, { title: "复制标题" });
  5116. addCopy(codeNode, { title: "复制番号" });
  5117. GM_addStyle("tbody a[data-copy]{display:inline!important}");
  5118. infoNode.addEventListener("contextmenu", e => {
  5119. const { target } = e;
  5120. if (!target.closest("#x-star") || !target.matches("a")) return;
  5121. handleCopy(e, "", target.textContent);
  5122. });
  5123. }
  5124.  
  5125. this.movieRes();
  5126. this.movieTitle();
  5127. this._movieJump();
  5128. this.movieScore();
  5129. this.movieStar();
  5130. this.driveMatch();
  5131.  
  5132. const tableObs = new MutationObserver((_, obs) => {
  5133. obs.disconnect();
  5134. this.refactorTable();
  5135. });
  5136. tableObs.observe(DOC.querySelector("#movie-loading"), { attributeFilter: ["style"] });
  5137. },
  5138. modifyItem() {
  5139. const container = DOC.querySelector("#related-waterfall");
  5140. if (!container) return;
  5141.  
  5142. const res = [];
  5143. for (const item of container.querySelectorAll(".movie-box")) {
  5144. const code = item.href?.split("/").at(-1);
  5145. if (!CODE_REGEX.test(code)) continue;
  5146.  
  5147. item.append(DOC.create("date", { class: "x-hide" }, code));
  5148. item.querySelector(".photo-info span").classList.add("x-title");
  5149. res.push({ item, code });
  5150. }
  5151. this.driveMatchForList(res, ".photo-frame");
  5152. this.globalClick();
  5153. },
  5154. movieRes() {
  5155. const { res } = this.params;
  5156. if (!res?.length) return;
  5157.  
  5158. unsafeWindow.$(".bigImage").magnificPopup({
  5159. type: "image",
  5160. closeOnContentClick: true,
  5161. closeBtnInside: false,
  5162. image: { verticalFit: false },
  5163. });
  5164. const box = DOC.querySelector(".bigImage");
  5165. const info = DOC.querySelector(".info");
  5166. const first = "x-cover";
  5167. const firstQuery = `a[for=${first}]`;
  5168.  
  5169. const cover = box.querySelector("img");
  5170. cover.setAttribute("id", first);
  5171. cover.classList.add("active");
  5172. box.insertAdjacentHTML(
  5173. "afterbegin",
  5174. '<div class="x-side prev"><span class="glyphicon glyphicon-chevron-left"></div><div class="x-side next"><span class="glyphicon glyphicon-chevron-right"></div>'
  5175. );
  5176. info.insertAdjacentHTML(
  5177. "afterbegin",
  5178. `<div id="x-res" class="btn-group btn-group-sm btn-group-justified mb10">
  5179. <a href="${VOID}" class="btn btn-default active" role="button" for="${first}">封面</a>
  5180. ${res
  5181. .map(
  5182. item =>
  5183. `<a href="${VOID}" class="btn btn-default" role="button" for="x-${item}" disabled><span class="glyphicon glyphicon-repeat is-loading" aria-hidden="true"></span></a>`
  5184. )
  5185. .join("")}
  5186. </div>`
  5187. );
  5188.  
  5189. box.addEventListener(
  5190. "click",
  5191. e => {
  5192. const { target } = e;
  5193.  
  5194. const side = target.closest(".x-side");
  5195. if (side) {
  5196. e.stopPropagation();
  5197. e.preventDefault();
  5198.  
  5199. const navs = info.querySelectorAll("#x-res a:not([disabled])");
  5200. const { length } = navs;
  5201. if (length === 1) return;
  5202.  
  5203. let index = Array.from(navs).findIndex(item => item.classList.contains("active"));
  5204. index = side.classList.contains("next") ? index + 1 : index - 1;
  5205. if (index > length - 1) index = 0;
  5206. if (index === -1) index = length - 1;
  5207. return navs[index].click();
  5208. }
  5209.  
  5210. if (target.closest(".x-player")) {
  5211. e.stopPropagation();
  5212. e.preventDefault();
  5213. return box.querySelector(".x-side.next").click();
  5214. }
  5215.  
  5216. const { nodeName } = target;
  5217. if (nodeName === "IMG") box.href = target.src;
  5218. if (nodeName !== "VIDEO") return;
  5219.  
  5220. e.stopPropagation();
  5221. e.preventDefault();
  5222. target.paused ? target.play() : target.pause();
  5223. },
  5224. true
  5225. );
  5226. info.querySelector("#x-res").addEventListener("click", ({ target }) => {
  5227. const tag = target.getAttribute("for");
  5228. if (!tag) return;
  5229.  
  5230. const active = box.querySelector(`#${tag}`);
  5231. if (target.classList.contains("active")) return active.focus();
  5232.  
  5233. const _target = info.querySelector("#x-res .active");
  5234. _target.classList.toggle("active");
  5235. if (_target.matches(firstQuery)) box.classList.remove("x-player");
  5236.  
  5237. target.classList.toggle("active");
  5238. if (target.matches(firstQuery) && box.classList.contains("isPlayer")) {
  5239. box.classList.add("x-player");
  5240. }
  5241.  
  5242. const _active = box.querySelector(".active");
  5243. _active.classList.toggle("active");
  5244. if (_active.nodeName === "VIDEO") _active.pause();
  5245.  
  5246. active.classList.toggle("active");
  5247. if (active.nodeName !== "VIDEO") return;
  5248.  
  5249. active.focus();
  5250. active.play();
  5251. });
  5252. res.forEach(key => {
  5253. this.upMovieResource(key, val => {
  5254. const id = `x-${key}`;
  5255. const nav = info.querySelector(`a[for=${id}]`);
  5256. if (!val.length) {
  5257. nav.innerHTML = "暂无";
  5258. return;
  5259. }
  5260.  
  5261. this.info[key] = val;
  5262. nav.removeAttribute("disabled");
  5263. nav.innerHTML = TAB_NAME[key];
  5264.  
  5265. const node = key === "img" ? DOC.create(key, { src: val, id }) : createVideo(val, { id });
  5266. box.append(node);
  5267. if (key === "img" || !nav.previousElementSibling?.matches(firstQuery)) return;
  5268. box.classList.add("isPlayer", "x-player");
  5269. });
  5270. });
  5271. },
  5272. movieTitle() {
  5273. this.upMovieResource(
  5274. "title",
  5275. val => {
  5276. DOC.querySelector("#x-title").textContent = val.length ? val : "暂无数据";
  5277. },
  5278. () => {
  5279. DOC.querySelector("span[style='color:#CC0000;']").parentElement.insertAdjacentHTML(
  5280. "beforebegin",
  5281. '<p><span class="header">机翻标题:</span> <span id="x-title">查询中...</span></p>'
  5282. );
  5283. }
  5284. );
  5285. },
  5286. _movieJump() {
  5287. this.movieJump(
  5288. this.info,
  5289. res => {
  5290. DOC.querySelector("span[style='color:#CC0000;']").parentElement.insertAdjacentHTML(
  5291. "afterend",
  5292. res
  5293. .map(
  5294. ({ group, list }) =>
  5295. `<p><span class="header">${group}:</span> ${list
  5296. .map(
  5297. ({ url, query, name }) =>
  5298. `<button type="button" class="x-jump btn ${
  5299. query ? "btn-default" : "btn-link"
  5300. } btn-xs" data-query="${query}" data-href="${url}">${name}</button>`
  5301. )
  5302. .join("")}</p>`
  5303. )
  5304. .join("")
  5305. );
  5306. },
  5307. (res, node) => node.classList.replace("btn-default", res.zh ? "btn-warning" : "btn-primary")
  5308. );
  5309. },
  5310. movieScore() {
  5311. const { score } = this.params;
  5312. if (!score?.length) return;
  5313.  
  5314. DOC.querySelector("p.header, p.star-show").insertAdjacentHTML(
  5315. "beforebegin",
  5316. score
  5317. .map(
  5318. item =>
  5319. `<p><span class="header">${item.toUpperCase()}评分:</span> <span id="x-${item}_score">查询中...</span></p>`
  5320. )
  5321. .join("")
  5322. );
  5323. score.forEach(key => {
  5324. key = `${key}_score`;
  5325. this.upMovieResource(key, val => {
  5326. const node = DOC.querySelector(`#x-${key}`);
  5327.  
  5328. if (!val.length) {
  5329. node.textContent = "暂无数据";
  5330. return;
  5331. }
  5332.  
  5333. const { score, total, num } = val[0];
  5334. let stars = Math.floor((score / total) * 5);
  5335. stars = Array(5).fill(" x-star", 0, stars).fill("", stars, 5);
  5336.  
  5337. node.innerHTML = `${stars
  5338. .map(item => `<span class="glyphicon glyphicon-star${item}"></span>`)
  5339. .join("")} ${score}分${num ? `, ${num}人评价` : ""}`;
  5340. });
  5341. });
  5342. },
  5343. movieStar() {
  5344. const noStar = DOC.querySelector(".glyphicon-info-sign");
  5345. if (!noStar) return DOC.querySelector(".info ul + p").setAttribute("id", "x-star");
  5346. noStar.nextSibling.replaceWith(DOC.create("p", { id: "x-star" }, "暫無出演者資訊"));
  5347.  
  5348. this.upMovieResource(
  5349. "star",
  5350. val => {
  5351. this.info.star = val;
  5352. DOC.querySelector("#x-star").innerHTML = !val.length
  5353. ? "暂无数据"
  5354. : val
  5355. .map(item => `<span class="genre"><a href="/searchstar/${item}">${item}</a></span>`)
  5356. .join("");
  5357. },
  5358. () => {
  5359. DOC.querySelector("#x-star").innerHTML = "查询中...";
  5360. }
  5361. );
  5362. },
  5363. refactorTable() {
  5364. const table = DOC.querySelector("#magnet-table");
  5365. const keys = (this.params?.magnet ?? []).map(item => `${item}_magnet`);
  5366. const magnets = [];
  5367.  
  5368. if (this.params.hasOwnProperty("sub")) {
  5369. keys.unshift("sub");
  5370. } else {
  5371. for (const tr of table.querySelectorAll("tr")) {
  5372. let [first, size, date] = tr.querySelectorAll("td");
  5373. if (!first || !size || !date) continue;
  5374.  
  5375. const link = first.querySelector("a");
  5376. if (!link?.href) continue;
  5377.  
  5378. size = size?.textContent?.trim() ?? "";
  5379. magnets.push({
  5380. name: link?.textContent?.trim() ?? "",
  5381. link: link.href.split("&")[0],
  5382. zh: !!first.querySelector("a.btn.btn-mini-new.btn-warning.disabled"),
  5383. size,
  5384. bytes: transToBytes(size),
  5385. date: date?.textContent?.trim() ?? "",
  5386. });
  5387. }
  5388. }
  5389. table.parentElement.innerHTML = `
  5390. <table class="table table-striped table-hover table-bordered x-table">
  5391. <caption><div class="x-flex-center x-caption">重构的表格</div></caption>
  5392. <thead>
  5393. <tr>
  5394. <th scope="col">#</th>
  5395. <th scope="col">磁力名称</th>
  5396. <th scope="col">档案大小</th>
  5397. <th scope="col">分享日期</th>
  5398. <th scope="col" class="text-center">来源</th>
  5399. <th scope="col" class="text-center">字幕</th>
  5400. <th scope="col">操作</th>
  5401. </tr>
  5402. </thead>
  5403. <tbody>
  5404. <tr><th scope="row" colspan="7" class="text-center text-muted">暂无数据</th></tr>
  5405. </tbody>
  5406. <tfoot>
  5407. <tr>
  5408. <th scope="row"></th>
  5409. <th></th>
  5410. <th colspan="4" class="text-right">总数</th>
  5411. <td>0</td>
  5412. </tr>
  5413. </tfoot>
  5414. </table>`;
  5415. const caption = DOC.querySelector(".x-table .x-caption");
  5416.  
  5417. this.refactorTbody(magnets);
  5418. keys.forEach(key => {
  5419. this.upMovieResource(
  5420. key,
  5421. res => this.refactorTbody(res, key),
  5422. () => {
  5423. caption.insertAdjacentHTML(
  5424. "beforeend",
  5425. `<span class="label label-default" id="x-${key}"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> ${
  5426. key === "sub" ? "字幕筛选" : `${key.split("_")[0].toUpperCase()}搜索`
  5427. }</span>`
  5428. );
  5429. }
  5430. );
  5431. });
  5432. },
  5433. refactorTbody(magnets, key) {
  5434. if (!magnets.length) return;
  5435.  
  5436. const table = DOC.querySelector(".x-table");
  5437. if (key) table.querySelector(`#x-${key}`).classList.replace("label-default", "label-success");
  5438. let start;
  5439.  
  5440. if (this.magnets.length) {
  5441. for (const item of magnets) {
  5442. const { link, zh } = item;
  5443. const index = this.magnets.findIndex(item => item.link.toLowerCase() === link.toLowerCase());
  5444. if (index === -1) {
  5445. this.magnets.push(item);
  5446. continue;
  5447. }
  5448. if (zh) this.magnets[index].zh = zh;
  5449. }
  5450. magnets = this.magnets;
  5451. } else {
  5452. start = () => {
  5453. table
  5454. .querySelector(".x-caption")
  5455. .insertAdjacentHTML(
  5456. "beforeend",
  5457. '<span class="label label-success" id="x-sort"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> 磁力排序</span>'
  5458. );
  5459. };
  5460.  
  5461. if (this.M_COPY) {
  5462. table.querySelector(
  5463. "thead th:last-child"
  5464. ).innerHTML = `<a href="${VOID}" data-copy="all" title="复制全部磁链">复制全部</a>`;
  5465. }
  5466.  
  5467. table.addEventListener("click", e => {
  5468. const { copy, magnet } = e.target.dataset;
  5469. if (!copy && !magnet) return;
  5470.  
  5471. if (magnet) return this._driveOffLine(e);
  5472. if (copy !== "all") return handleCopy(e);
  5473. handleCopy(e, "", this.magnets.map(item => item.link).join("\n"));
  5474. });
  5475. }
  5476. table.querySelector("tfoot td").textContent = magnets.length;
  5477. magnets = this.movieSort(magnets, start);
  5478. this.magnets = magnets;
  5479. table.querySelector("tbody").innerHTML = this.refactorTr(magnets);
  5480. },
  5481. refactorTr(magnets) {
  5482. return magnets
  5483. .map(
  5484. ({ name, link, size, date, from, href, zh }, index) => `
  5485. <tr>
  5486. <th scope="row">${++index}</th>
  5487. <th class="x-line" title="${name}">
  5488. <a href="${link}">${name}</a>
  5489. </th>
  5490. <td>${size}</td>
  5491. <td>${date}</td>
  5492. <td class="text-center">
  5493. <a href="${href || VOID}"${href ? ` target="_blank" title="查看详情"` : ""}>
  5494. <code>${from || Domain}</code>
  5495. </a>
  5496. </td>
  5497. <td class="text-center">
  5498. <span class="glyphicon glyphicon-${zh ? "ok" : "remove"}-circle text-${
  5499. zh ? "success" : "danger"
  5500. }"></span>
  5501. </td>
  5502. <td>
  5503. <a hidden href="${VOID}" data-copy="${link}" title="复制磁力链接">复制磁链</a><a hidden href="${VOID}" data-magnet="${link}" class="text-success" title="添加离线任务">添加离线</a>
  5504. </td>
  5505. </tr>`
  5506. )
  5507. .join("");
  5508. },
  5509. driveMatch() {
  5510. this.driveMatchForMovie(
  5511. this.info,
  5512. res => {
  5513. const refresh = DOC.querySelector("#x-refresh");
  5514. refresh.inert = false;
  5515. refresh.textContent = "刷新资源";
  5516. refresh.classList.remove("active");
  5517.  
  5518. DOC.querySelector("#x-match").innerHTML = !res.length
  5519. ? "暂无数据"
  5520. : res
  5521. .map(
  5522. ({ n, pc, fid, cid, t }) =>
  5523. `<a class="show x-line" href="${VOID}" data-n="${n}" data-pc="${pc}" data-fid="${fid}" data-cid="${cid}" title="[${t}] ${n}"><span class="x-btn" title="资源调整"></span>${n}</a>`
  5524. )
  5525. .join("");
  5526. },
  5527. () => {
  5528. const refresh = DOC.querySelector("#x-refresh");
  5529. if (refresh) {
  5530. refresh.inert = true;
  5531. refresh.textContent = "请求中...";
  5532. return refresh.classList.add("active");
  5533. }
  5534.  
  5535. const { icon, resources } = GM_info.script;
  5536. addPrefetch([icon, ...resources.map(item => item.url)]);
  5537. GM_addStyle("tbody a[data-magnet]{display:inline!important}");
  5538. DOC.querySelector(".info").insertAdjacentHTML(
  5539. "beforeend",
  5540. `<p class="header">网盘资源:</p><p id="x-match">查询中...</p><div class="btn-group btn-group-sm btn-group-justified"><a href="${VOID}" class="btn btn-default" role="button" id="x-magnet" data-magnet="all">一键离线</a><a href="${VOID}" class="btn btn-default active" role="button" id="x-refresh" inert>请求中...</a></div>`
  5541. );
  5542. DOC.querySelector("#x-refresh").addEventListener("click", () => this.driveMatch());
  5543. DOC.querySelector("#x-magnet").addEventListener("click", e => this._driveOffLine(e));
  5544. const modify = this.upModifyTarget();
  5545. DOC.querySelector("#x-match").addEventListener("click", e => {
  5546. if (e.target.dataset.pc) this.advancedLink(e, { type: "left" });
  5547. if (e.target.classList.contains("x-btn")) this.driveModify(e, modify);
  5548. });
  5549. DOC.querySelector("#x-match").addEventListener("contextmenu", e => {
  5550. if (e.target.dataset.cid) this.advancedLink(e, { type: "right" });
  5551. });
  5552. }
  5553. );
  5554. },
  5555. _driveOffLine(e) {
  5556. this.driveOffLine(e, { ...this.info, magnets: this.magnets });
  5557. },
  5558. };
  5559. }
  5560. class Drive115 {
  5561. beforeUnload_time = 0;
  5562. docStart() {
  5563. Store.setVerifyStatus("pending");
  5564.  
  5565. unsafeWindow.onbeforeunload = () => {
  5566. this.beforeUnload_time = new Date().getTime();
  5567. };
  5568. unsafeWindow.onunload = () => {
  5569. if (new Date().getTime() - this.beforeUnload_time > 5) return;
  5570. Store.setVerifyStatus("failed");
  5571. };
  5572. }
  5573. contentLoaded() {
  5574. unsafeWindow.focus();
  5575. DOC.querySelector("#js_ver_code_box button[rel=verify]").addEventListener("click", () => {
  5576. const interval = setInterval(() => {
  5577. if (DOC.querySelector(".vcode-hint").getAttribute("style").indexOf("none") !== -1) {
  5578. Store.setVerifyStatus("verified");
  5579. unsafeWindow.onbeforeunload = null;
  5580. unsafeWindow.onunload = null;
  5581. clearTimer();
  5582. unsafeWindow.open("", "_self");
  5583. unsafeWindow.close();
  5584. }
  5585. }, 300);
  5586. const timeout = setTimeout(() => clearTimer(), 600);
  5587.  
  5588. const clearTimer = () => {
  5589. clearInterval(interval);
  5590. clearTimeout(timeout);
  5591. };
  5592. });
  5593. }
  5594. }
  5595.  
  5596. try {
  5597. const Process = eval(`new ${Domain}()`);
  5598. Process.docStart?.();
  5599. DOC.addEventListener("XContentLoaded", () => Process.contentLoaded?.(), { once: true });
  5600. } catch (err) {
  5601. console.error(`${GM_info.script.name}: 无匹配模块`);
  5602. }
  5603. })();