Project

General

Profile

« Previous | Next » 

Revision c483ae19

Added by koszko about 2 years ago

add ability to query page content from repo and display it in the popup

View differences:

background/page_actions_server.js
14 14
 * IMPORT listen_for_connection
15 15
 * IMPORT sha256
16 16
 * IMPORT get_query_best
17
 * IMPORT make_ajax_request
17 18
 * IMPORTS_END
18 19
 */
19 20

  
......
23 24

  
24 25
function send_actions(url, port)
25 26
{
26
    let [pattern, settings] = query_best(url);
27
    const [pattern, settings] = query_best(url);
28
    const repos = storage.get_all(TYPE_PREFIX.REPO);
27 29

  
28
    port.postMessage(["settings", [pattern, settings]]);
30
    port.postMessage(["settings", [pattern, settings, repos]]);
29 31

  
30 32
    if (settings === undefined)
31 33
	return;
......
85 87
    }
86 88
}
87 89

  
88
function ajax_callback()
89
{
90
    if (this.readyState == 4)
91
	this.resolve_callback(this);
92
}
93

  
94
function initiate_ajax_request(resolve, method, url)
95
{
96
    var xhttp = new XMLHttpRequest();
97
    xhttp.resolve_callback = resolve;
98
    xhttp.onreadystatechange = ajax_callback;
99
    xhttp.open(method, url, true);
100
    xhttp.send();
101
}
102

  
103
function make_ajax_request(method, url)
104
{
105
    return new Promise((resolve, reject) =>
106
		       initiate_ajax_request(resolve, method, url));
107
}
108

  
109 90
async function fetch_remote_script(script_data)
110 91
{
111 92
    try {

Also available in: Unified diff