Add Paul's Toolbox Contents

This commit is contained in:
2024-03-01 18:33:29 +08:00
parent 65b2b86b78
commit 3ef694a468
28 changed files with 1534 additions and 366 deletions
+26
View File
@@ -0,0 +1,26 @@
import type { PlasmoMessaging } from "@plasmohq/messaging";
const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
const { token, siteUrl } = await chrome.storage.local.get(["token", "siteUrl"]);
if (req.body.action === "submitAddForm") {
const { values } = req.body;
const formData = new FormData();
Object.keys(values).forEach((item) => {
formData.append(item, String(values[item]));
});
const addReq = await fetch(`${siteUrl}/api/read/add`, {
method: "POST",
body: formData,
headers: {
"paul-token-code": token,
},
}).then((res) => res.json());
res.send(addReq);
}
}
export default handler;
-13
View File
@@ -1,13 +0,0 @@
import type { PlasmoMessaging } from "@plasmohq/messaging"
const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
const message = await fetch('https://paul.ren/api/note').then((res) => res.json());
console.log(message);
res.send({
message
})
}
export default handler