From c483ae19e110ef5c1e539883a38fbc79b3dd4e4e Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Wed, 21 Jul 2021 22:00:20 +0200 Subject: add ability to query page content from repo and display it in the popup --- background/page_actions_server.js | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) (limited to 'background') 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 { -- cgit v1.2.3