blob: 1562f8f1445e5c167bcfe7e289ac7e44b418c6a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
"use strict";
document.addEventListener("DOMContentLoaded", () => {
const background = chrome.extension.getBackgroundPage().require('./background');
var tab = document.location.search.match(/tab=([^&]*)/)[1];
var content = document.getElementById("content");
var nrw_text_div = document.createElement("div");
nrw_text_div.innerText = "Unrewritten HTTP resources loaded from this tab (enable HTTPS on these domains and add them to HTTPS Everywhere):"
var nrw_div = switchPlannerDetailsHtmlSection(
background.sortSwitchPlanner(tab, "nrw"),
background.switchPlannerInfo[tab]["nrw"]
);
var rw_text_div = document.createElement("div");
rw_text_div.style.marginTop = "20px";
rw_text_div.innerText = "Resources rewritten successfully from this tab (update these in your source code):"
var rw_div = switchPlannerDetailsHtmlSection(
background.sortSwitchPlanner(tab, "rw"),
background.switchPlannerInfo[tab]["rw"]
);
content.appendChild(nrw_text_div);
content.appendChild(nrw_div);
content.appendChild(rw_text_div);
content.appendChild(rw_div);
});
/**
* Generate the detailed html fot the switch planner, by section
* */
function switchPlannerDetailsHtmlSection(asset_host_list, link_keys) {
var wrapper_div = document.createElement("div");
if (asset_host_list.length == 0) {
wrapper_div.style.fontWeight = "bold";
wrapper_div.innerText = "none";
return wrapper_div;
}
for (var i = asset_host_list.length - 1; i >= 0; i--) {
var host = asset_host_list[i][3];
var activeCount = asset_host_list[i][1];
var passiveCount = asset_host_list[i][2];
var div = document.createElement("div");
div.style.marginTop = "20px";
var b = document.createElement("b");
b.innerText = host;
div.appendChild(b);
if (activeCount > 0) {
var active_div = document.createElement("div");
active_div.appendChild(document.createTextNode(activeCount + " active"));
for (const link of linksFromKeys(link_keys[host][1])) {
active_div.appendChild(link);
}
div.appendChild(active_div);
}
if (passiveCount > 0) {
var passive_div = document.createElement("div");
passive_div.appendChild(document.createTextNode(passiveCount + " passive"));
for (const link of linksFromKeys(link_keys[host][0])) {
passive_div.appendChild(link);
}
div.appendChild(passive_div);
}
wrapper_div.appendChild(div);
}
return wrapper_div;
}
/**
* Generate a HTML link from urls in map
* map: the map containing the urls
* */
function linksFromKeys(map) {
if (typeof map == 'undefined') return "";
var links = [];
for (var key in map) {
if (map.hasOwnProperty(key)) {
var link = document.createElement("a");
link.style.display = "block";
link.href = key;
link.innerText = key;
links.push(link);
}
}
return links;
}
|