aboutsummaryrefslogtreecommitdiff
path: root/background
diff options
context:
space:
mode:
authorjahoti <jahoti@tilde.team>2021-07-21 00:00:00 +0000
committerjahoti <jahoti@tilde.team>2021-07-21 00:00:00 +0000
commitefce4e9807889e9269534b19c8e0cbb4df527ecd (patch)
tree0a951d1b2b5c1470f7baf2be41585f5f08a09a9a /background
parentefd6ae83e6e48008988a2a11ac1658ec71dc82d2 (diff)
parentc483ae19e110ef5c1e539883a38fbc79b3dd4e4e (diff)
downloadbrowser-extension-efce4e9807889e9269534b19c8e0cbb4df527ecd.tar.gz
browser-extension-efce4e9807889e9269534b19c8e0cbb4df527ecd.zip
Merge remote-tracking branch 'origin/koszko' into jahoti
Diffstat (limited to 'background')
-rw-r--r--background/page_actions_server.js27
-rw-r--r--background/storage.js4
-rw-r--r--background/storage_server.js12
3 files changed, 10 insertions, 33 deletions
diff --git a/background/page_actions_server.js b/background/page_actions_server.js
index c6800a0..a7a44c1 100644
--- a/background/page_actions_server.js
+++ b/background/page_actions_server.js
@@ -14,6 +14,7 @@
* IMPORT listen_for_connection
* IMPORT sha256
* IMPORT get_query_best
+ * IMPORT make_ajax_request
* IMPORTS_END
*/
@@ -23,9 +24,10 @@ var handler;
function send_actions(url, port)
{
- let [pattern, settings] = query_best(url);
+ const [pattern, settings] = query_best(url);
+ const repos = storage.get_all(TYPE_PREFIX.REPO);
- port.postMessage(["settings", [pattern, settings]]);
+ port.postMessage(["settings", [pattern, settings, repos]]);
if (settings === undefined)
return;
@@ -85,27 +87,6 @@ async function get_script_text(script_name)
}
}
-function ajax_callback()
-{
- if (this.readyState == 4)
- this.resolve_callback(this);
-}
-
-function initiate_ajax_request(resolve, method, url)
-{
- var xhttp = new XMLHttpRequest();
- xhttp.resolve_callback = resolve;
- xhttp.onreadystatechange = ajax_callback;
- xhttp.open(method, url, true);
- xhttp.send();
-}
-
-function make_ajax_request(method, url)
-{
- return new Promise((resolve, reject) =>
- initiate_ajax_request(resolve, method, url));
-}
-
async function fetch_remote_script(script_data)
{
try {
diff --git a/background/storage.js b/background/storage.js
index 7229a2d..682f933 100644
--- a/background/storage.js
+++ b/background/storage.js
@@ -101,10 +101,6 @@ async function list(prefix)
return {map, prefix, name, listeners : new Set(), lock : make_lock()};
}
-var pages;
-var bags;
-var scripts;
-
var list_by_prefix = {};
async function init()
diff --git a/background/storage_server.js b/background/storage_server.js
index 554aff2..2252eb5 100644
--- a/background/storage_server.js
+++ b/background/storage_server.js
@@ -9,7 +9,7 @@
* IMPORTS_START
* IMPORT listen_for_connection
* IMPORT get_storage
- * IMPORT TYPE_PREFIX
+ * IMPORT list_prefixes
* IMPORT CONNECTION_TYPE
* IMPORTS_END
*/
@@ -38,11 +38,11 @@ function new_connection(port)
{
console.log("new remote storage connection!");
- port.postMessage({
- [TYPE_PREFIX.SCRIPT] : storage.get_all(TYPE_PREFIX.SCRIPT),
- [TYPE_PREFIX.BAG] : storage.get_all(TYPE_PREFIX.BAG),
- [TYPE_PREFIX.PAGE] : storage.get_all(TYPE_PREFIX.PAGE)
- });
+ const message = {};
+ for (const prefix of list_prefixes)
+ message[prefix] = storage.get_all(prefix);
+
+ port.postMessage(message);
let handle_change = change => port.postMessage(change);