From aed95236be8cfa6a5bae90bedd18afaf42c63713 Mon Sep 17 00:00:00 2001 From: suziwen Date: Thu, 15 Aug 2024 09:19:53 +0800 Subject: [PATCH] firefox private mode check --- .../overlay/x-background.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/omega-target-chromium-extension/overlay/x-background.js b/omega-target-chromium-extension/overlay/x-background.js index 0ee60c9..2fa0002 100644 --- a/omega-target-chromium-extension/overlay/x-background.js +++ b/omega-target-chromium-extension/overlay/x-background.js @@ -21,11 +21,17 @@ import "./js/background.js" // zeroBackground **/ const isFirefox = !!globalThis.localStorage +const zcb = globalThis.zeroDetectModeCB function detectPrivateMode(cb) { - var db, tempMode, - on = cb.bind(null, true), - off = cb.bind(null, false) + var db, tempMode,on, off; + if (zcb) { + on = zcb(cb, true); + off = zcb(cb, false); + } else { + on = ()=> {setTimeout(cb.bind(null, true), 1)}; + off = ()=> {setTimeout(cb.bind(null, false), 1)}; + } if (isFirefox) { // in private mode, localStorage will be erased when browser restart tempMode = localStorage.getItem('zeroOmega.isPrivateMode')