From f6a7f24e61a78f197250875ac9833f497a455d20 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Wed, 12 May 2021 17:41:08 +0200 Subject: rename "bundles" to "bags" --- TODOS.org | 2 +- background/main.js | 4 ++-- background/page_actions_server.js | 24 ++++++++++++------------ background/reverse_use_info.js | 6 +++--- background/storage.js | 6 +++--- background/storage_server.js | 2 +- common/storage_client.js | 4 ++-- common/stored_types.js | 6 +++--- html/options.html | 32 ++++++++++++++++---------------- html/options_main.js | 16 ++++++++-------- 10 files changed, 51 insertions(+), 51 deletions(-) diff --git a/TODOS.org b/TODOS.org index 48e3717..0abef25 100644 --- a/TODOS.org +++ b/TODOS.org @@ -20,7 +20,6 @@ TODO: - find some way not to require each chrome user to modify manifest.json - rename the extension to something good - port to gecko-based browsers -- CRUCIAL -- rename "bundles" to "bags" to avoid confusion with Web Bundles - make it possible to modify CSP to suit our custom scripts' needs - find a way to additionally block all other scripts using CSP as an additional safety measure @@ -40,6 +39,7 @@ TODO: to manage imports/exports DONE: +- rename "bundles" to "bags" to avoid confusion with Web Bundles -- DONE 2021-05-12 - use non-predictable value in place of "myext-allow", utilizing hashes -- DONE 2021-05-12 - stop using modules (not available on all browsers) -- DONE 2021-05-12 - clean up the remnants of LibreJS -- DONE 2021-05-12 diff --git a/background/main.js b/background/main.js index f4b01f8..6b636c4 100644 --- a/background/main.js +++ b/background/main.js @@ -116,10 +116,10 @@ text: "console.log(\"hello, every1!\");\n" }; await storage.set(TYPE_PREFIX.SCRIPT, "hello", hello_script); - await storage.set(TYPE_PREFIX.BUNDLE, "hello", + await storage.set(TYPE_PREFIX.BAG, "hello", [[TYPE_PREFIX.SCRIPT, "hello"]]); await storage.set(TYPE_PREFIX.PAGE, "https://my.fsf.org/", { - components: [[TYPE_PREFIX.BUNDLE, "hello"]], + components: [[TYPE_PREFIX.BAG, "hello"]], allow: true }); diff --git a/background/page_actions_server.js b/background/page_actions_server.js index fbb672e..2a0b858 100644 --- a/background/page_actions_server.js +++ b/background/page_actions_server.js @@ -29,31 +29,31 @@ return; let components = settings.components; - let processed_bundles = new Set(); + let processed_bags = new Set(); - send_scripts_rec(components, port, processed_bundles); + send_scripts_rec(components, port, processed_bags); } // TODO: parallelize script fetching - async function send_scripts_rec(components, port, processed_bundles) + async function send_scripts_rec(components, port, processed_bags) { for (let [prefix, name] of components) { - if (prefix === TYPE_PREFIX.BUNDLE) { - if (processed_bundles.has(name)) { - console.log(`preventing recursive inclusion of bundle ${name}`); + if (prefix === TYPE_PREFIX.BAG) { + if (processed_bags.has(name)) { + console.log(`preventing recursive inclusion of bag ${name}`); continue; } - var bundle = storage.get(TYPE_PREFIX.BUNDLE, name); + var bag = storage.get(TYPE_PREFIX.BAG, name); - if (bundle === undefined) { - console.log(`no bundle in storage for key ${name}`); + if (bag === undefined) { + console.log(`no bag in storage for key ${name}`); continue; } - processed_bundles.add(name); - await send_scripts_rec(bundle, port, processed_bundles); - processed_bundles.delete(name); + processed_bags.add(name); + await send_scripts_rec(bag, port, processed_bags); + processed_bags.delete(name); } else { let script_text = await get_script_text(name); if (script_text === undefined) diff --git a/background/reverse_use_info.js b/background/reverse_use_info.js index 3399285..688cd64 100644 --- a/background/reverse_use_info.js +++ b/background/reverse_use_info.js @@ -1,5 +1,5 @@ /** -* Myext scripts and bundles usage index +* Myext scripts and bags usage index * * Copyright (C) 2021 Wojtek Kosior * @@ -11,7 +11,7 @@ "use strict"; /* - * We want to count referenes to scripts and bundles in order to know, + * We want to count referenes to scripts and bags in order to know, * for example, whether one can be safely deleted. */ @@ -83,7 +83,7 @@ { storage = await get_storage(); - prefixes = [TYPE_PREFIX.PAGE, TYPE_PREFIX.BUNDLE]; + prefixes = [TYPE_PREFIX.PAGE, TYPE_PREFIX.BAG]; for (let prefix of prefixes) build_reverse_uses_info(prefix); diff --git a/background/storage.js b/background/storage.js index ea390ef..5578109 100644 --- a/background/storage.js +++ b/background/storage.js @@ -104,7 +104,7 @@ } var pages; - var bundles; + var bags; var scripts; var list_by_prefix = {}; @@ -310,8 +310,8 @@ */ /* - * For bundles, item name is chosen by user, data is an array of 2-element - * arrays with type prefix and script/bundle names. + * For bags, item name is chosen by user, data is an array of 2-element + * arrays with type prefix and script/bag names. */ /* diff --git a/background/storage_server.js b/background/storage_server.js index 05f616b..a4b292c 100644 --- a/background/storage_server.js +++ b/background/storage_server.js @@ -41,7 +41,7 @@ port.postMessage({ [TYPE_PREFIX.SCRIPT] : storage.get_all(TYPE_PREFIX.SCRIPT), - [TYPE_PREFIX.BUNDLE] : storage.get_all(TYPE_PREFIX.BUNDLE), + [TYPE_PREFIX.BAG] : storage.get_all(TYPE_PREFIX.BAG), [TYPE_PREFIX.PAGE] : storage.get_all(TYPE_PREFIX.PAGE) }); diff --git a/common/storage_client.js b/common/storage_client.js index 39ece44..f1ae272 100644 --- a/common/storage_client.js +++ b/common/storage_client.js @@ -55,12 +55,12 @@ } var scripts = list("scripts", TYPE_PREFIX.SCRIPT); - var bundles = list("bundles", TYPE_PREFIX.BUNDLE); + var bags = list("bags", TYPE_PREFIX.BAG); var pages = list("pages", TYPE_PREFIX.PAGE); const list_by_prefix = { [TYPE_PREFIX.SCRIPT] : scripts, - [TYPE_PREFIX.BUNDLE] : bundles, + [TYPE_PREFIX.BAG] : bags, [TYPE_PREFIX.PAGE] : pages }; diff --git a/common/stored_types.js b/common/stored_types.js index de0ec71..31254a9 100644 --- a/common/stored_types.js +++ b/common/stored_types.js @@ -21,20 +21,20 @@ (() => { const TYPE_PREFIX = { PAGE : "p", - BUNDLE : "b", + BAG : "b", SCRIPT : "s", VAR : "_" }; const TYPE_NAME = { [TYPE_PREFIX.PAGE] : "page", - [TYPE_PREFIX.BUNDLE] : "bundle", + [TYPE_PREFIX.BAG] : "bag", [TYPE_PREFIX.SCRIPT] : "script" } const list_prefixes = [ TYPE_PREFIX.PAGE, - TYPE_PREFIX.BUNDLE, + TYPE_PREFIX.BAG, TYPE_PREFIX.SCRIPT ]; diff --git a/html/options.html b/html/options.html index 0bce6fc..cb39090 100644 --- a/html/options.html +++ b/html/options.html @@ -30,13 +30,13 @@ /* tabbed view */ #show_pages:not(:checked) ~ #pages, - #show_bundles:not(:checked) ~ #bundles, + #show_bags:not(:checked) ~ #bags, #show_scripts:not(:checked) ~ #scripts { display: none; } #show_pages:checked ~ #pages_lbl, - #show_bundles:checked ~ #bundles_lbl, + #show_bags:checked ~ #bags_lbl, #show_scripts:checked ~ #scripts_lbl { border-left: 2px solid green; border-right: 2px solid green; @@ -89,12 +89,12 @@ - + - + @@ -119,23 +119,23 @@ -
-