diff options
author | Clément Lassieur <clement@lassieur.org> | 2023-11-09 14:15:44 +0100 |
---|---|---|
committer | Mark H Weaver <mhw@netris.org> | 2023-12-30 09:24:46 -0500 |
commit | ba0d2ab758143b9fe2ca14f6eed07d9a6a350c2b (patch) | |
tree | 0ecd8a30389110b49a8a1c1513332dbacfcb46f9 /data/extensions/https-everywhere@eff.org/background-scripts/incognito.js | |
parent | f889514426e512e5602c71e1b411ae0332a33366 (diff) |
Migrate from HTTPS-Everywhere to Icecat's own HTTPS-Only Mode.
See <https://www.eff.org/https-everywhere>.
Modified-By: Mark H Weaver <mhw@netris.org>.
Diffstat (limited to 'data/extensions/https-everywhere@eff.org/background-scripts/incognito.js')
-rw-r--r-- | data/extensions/https-everywhere@eff.org/background-scripts/incognito.js | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/data/extensions/https-everywhere@eff.org/background-scripts/incognito.js b/data/extensions/https-everywhere@eff.org/background-scripts/incognito.js deleted file mode 100644 index 7d4bc81..0000000 --- a/data/extensions/https-everywhere@eff.org/background-scripts/incognito.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; - -(function(exports) { - -// This file keeps track of incognito sessions, and clears any caches after -// an entire incognito session is closed (i.e. all incognito windows are closed). - -let state = { - incognito_session_exists: false, -}; - -function Incognito(onIncognitoDestruction) { - Object.assign(this, {onIncognitoDestruction}); - // Listen to window creation, so we can detect if an incognito window is created - if (chrome.windows) { - chrome.windows.onCreated.addListener(this.detect_incognito_creation); - } - - // Listen to window destruction, so we can clear caches if all incognito windows are destroyed - if (chrome.windows) { - chrome.windows.onRemoved.addListener(this.detect_incognito_destruction); - } -} - -Incognito.prototype = { - /** - * Detect if an incognito session is created, so we can clear caches when it's destroyed. - * - * @param window: A standard Window object. - */ - detect_incognito_creation: function(window_) { - if (window_.incognito === true) { - state.incognito_session_exists = true; - } - }, - - // If a window is destroyed, and an incognito session existed, see if it still does. - detect_incognito_destruction: async function() { - if (state.incognito_session_exists) { - if (!(await any_incognito_windows())) { - state.incognito_session_exists = false; - this.onIncognitoDestruction(); - } - } - }, -}; - -/** - * Check if any incognito window still exists - */ -function any_incognito_windows() { - return new Promise(resolve => { - chrome.windows.getAll(arrayOfWindows => { - for (let window_ of arrayOfWindows) { - if (window_.incognito === true) { - return resolve(true); - } - } - resolve(false); - }); - }); -} - -function onIncognitoDestruction(callback) { - return new Incognito(callback); -}; - -Object.assign(exports, { - onIncognitoDestruction, - state, -}); - -})(typeof exports == 'undefined' ? require.scopes.incognito = {} : exports); |