Revision b7e2870f
Added by koszko about 2 years ago
| background/page_actions_server.js | ||
|---|---|---|
| 21 | 21 |
var query_best; |
| 22 | 22 |
var handler; |
| 23 | 23 |
|
| 24 |
function send_scripts(url, port)
|
|
| 24 |
function send_actions(url, port)
|
|
| 25 | 25 |
{
|
| 26 | 26 |
let [pattern, settings] = query_best(url); |
| 27 |
|
|
| 28 |
port.postMessage(["settings", [pattern, settings]]); |
|
| 29 |
|
|
| 27 | 30 |
if (settings === undefined) |
| 28 | 31 |
return; |
| 29 | 32 |
|
| ... | ... | |
| 31 | 34 |
let processed_bags = new Set(); |
| 32 | 35 |
|
| 33 | 36 |
if (components !== undefined) |
| 34 |
send_scripts_rec([components], port, processed_bags);
|
|
| 37 |
send_scripts([components], port, processed_bags); |
|
| 35 | 38 |
} |
| 36 | 39 |
|
| 37 | 40 |
// TODO: parallelize script fetching |
| 38 |
async function send_scripts_rec(components, port, processed_bags)
|
|
| 41 |
async function send_scripts(components, port, processed_bags) |
|
| 39 | 42 |
{
|
| 40 | 43 |
for (let [prefix, name] of components) {
|
| 41 | 44 |
if (prefix === TYPE_PREFIX.BAG) {
|
| ... | ... | |
| 52 | 55 |
} |
| 53 | 56 |
|
| 54 | 57 |
processed_bags.add(name); |
| 55 |
await send_scripts_rec(bag, port, processed_bags); |
|
| 58 |
await send_scripts(bag, port, processed_bags); |
|
| 59 |
|
|
| 56 | 60 |
processed_bags.delete(name); |
| 57 | 61 |
} else {
|
| 58 | 62 |
let script_text = await get_script_text(name); |
| 59 | 63 |
if (script_text === undefined) |
| 60 | 64 |
continue; |
| 61 | 65 |
|
| 62 |
port.postMessage({inject : [script_text]});
|
|
| 66 |
port.postMessage(["inject", [script_text]]);
|
|
| 63 | 67 |
} |
| 64 | 68 |
} |
| 65 | 69 |
} |
| ... | ... | |
| 127 | 131 |
port.onMessage.removeListener(handler[0]); |
| 128 | 132 |
let url = message.url; |
| 129 | 133 |
console.log({url});
|
| 130 |
send_scripts(url, port);
|
|
| 134 |
send_actions(url, port);
|
|
| 131 | 135 |
} |
| 132 | 136 |
|
| 133 | 137 |
function new_connection(port) |
Also available in: Unified diff
show some settings of the current page in the popup