support fc2

This commit is contained in:
mrbunker
2023-01-01 19:45:21 +08:00
parent 205d9e8983
commit d8f0257d6b
2 changed files with 44 additions and 43 deletions

View File

@@ -1,30 +1,28 @@
import { render } from "preact";
import { Current, matchList } from "@/utils/matchList";
import { getCode } from "@/utils/getCode";
import "@/style.css";
import App from "./components/App";
// !debugger 图片关
// document.querySelectorAll("img").forEach((item) => (item.style.display = "none"));
function main() {
/** 当前 macth 站点对象 */
const current = matchList.find((item) => item.href.test(window.location.href)) as Current;
const CODE = getCode(current);
if (CODE === undefined) return;
current.method();
const panel = document.querySelector<HTMLElement>(current.querys.panelQueryStr);
if (panel === null) return;
const app = document.createElement("div");
app.classList.add("jop-app");
panel.append(app);
render(<App current={current} CODE={CODE} />, app);
}
main();
import { render } from "preact";
import { Current, matchList } from "@/utils/matchList";
import { getCode } from "@/utils/getCode";
import "@/style.css";
import App from "./components/App";
// !debugger 图片关
// document.querySelectorAll("img").forEach((item) => (item.style.display = "none"));
function main() {
/** 当前 macth 站点对象 */
const current = matchList.find((item) => item.href.test(window.location.href)) as Current;
const CODE = getCode(current);
current.method();
const panel = document.querySelector<HTMLElement>(current.querys.panelQueryStr);
if (panel === null) return;
const app = document.createElement("div");
app.classList.add("jop-app");
panel.append(app);
render(<App current={current} CODE={CODE} />, app);
}
main();

View File

@@ -1,13 +1,16 @@
import { Current } from "./matchList";
export function getCode(cms: Current): string | undefined {
const { codeQueryStr } = cms.querys;
const codeNode = document.querySelector<HTMLElement>(codeQueryStr);
const codeText =
cms.name === "javdb"
? (codeNode?.dataset.clipboardText as string)
: codeNode?.innerText.replace("复制", "");
return codeText;
}
import { Current } from "./matchList";
export function getCode(cms: Current): string {
const { codeQueryStr } = cms.querys;
const codeNode = document.querySelector<HTMLElement>(codeQueryStr);
if (!codeNode) return "";
const codeText =
cms.name === "javdb"
? (codeNode.dataset.clipboardText as string)
: codeNode.innerText.replace("复制", "");
if (codeText?.includes("FC2")) return codeText.split("-")[1];
return codeText;
}