From ce8e808f19a1f5452385b8b93cfc77ec99c57635 Mon Sep 17 00:00:00 2001 From: Hojjat Kamyabi Date: Wed, 27 May 2026 16:29:10 +0200 Subject: [PATCH] keeping the bot alive to avoid service worker being disabled --- src/background/Extension.js | 3 +++ src/content/ContentHandler.js | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/background/Extension.js b/src/background/Extension.js index 620dfe72..ca05127d 100644 --- a/src/background/Extension.js +++ b/src/background/Extension.js @@ -653,6 +653,9 @@ export default class Extension { console.log('getting settings') sendResponse(this.get_settings()) + } else if (msg.hasOwnProperty('keep_alive')){ + sendResponse({alive: true}) + } else if (msg.hasOwnProperty('download_page')){ const pageData = { url: 'data:text/html;charset=utf-8,' + encodeURIComponent(msg.content), diff --git a/src/content/ContentHandler.js b/src/content/ContentHandler.js index 0bac9f39..9bc3e67d 100644 --- a/src/content/ContentHandler.js +++ b/src/content/ContentHandler.js @@ -28,6 +28,7 @@ export default class ContentHandler { this.debug = true; //false; this.onBackendMessage = this.onBackendMessage.bind(this); this.settings = {} + this.keepAliveTimer = null; } @@ -319,6 +320,10 @@ export default class ContentHandler { if (this.debug) console.log('onStart this.sendMessage'); }); + // keep alive connection to avoid browser disabling the serviceworker + setInterval(() => { + this.browser.runtime.sendMessage({ keep_alive: true }).catch(() => {}); + }, 25000); // connect to the backend this.browser.runtime.connect({