JavScript

一站式体验,JavBus & JavDB 兼容

Version au 17/02/2023. Voir la dernière version.

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