feat: wire market plugin controls

This commit is contained in:
2026-04-20 20:17:48 +08:00
parent f6b2bdc862
commit 9b3c6756bb
4 changed files with 608 additions and 1 deletions
+34 -1
View File
@@ -1 +1,34 @@
export {};
import {
createMarketController,
type CreateMarketControllerOptions
} from "./market/index";
interface BootContentScriptOptions {
createMarketController?: (
options: CreateMarketControllerOptions
) => { ready: Promise<void> };
document?: Document;
window?: Window;
}
export async function bootContentScript(
options: BootContentScriptOptions = {}
): Promise<{ ready: Promise<void> } | null> {
const currentWindow = options.window ?? window;
const currentDocument = options.document ?? document;
const controllerFactory =
options.createMarketController ?? createMarketController;
if (!isMarketPage(currentWindow.location.href)) {
return null;
}
return controllerFactory({
document: currentDocument,
window: currentWindow
});
}
function isMarketPage(url: string): boolean {
return url.startsWith("https://xingtu.cn/ad/creator/market");
}