feat: extension on start event (#239)

This commit is contained in:
Levi authored and GitHub committed 2023-10-19 18:08:27 +08:00
1 parent 755d7ce814
commit 858ad74339
23 files changed
+292 -101

No files matched your search

+13 -13
View File
@@ -2,36 +2,36 @@ gopeed.events.onResolve(async function (ctx) {
const key = "key"
const value1 = "value1", value2 = JSON.stringify({a: 1, b: "2"})
if (ctx.storage.get(key) !== null) {
if (gopeed.storage.get(key) !== null) {
throw new Error("storage get null error")
}
ctx.storage.remove(key)
if(ctx.storage.keys().length !== 0) {
gopeed.storage.remove(key)
if(gopeed.storage.keys().length !== 0) {
throw new Error("storage keys null error")
}
ctx.storage.set(key, value1)
if (ctx.storage.get(key) !== value1) {
gopeed.storage.set(key, value1)
if (gopeed.storage.get(key) !== value1) {
throw new Error("storage put1 error")
}
ctx.storage.set(key, value2)
if (ctx.storage.get(key) !== value2) {
gopeed.storage.set(key, value2)
if (gopeed.storage.get(key) !== value2) {
throw new Error("storage put2 error")
}
if(ctx.storage.keys().length !== 1) {
if(gopeed.storage.keys().length !== 1) {
throw new Error("storage keys error")
}
ctx.storage.remove(key)
if (ctx.storage.get(key) !== null) {
gopeed.storage.remove(key)
if (gopeed.storage.get(key) !== null) {
throw new Error("storage delete error")
}
ctx.storage.set(key, value1)
ctx.storage.clear()
if (ctx.storage.get(key) !== null) {
gopeed.storage.set(key, value1)
gopeed.storage.clear()
if (gopeed.storage.get(key) !== null) {
throw new Error("storage clear error")
}
+5 -3
View File
@@ -5,9 +5,11 @@
"scripts": [
{
"event": "onResolve",
"matches": [
"*://github.com/*"
],
"match": {
"urls": [
"*://*/*"
]
},
"entry": "index.js"
}
],