summaryrefslogtreecommitdiff
path: root/data/extensions/jsr@javascriptrestrictor/level_cache.js
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2023-09-27 00:53:30 -0400
committerMark H Weaver <mhw@netris.org>2023-09-27 14:34:35 -0400
commitfa5c0b073214191e6996ba0b5bc8e61560ff822c (patch)
tree38e7133195616f4a4da6c8fe46ab2c77c5a6e9e2 /data/extensions/jsr@javascriptrestrictor/level_cache.js
parentd167f676a167b1392a4e29f14ddf25613468680b (diff)
Update the JShelter extension to 0.15.2.
Diffstat (limited to 'data/extensions/jsr@javascriptrestrictor/level_cache.js')
-rw-r--r--data/extensions/jsr@javascriptrestrictor/level_cache.js24
1 files changed, 7 insertions, 17 deletions
diff --git a/data/extensions/jsr@javascriptrestrictor/level_cache.js b/data/extensions/jsr@javascriptrestrictor/level_cache.js
index b0bef17..a094827 100644
--- a/data/extensions/jsr@javascriptrestrictor/level_cache.js
+++ b/data/extensions/jsr@javascriptrestrictor/level_cache.js
@@ -4,6 +4,7 @@
* \author Copyright (C) 2020 Libor Polcak
* \author Copyright (C) 2021 Giorgio Maone
* \author Copyright (C) 2022 Marek Salon
+ * \author Copyright (C) 2023 Martin Zmitko
*
* \license SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -27,13 +28,11 @@
* @param {url} string
* @param isPrivate bool specifying incognito mode
*/
-
-
function getContentConfiguration(url, frameId, tabId) {
return new Promise(resolve => {
function resolve_promise() {
let level = getCurrentLevelJSON(url);
- if (level[0].is_default && frameId !== 0) {
+ if (level.is_default && frameId !== 0) {
/**
* \bug iframes nested within an iframe with user-specific level do not get this level
*
@@ -59,26 +58,16 @@ function getContentConfiguration(url, frameId, tabId) {
* gets the user-defined settings for domain B but the iframe from domain C
* is set with the level of domain A.
*/
- level = getCurrentLevelJSON(TabCache.get(tabId).url);
+ level = getCurrentLevelJSON(TabCache.get(tabId).url);
}
- let [{wrappers}, code] = level;
let {domainHash} = Hashes.getFor(url);
- if (isFpdOn(tabId)) {
- if (!code) {
- code = fp_generate_wrapping_code(fpdSettings.detection);
- }
- else {
- code = fp_update_wrapping_code(code, wrappers, fpdSettings.detection);
- }
- }
resolve({
- currentLevel: level[0],
- code,
- wrappers,
+ currentLevel: level,
+ fpdWrappers: isFpdOn(tabId) ? fp_levels.page_wrappers[fpdSettings.detection] : [],
domainHash
});
}
- if (levels_initialised === true) {
+ if (levels_initialised && fp_levels_initialised) {
resolve_promise();
}
else {
@@ -129,6 +118,7 @@ DocStartInjection.register(async ({url, frameId, tabId}) => {
*/
NavCache.onUrlChanged.addListener(({tabId, frameId, previousUrl, url}) => {
if (getSiteForURL(previousUrl) === getSiteForURL(url)) return;
+ if (previousUrl === undefined) return; // First page in this window, see https://pagure.io/JShelter/webextension/issue/116#comment-875070
(async () => {
let configuration = await getContentConfiguration(url, frameId, tabId);
if (configuration.currentLevel.windowname) {