Last active
September 30, 2022 07:09
-
-
Save fregante/60fb96400de9efedc4d36af47dd4b794 to your computer and use it in GitHub Desktop.
MV3 lifetime test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Respond to CS | |
const startTime = Date.now() | |
const delay = 13000; | |
chrome.runtime.onMessage.addListener( (message, sender, respond) => { | |
setTimeout(respond, delay, Math.round((Date.now() - startTime + delay) / 1000)); | |
return true | |
}) | |
// Overlapping fetch requests | |
console.log('will req'); | |
let id = new Date().getMinutes() + ':' | |
let i = 0; | |
chrome.storage.local.get().then(console.log) | |
setInterval(async () => { | |
const thisId = id + i; | |
i++; | |
console.log(thisId, 'req') | |
chrome.storage.local.set({[thisId]: 'req'}) | |
await fetch('https://deelay.me/19000/https://pixiebrix.com') | |
console.log(thisId, 'req done') | |
chrome.storage.local.set({[thisId]: 'req done'}) | |
}, 13000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Starting'); | |
setInterval(() => { | |
console.log('sending') | |
chrome.runtime.sendMessage('lifetime in seconds', console.log) | |
}, 7000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"manifest_version": 3, | |
"name": "MV3 test", | |
"version": "0.0.0", | |
"permissions": ["storage"], | |
"background": { | |
"service_worker": "background.worker.js" | |
}, | |
"content_scripts": [ | |
{ | |
"matches": ["*://*/*"], | |
"js": ["content.js"] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment