Add Paul's Toolbox Contents
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import type { PlasmoCSConfig } from "plasmo";
|
||||
|
||||
export const config: PlasmoCSConfig = {
|
||||
matches: ["https://mall.bilibili.com/*"]
|
||||
};
|
||||
|
||||
chrome.runtime.onMessage.addListener((req, sender, send) => {
|
||||
if (req.type === "toolbox:getBiliToy") {
|
||||
const item = document.querySelectorAll<HTMLDivElement>(".silde-item");
|
||||
|
||||
if (item.length) {
|
||||
const project = document.querySelector<HTMLDivElement>(".tagC-ip .tagC-ip-con").innerText;
|
||||
const made = document.querySelector<HTMLDivElement>(".tagC-ip .tagC-ip-con-brand").innerText;
|
||||
|
||||
const projectExp = new RegExp(`\s?${project}\s?`);
|
||||
const madeExp = new RegExp(`\s?${made}\s?`);
|
||||
const name = document.querySelector<HTMLDivElement>(".title-text-wrap")
|
||||
.innerText.replace(/\[\S+\]/, "")
|
||||
.replace(projectExp, "")
|
||||
.replace(madeExp, "")
|
||||
.replaceAll(/\s?Q版手办\s?|\s?粘土人\s?/g, "")
|
||||
.trim();
|
||||
|
||||
const images = [];
|
||||
|
||||
item.forEach((item) => {
|
||||
images.push(
|
||||
item.style.backgroundImage.replace("url(\"", "").replace("\")", "").replace("//", "https://")
|
||||
);
|
||||
});
|
||||
|
||||
send({
|
||||
name,
|
||||
project,
|
||||
made: document.querySelector<HTMLDivElement>(".tagC-ip .tagC-ip-con-brand").innerText,
|
||||
sale: document.querySelector<HTMLDivElement>(".item-complex:nth-child(4) .item-complex-value").innerText.replace("-", "/"),
|
||||
images,
|
||||
});
|
||||
}
|
||||
else {
|
||||
send(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user