移除跳转播放无用的地址

This commit is contained in:
lzyme.dev@gmail.com
2026-08-30 19:09:07 +08:00
parent 03700906e5
commit e92991c365
4 changed files with 408 additions and 533 deletions
+278 -428
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+95 -96
View File
@@ -1,6 +1,6 @@
import { BasePlugin } from '../core/base-plugin.js'; import {BasePlugin} from '../core/base-plugin.js';
import { __publicField, isJavBus, isJavDb } from '../core/constants.js'; import {__publicField, isJavBus, isJavDb} from '../core/constants.js';
import { AsyncQueue } from '../core/utils.js'; import {AsyncQueue} from '../core/utils.js';
class OtherSitePlugin extends BasePlugin { class OtherSitePlugin extends BasePlugin {
constructor() { constructor() {
@@ -10,98 +10,97 @@ class OtherSitePlugin extends BasePlugin {
__publicField(this, "warnBackgroundColor", "#d7a80c"); __publicField(this, "warnBackgroundColor", "#d7a80c");
__publicField(this, "domainErrorBackgroundColor", "#d7780c"); __publicField(this, "domainErrorBackgroundColor", "#d7780c");
__publicField(this, "asyncQueue", new AsyncQueue); __publicField(this, "asyncQueue", new AsyncQueue);
__publicField(this, "siteConfigs", [ { __publicField(this, "siteConfigs", [
id: "javTrailersBtn", {
getBaseUrl: async () => await this.getJavTrailersUrl(), id: "MissAvBtn",
itemSelector: ".videos-list .video-link", getBaseUrl: async () => await this.getMissAvUrl(),
searchPath: (baseUrl, carNum2) => `${baseUrl}/search/${carNum2}`, itemSelector: ".text-secondary",
getDetailPageHref: $box2 => $box2.attr("href"), searchPath: (baseUrl, carNum2) => `${baseUrl}/search/${carNum2}`,
findCarNumOrTitle: $box2 => $box2.find("p.card-text").text() getDetailPageHref: $box2 => $box2.attr("href"),
}, { findCarNumOrTitle: $box2 => $box2.text()
id: "123AvBtn", }, {
getBaseUrl: async () => await this.getAv123Url() + "/ja", id: "123AvBtn",
itemSelector: ".box-item", getBaseUrl: async () => await this.getAv123Url() + "/ja",
searchPath: (baseUrl, carNum2) => `${baseUrl}/search?keyword=${carNum2}`, itemSelector: ".box-item",
getDetailPageHref: $box2 => $box2.find(".detail a").attr("href"), searchPath: (baseUrl, carNum2) => `${baseUrl}/search?keyword=${carNum2}`,
findCarNumOrTitle: $box2 => $box2.find("img").attr("title") getDetailPageHref: $box2 => $box2.find(".detail a").attr("href"),
}, { findCarNumOrTitle: $box2 => $box2.find("img").attr("title")
id: "jableBtn", }, {
getBaseUrl: async () => await this.getjableUrl(), id: "JableBtn",
itemSelector: "#list_videos_videos_list_search_result .detail .title a", getBaseUrl: async () => await this.getjableUrl(),
searchPath: (baseUrl, carNum2) => `${baseUrl}/search/${carNum2}/`, itemSelector: "#list_videos_videos_list_search_result .detail .title a",
getDetailPageHref: $box2 => $box2.attr("href"), searchPath: (baseUrl, carNum2) => `${baseUrl}/search/${carNum2}/`,
findCarNumOrTitle: $box2 => $box2.text() getDetailPageHref: $box2 => $box2.attr("href"),
}, { findCarNumOrTitle: $box2 => $box2.text()
id: "avgleBtn", }, {
getBaseUrl: async () => await this.getAvgleUrl(), id: "SupJavBtn",
itemSelector: ".text-secondary", getBaseUrl: async () => await this.getSupJavUrl(),
searchPath: (baseUrl, carNum2) => `${baseUrl}/vod/search.html?wd=${carNum2}`, itemSelector: ".posts post",
getDetailPageHref: $box2 => $box2.attr("href"), searchPath: (baseUrl, carNum2) => `${baseUrl}/?s=${carNum2}`,
findCarNumOrTitle: $box2 => $box2.text() getDetailPageHref: ($box2, baseUrl, carNum2) => $box2.attr("href"),
}, { findCarNumOrTitle: $box2 => $box2.attr("title")
id: "missAvBtn", },
getBaseUrl: async () => await this.getMissAvUrl(), {
itemSelector: ".text-secondary", id: "JavTrailersBtn",
searchPath: (baseUrl, carNum2) => `${baseUrl}/search/${carNum2}`, getBaseUrl: async () => await this.getJavTrailersUrl(),
getDetailPageHref: $box2 => $box2.attr("href"), itemSelector: ".videos-list .video-link",
findCarNumOrTitle: $box2 => $box2.text() searchPath: (baseUrl, carNum2) => `${baseUrl}/search/${carNum2}`,
}, { getDetailPageHref: $box2 => $box2.attr("href"),
id: "supJavBtn", findCarNumOrTitle: $box2 => $box2.find("p.card-text").text()
getBaseUrl: async () => await this.getSupJavUrl(), },
itemSelector: ".posts post",
searchPath: (baseUrl, carNum2) => `${baseUrl}/?s=${carNum2}`, {
getDetailPageHref: ($box2, baseUrl, carNum2) => $box2.attr("href"), id: "JavDbBtn",
findCarNumOrTitle: $box2 => $box2.attr("title") getBaseUrl: async () => await this.getJavDbUrl(),
}, { itemSelector: ".movie-list .item",
id: "javDbBtn", searchPath: (baseUrl, carNum2) => `${baseUrl}/search?q=${carNum2}`,
getBaseUrl: async () => await this.getJavDbUrl(), getDetailPageHref: $box2 => $box2.find("a").attr("href"),
itemSelector: ".movie-list .item", findCarNumOrTitle: $box2 => $box2.find(".video-title").text(),
searchPath: (baseUrl, carNum2) => `${baseUrl}/search?q=${carNum2}`, condition: sourceCarNum => isJavBus
getDetailPageHref: $box2 => $box2.find("a").attr("href"), }, {
findCarNumOrTitle: $box2 => $box2.find(".video-title").text(), id: "JavBusBtn",
condition: sourceCarNum => isJavBus getBaseUrl: async () => await this.getJavBusUrl(),
}, { itemSelector: ".container h3",
id: "javBusBtn", searchPath: (baseUrl, carNum2) => `${baseUrl}/${carNum2}`,
getBaseUrl: async () => await this.getJavBusUrl(), getDetailPageHref: ($box2, baseUrl, carNum2) => `${baseUrl}/${carNum2}`,
itemSelector: ".container h3", findCarNumOrTitle: $box2 => $box2.text(),
searchPath: (baseUrl, carNum2) => `${baseUrl}/${carNum2}`, condition: sourceCarNum => isJavDb && sourceCarNum && !sourceCarNum.includes("FC2")
getDetailPageHref: ($box2, baseUrl, carNum2) => `${baseUrl}/${carNum2}`, }]);
findCarNumOrTitle: $box2 => $box2.text(),
condition: sourceCarNum => isJavDb && sourceCarNum && !sourceCarNum.includes("FC2")
}, {
id: "fanzaBtn",
noHandle: !0,
initUrl: carNum2 => `https://www.dmm.co.jp/search/=/searchstr=${carNum2}`,
condition: sourceCarNum => sourceCarNum && !sourceCarNum.includes("FC2")
} ]);
__publicField(this, "settingCache", null); __publicField(this, "settingCache", null);
__publicField(this, "lastFetchTime", 0); __publicField(this, "lastFetchTime", 0);
__publicField(this, "CACHE_DURATION", 1e4); __publicField(this, "CACHE_DURATION", 1e4);
} }
getName() { getName() {
return "OtherSitePlugin"; return "OtherSitePlugin";
} }
async initCss() { async initCss() {
return "\n <style>\n .site-btn {\n position: relative !important;\n min-width: 80px;\n display: inline-block;\n padding: 5px 10px;\n color: white !important;\n background-color:#938585;\n text-decoration: none;\n border-radius: 4px;\n text-align: center;\n margin-bottom: 5px;\n }\n .site-btn:hover {\n color: white;\n transform: translateY(-2px);\n box-shadow: 0 2px 5px rgba(0,0,0,0.1);\n }\n .site-tag {\n position: absolute; \n top: -15px; \n right: 0; \n background-color: #ffc107; \n color: #333; \n font-size: 12px; \n padding: 2px 6px; \n border-radius: 4px;\n }\n </style>\n "; return "\n <style>\n .site-btn {\n position: relative !important;\n min-width: 80px;\n display: inline-block;\n padding: 5px 10px;\n color: white !important;\n background-color:#938585;\n text-decoration: none;\n border-radius: 4px;\n text-align: center;\n margin-bottom: 5px;\n }\n .site-btn:hover {\n color: white;\n transform: translateY(-2px);\n box-shadow: 0 2px 5px rgba(0,0,0,0.1);\n }\n .site-tag {\n position: absolute; \n top: -15px; \n right: 0; \n background-color: #ffc107; \n color: #333; \n font-size: 12px; \n padding: 2px 6px; \n border-radius: 4px;\n }\n </style>\n ";
} }
async handle() { async handle() {
window.isDetailPage && this.loadOtherSite().then(); window.isDetailPage && this.loadOtherSite().then();
} }
async loadOtherSite(carNum2, sourceCarNum) { async loadOtherSite(carNum2, sourceCarNum) {
if ("yes" !== await storageManager.getSetting("enableLoadOtherSite", "yes")) return; if ("yes" !== await storageManager.getSetting("enableLoadOtherSite", "yes")) return;
carNum2 || (carNum2 = this.getPageInfo().carNum); carNum2 || (carNum2 = this.getPageInfo().carNum);
const enabledSites = this.getEnabledSites(), html = `\n <div id="otherSiteBox" class="panel-block" style="${isJavDb ? "margin-top:8px;font-size:13px" : "margin-top:10px;font-size:13px"}; user-select: none; ">\n <div style="display: flex;gap: 5px;flex-wrap: wrap">\n ${this.siteConfigs.map((config => { const enabledSites = this.getEnabledSites(),
config.sourceCarNum = sourceCarNum; html = `\n <div id="otherSiteBox" class="panel-block" style="${isJavDb ? "margin-top:8px;font-size:13px" : "margin-top:10px;font-size:13px"}; user-select: none; ">\n <div style="display: flex;gap: 5px;flex-wrap: wrap">\n ${this.siteConfigs.map((config => {
if (config.condition && !1 === config.condition(config.sourceCarNum)) return ""; config.sourceCarNum = sourceCarNum;
return `<a target="_blank" class="site-btn" style="${enabledSites.includes(config.id) ? "" : "display:none"}" id="${config.id}"><span>${config.id.replace("Btn", "")}</span></a>`; if (config.condition && !1 === config.condition(config.sourceCarNum)) return "";
})).join("")}\n <a id="settingSiteBtn" class="site-btn"><span>设置</span></a>\n </div>\n </div>\n \n <div id="settingsArea" class="panel-block" style="display: none; margin-top:10px; margin-bottom: 10px; user-select: none; ">\n <div id="siteCheckboxes" style="display: flex;gap: 5px;flex-wrap: wrap">\n </div>\n </div>\n `; return `<a target="_blank" class="site-btn" style="${enabledSites.includes(config.id) ? "" : "display:none"}" id="${config.id}"><span>${config.id.replace("Btn", "")}</span></a>`;
})).join("")}\n <a id="settingSiteBtn" class="site-btn"><span>跳转设置</span></a>\n </div>\n </div>\n \n <div id="settingsArea" class="panel-block" style="display: none; margin-top:10px; margin-bottom: 10px; user-select: none; ">\n <div id="siteCheckboxes" style="display: flex;gap: 5px;flex-wrap: wrap">\n </div>\n </div>\n `;
$(".movie-panel-info").append(html); $(".movie-panel-info").append(html);
$(".container .info").append(html); $(".container .info").append(html);
$("#javTrailersBtn").on("click", (async event => { $("#javTrailersBtn").on("click", (async event => {
event.preventDefault(); event.preventDefault();
let settingObj = await storageManager.getSetting(); let settingObj = await storageManager.getSetting();
const filterHotKey = settingObj.filterHotKey, favoriteHotKey = settingObj.favoriteHotKey, speedVideoHotKey = settingObj.speedVideoHotKey; const filterHotKey = settingObj.filterHotKey, favoriteHotKey = settingObj.favoriteHotKey,
let href = $("#javTrailersBtn").attr("href"), url = href + `?handle=1&filterHotKey=${filterHotKey}&favoriteHotKey=${favoriteHotKey}&speedVideoHotKey=${speedVideoHotKey}`; speedVideoHotKey = settingObj.speedVideoHotKey;
let href = $("#javTrailersBtn").attr("href"),
url = href + `?handle=1&filterHotKey=${filterHotKey}&favoriteHotKey=${favoriteHotKey}&speedVideoHotKey=${speedVideoHotKey}`;
event && (event.ctrlKey || event.metaKey) && (url = href); event && (event.ctrlKey || event.metaKey) && (url = href);
utils.openPage(url, carNum2, !1, event); utils.openPage(url, carNum2, !1, event);
})); }));
@@ -111,26 +110,15 @@ class OtherSitePlugin extends BasePlugin {
this.renderSettingsArea(); this.renderSettingsArea();
this.setupEventListeners(); this.setupEventListeners();
} }
async handleSite(carNum2, config) { async handleSite(carNum2, config) {
const $btn = $(`#${config.id}`); const $btn = $(`#${config.id}`);
if (config.initUrl) { try {
$btn.attr("href", config.initUrl(carNum2));
$btn.css("backgroundColor", this.warnBackgroundColor);
}
if (config.noHandle && !0 === config.noHandle) {
const dmmCacheKey = "jhs_other_site_dmm", dmmCachedResult = (localStorage.getItem(dmmCacheKey) ? JSON.parse(localStorage.getItem(dmmCacheKey)) : {})[carNum2];
if (dmmCachedResult) if ("single" === dmmCachedResult.type) {
$btn.attr("href", dmmCachedResult.url);
$btn.css("backgroundColor", this.okBackgroundColor);
} else if ("multiple" === dmmCachedResult.type) {
$btn.attr("href", dmmCachedResult.url);
$btn.append('<span class="site-tag" style="top:-15px">多结果</span>');
$btn.css("backgroundColor", this.okBackgroundColor);
}
} else try {
if ($btn.attr("href")) return; if ($btn.attr("href")) return;
if (utils.isHidden($btn)) return; if (utils.isHidden($btn)) return;
const cacheKey = "jhs_other_site", cacheData = localStorage.getItem(cacheKey) ? JSON.parse(localStorage.getItem(cacheKey)) : {}, siteKey = carNum2 + "_" + config.id.replace("Btn", ""), cachedResult = cacheData[siteKey]; const cacheKey = "jhs_other_site",
cacheData = localStorage.getItem(cacheKey) ? JSON.parse(localStorage.getItem(cacheKey)) : {},
siteKey = carNum2 + "_" + config.id.replace("Btn", ""), cachedResult = cacheData[siteKey];
if (cachedResult) { if (cachedResult) {
if ("single" === cachedResult.type) { if ("single" === cachedResult.type) {
$btn.attr("href", cachedResult.url); $btn.attr("href", cachedResult.url);
@@ -144,7 +132,8 @@ class OtherSitePlugin extends BasePlugin {
} }
const baseUrl = await config.getBaseUrl(), searchUrl = config.searchPath(baseUrl, carNum2); const baseUrl = await config.getBaseUrl(), searchUrl = config.searchPath(baseUrl, carNum2);
$btn.attr("href", searchUrl); $btn.attr("href", searchUrl);
const html = await gmHttp.get(searchUrl, null, config.headers, !0), $dom = utils.htmlTo$dom(html), resultUrlList = []; const html = await gmHttp.get(searchUrl, null, config.headers, !0), $dom = utils.htmlTo$dom(html),
resultUrlList = [];
$dom.find(config.itemSelector).each(((index, element) => { $dom.find(config.itemSelector).each(((index, element) => {
const $box2 = $(element); const $box2 = $(element);
if (!config.findCarNumOrTitle($box2).toLowerCase().includes(carNum2.toLowerCase())) return; if (!config.findCarNumOrTitle($box2).toLowerCase().includes(carNum2.toLowerCase())) return;
@@ -202,6 +191,7 @@ class OtherSitePlugin extends BasePlugin {
} }
} }
} }
async getSettingCache() { async getSettingCache() {
const now = Date.now(); const now = Date.now();
if (!this.settingCache || now - this.lastFetchTime > this.CACHE_DURATION) { if (!this.settingCache || now - this.lastFetchTime > this.CACHE_DURATION) {
@@ -210,37 +200,44 @@ class OtherSitePlugin extends BasePlugin {
} }
return this.settingCache; return this.settingCache;
} }
async getMissAvUrl() { async getMissAvUrl() {
return (await this.getSettingCache()).missAvUrl || "https://missav.live"; return (await this.getSettingCache()).missAvUrl || "https://missav.live";
} }
async getjableUrl() { async getjableUrl() {
return (await this.getSettingCache()).jableUrl || "https://jable.tv"; return (await this.getSettingCache()).jableUrl || "https://jable.tv";
} }
async getAvgleUrl() {
return (await this.getSettingCache()).avgleUrl || "https://jav.rs";
}
async getJavTrailersUrl() { async getJavTrailersUrl() {
return (await this.getSettingCache()).javTrailersUrl || "https://javtrailers.com"; return (await this.getSettingCache()).javTrailersUrl || "https://javtrailers.com";
} }
async getAv123Url() { async getAv123Url() {
return (await this.getSettingCache()).av123Url || "https://123av.com"; return (await this.getSettingCache()).av123Url || "https://123av.com";
} }
async getJavDbUrl() { async getJavDbUrl() {
return (await this.getSettingCache()).javDbUrl || "https://javdb.com"; return (await this.getSettingCache()).javDbUrl || "https://javdb.com";
} }
async getJavBusUrl() { async getJavBusUrl() {
return (await this.getSettingCache()).javBusUrl || "https://www.javbus.com"; return (await this.getSettingCache()).javBusUrl || "https://www.javbus.com";
} }
async getSupJavUrl() { async getSupJavUrl() {
return (await this.getSettingCache()).supJavUrl || "https://supjav.com"; return (await this.getSettingCache()).supJavUrl || "https://supjav.com";
} }
getEnabledSites() { getEnabledSites() {
const enabledSites = localStorage.getItem("jhs_enabled_sites"); const enabledSites = localStorage.getItem("jhs_enabled_sites");
return enabledSites ? JSON.parse(enabledSites) : this.siteConfigs.map((c => c.id)); return enabledSites ? JSON.parse(enabledSites) : this.siteConfigs.map((c => c.id));
} }
saveEnabledSites(sites) { saveEnabledSites(sites) {
localStorage.setItem("jhs_enabled_sites", JSON.stringify(sites)); localStorage.setItem("jhs_enabled_sites", JSON.stringify(sites));
} }
renderSettingsArea() { renderSettingsArea() {
const enabledSites = this.getEnabledSites(), checkboxesDiv = document.getElementById("siteCheckboxes"); const enabledSites = this.getEnabledSites(), checkboxesDiv = document.getElementById("siteCheckboxes");
checkboxesDiv && (checkboxesDiv.innerHTML = this.siteConfigs.map((config => { checkboxesDiv && (checkboxesDiv.innerHTML = this.siteConfigs.map((config => {
@@ -248,6 +245,7 @@ class OtherSitePlugin extends BasePlugin {
return `\n <div style="margin-right: 15px; display: flex; align-items: ${isJavDb ? "center" : "flex-start"};">\n <input type="checkbox" id="checkbox-${config.id}" data-site-id="${config.id}" ${isEnabled ? "checked" : ""} style="margin-right: 8px; cursor: pointer;">\n <label for="checkbox-${config.id}" style="color: #333; font-weight: 500; cursor: pointer;">${config.id.replace("Btn", "")}</label>\n </div>\n `; return `\n <div style="margin-right: 15px; display: flex; align-items: ${isJavDb ? "center" : "flex-start"};">\n <input type="checkbox" id="checkbox-${config.id}" data-site-id="${config.id}" ${isEnabled ? "checked" : ""} style="margin-right: 8px; cursor: pointer;">\n <label for="checkbox-${config.id}" style="color: #333; font-weight: 500; cursor: pointer;">${config.id.replace("Btn", "")}</label>\n </div>\n `;
})).join("")); })).join(""));
} }
setupEventListeners() { setupEventListeners() {
const settingsArea = document.getElementById("settingsArea"); const settingsArea = document.getElementById("settingsArea");
document.addEventListener("click", (event => { document.addEventListener("click", (event => {
@@ -261,7 +259,8 @@ class OtherSitePlugin extends BasePlugin {
const siteId = event.target.getAttribute("data-site-id"); const siteId = event.target.getAttribute("data-site-id");
if (event.target.checked) { if (event.target.checked) {
$(`#${siteId}`).show(); $(`#${siteId}`).show();
const carNum2 = this.getPageInfo().carNum, config = this.siteConfigs.find((item => item.id === siteId)); const carNum2 = this.getPageInfo().carNum,
config = this.siteConfigs.find((item => item.id === siteId));
this.handleSite(carNum2, config).then(); this.handleSite(carNum2, config).then();
} else $(`#${siteId}`).hide(); } else $(`#${siteId}`).hide();
const enabledSites = Array.from(settingsArea.querySelectorAll('input[type="checkbox"]:checked')).map((checkbox => checkbox.getAttribute("data-site-id"))); const enabledSites = Array.from(settingsArea.querySelectorAll('input[type="checkbox"]:checked')).map((checkbox => checkbox.getAttribute("data-site-id")));
@@ -272,4 +271,4 @@ class OtherSitePlugin extends BasePlugin {
} }
export { OtherSitePlugin }; export {OtherSitePlugin};
File diff suppressed because one or more lines are too long