import { __publicField } from './constants.js';
class BasePlugin {
constructor() {
__publicField(this, "pluginManager", null);
__publicField(this, "settingSvg", '');
__publicField(this, "editSvg", '');
__publicField(this, "deleteSvg", '');
__publicField(this, "checkSvg", '');
__publicField(this, "actressSvg", '');
__publicField(this, "newSvg", '');
__publicField(this, "refreshSvg", '');
__publicField(this, "blacklistSvg", '');
__publicField(this, "removeSvg", '');
__publicField(this, "copySvg", '');
__publicField(this, "titleSvg", '');
__publicField(this, "carNumSvg", '');
__publicField(this, "downSvg", '');
__publicField(this, "handleSvg", '');
__publicField(this, "siteSvg", '');
__publicField(this, "videoSvg", '');
__publicField(this, "screenSvg", '');
__publicField(this, "recoveryVideoSvg", '');
__publicField(this, "markDeleteSvg", '');
}
getName() {
throw new Error(`${this.constructor.name} 未显示getName()`);
}
getBean(name2) {
return this.pluginManager.getBean(name2);
}
async initCss() {
return "";
}
async handle() {}
getPageInfo() {
let carNum2, url, actress, actors, publishTime, currentHref2 = window.location.href;
if (isJavDb) {
carNum2 = $('a[title="複製番號"]').attr("data-clipboard-text");
url = currentHref2.split("?")[0].split("#")[0];
actress = $(".female").prev().map(((i, el) => $(el).text())).get().join(" ");
actors = $(".male").prev().map(((i, el) => $(el).text())).get().join(" ");
publishTime = $('strong:contains("日期:")').parent(".panel-block").find(".value").text().trim();
}
if (isJavBus) {
url = currentHref2.split("?")[0];
carNum2 = url.split("/").filter(Boolean).pop().replace(/_\d{4}-\d{2}-\d{2}$/, "");
actress = $('span[onmouseover*="star_"] a').map(((i, el) => $(el).text())).get().join(" ");
actors = "";
publishTime = $('span.header:contains("發行日期:")').parent("p").text().trim().replace("發行日期:", "").trim();
}
return {
carNum: carNum2,
url: url,
actress: actress,
actors: actors,
publishTime: publishTime
};
}
getActressId() {
const match = currentHref.match(/\/actors\/([^/?]+)/);
return match && match.length > 1 ? match[1] : null;
}
getActressPageInfo() {
let currentHref2 = window.location.href;
if (!currentHref2.includes("/actors/") && !currentHref2.includes("/star/")) throw new Error("接口调用错误, 非演员详情页");
let nameList = [], $actor = isJavDb ? $(".actor-section-name") : $(".avatar-box .photo-info .pb10");
$actor.length && $actor.text().trim().split(",").forEach((name2 => {
nameList.push(name2.trim());
}));
let $sectionMeta = $(".section-meta:not(:contains('影片'))");
$sectionMeta.length && $sectionMeta.text().trim().split(",").forEach((name2 => {
nameList.push(name2.trim());
}));
let role = $(".section-meta:contains('男優')").length > 0 ? "actor" : "actress", movieType = "censored";
nameList.some((n => n.includes("無碼"))) && (movieType = "uncensored");
currentHref2.includes("uncensored") && (movieType = "uncensored");
let blacklistUrl = null, starId = null;
const urlObj = new URL(currentHref2);
if (isJavDb) {
starId = urlObj.pathname.split("/").filter((segment => "" !== segment.trim())).pop();
const params = urlObj.searchParams;
params.delete("sort_type");
params.delete("page");
blacklistUrl = urlObj.toString();
} else if (isJavBus) {
const splitStr = "/star/", parts = currentHref2.split(splitStr);
if (parts.length < 2) throw new Error("提取演员url失败");
const host = parts[0];
starId = parts[1].split("/")[0];
blacklistUrl = host + splitStr + starId;
}
return {
starId: starId,
name: nameList[0],
allName: nameList,
role: role,
movieType: movieType,
blacklistUrl: blacklistUrl
};
}
getSelector(type) {
const key = type || (isJavDb ? "javdb" : isJavBus ? "javbus" : null), selectors = {
javdb: {
boxSelector: ".movie-list",
itemSelector: ".movie-list .item",
coverImgSelector: ".cover img",
requestDomItemSelector: ".movie-list .item",
nextPageSelector: ".pagination-next"
},
javbus: {
boxSelector: ".masonry",
itemSelector: ".masonry .item",
coverImgSelector: ".masonry .movie-box .photo-frame img",
requestDomItemSelector: "#waterfall .item",
nextPageSelector: "#next"
}
};
if (!key || !selectors[key]) throw new Error("类型错误: 无法确定选择器类型 (JavDb 或 JavBus)");
return selectors[key];
}
parseMovieId(href) {
return href.split("/").pop().split(/[?#]/)[0];
}
getBoxCarInfo($box2) {
var _a2, _b, _c;
const $aLink = $box2.find("a"), url = $aLink.attr("href");
let carNum2 = null, title = null, publishTime = null;
const $videoTitleEle = $box2.find(".video-title");
if ($videoTitleEle.length > 0) {
const $strongEle = $videoTitleEle.find("strong");
$strongEle.length > 0 && (carNum2 = $strongEle.text().trim());
title = null == (_a2 = $aLink.attr("title")) ? void 0 : _a2.trim();
if (!title) {
const fullTitleText = $videoTitleEle.text().trim();
title = carNum2 && fullTitleText.includes(carNum2) ? fullTitleText.replace(carNum2, "").trim() : fullTitleText;
}
publishTime = $box2.find(".meta").text().trim();
}
if (!carNum2) {
const $imgEle = $box2.find("img");
$imgEle.length > 0 && (title = (null == (_b = $imgEle.attr("title")) ? void 0 : _b.trim()) || (null == (_c = $imgEle.attr("data-title")) ? void 0 : _c.trim()));
const dateElements = $box2.find("date").map(((i, el) => $(el).text().trim())).get(), isDate = s => /^\d{4}-\d{1,2}-\d{1,2}$/.test(s);
publishTime = dateElements.find(isDate) || null;
carNum2 = dateElements.find((i => !isDate(i))) || null;
}
if (!carNum2) {
const msg = "提取番号信息失败: carNum 为空";
console.error("Error in getBoxCarInfo:", msg, "Box Element:", $box2.get(0));
show.error(msg);
throw new Error(msg);
}
return {
carNum: carNum2,
url: url || "",
aHref: url || "",
title: title || "",
publishTime: publishTime || ""
};
}
getBoxCarInfoList($boxList = null) {
$boxList || ($boxList = $(this.getSelector().itemSelector));
if (0 === $boxList.length) {
clog.error("获取当前列表页所有item的番号信息失败!");
return [];
}
const results = [];
$boxList.each(((index, element) => {
const $box2 = $(element);
try {
const carInfo = this.getBoxCarInfo($box2);
results.push(carInfo);
} catch (error) {
clog.error("[getBoxCarInfoList] 提取单个 boxCar 信息失败:", error.message, "元素索引:", index);
}
}));
return results;
}
checkDuplicateCarNumbers(currentList, newList) {
if (!isJavDb) return !1;
if (!currentList || 0 === currentList.length || !newList || 0 === newList.length) return !1;
const currentCarNums = new Set(currentList.map((item => item.carNum)).filter((n => n)));
if (0 === currentCarNums.size) return !1;
let consecutiveDuplicates = 0;
for (let i = 0; i < newList.length; i++) {
const newCarNum = newList[i] ? newList[i].carNum : null;
if (newCarNum && currentCarNums.has(newCarNum)) {
consecutiveDuplicates++;
if (consecutiveDuplicates >= 2) {
clog.warn("警告: 检测到连续番号信息重复, 该类别可能已被限制页码。");
return !0;
}
} else consecutiveDuplicates = 0;
}
return !1;
}
}
export { BasePlugin };