JavScript

一站式体验,JavBus & JavDB 兼容

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

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