Skip to content

Commit

Permalink
fix: download event not fired in firefox #59 (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
pureiboi committed Jul 10, 2023
1 parent 468bbfd commit 5fd10d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,14 @@ browser.runtime.onInstalled.addListener(function () {

// create the offscreen document if it doesn't already exist
async function createOffscreen() {
if (await chrome.offscreen.hasDocument?.()) return;
await chrome.offscreen.createDocument({
if (await browser.offscreen === undefined || await browser.offscreen.hasDocument?.()) return;
await browser.offscreen.createDocument({
url: 'pages/offscreen.html',
reasons: ['BLOBS'],
justification: 'keep service worker running',
});
}
// a message from an offscreen document every 20 second resets the inactivity timer
chrome.runtime.onMessage.addListener((msg) => {
browser.runtime.onMessage.addListener((msg) => {
if (msg.keepAlive) console.log('keepAlive');
});
4 changes: 3 additions & 1 deletion app/scripts/offscreen.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as browser from 'webextension-polyfill';

// send a message every 20 sec to service worker
setInterval(() => {
chrome.runtime.sendMessage({ keepAlive: true });
browser.runtime.sendMessage({ keepAlive: true });
}, 20000);

0 comments on commit 5fd10d4

Please sign in to comment.