-
Notifications
You must be signed in to change notification settings - Fork 3
/
content.js
118 lines (118 loc) · 3.55 KB
/
content.js
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//'use strict';
//
//// This code was showing which channel how many HTTP responses came from.
//// We now do this in the page_action popup script. I'm keeping this here
//// for a while as a backup. But feel free to remove it completely whenever
//// content script is needed for other purposes.
//
//function createClearElement(tag) {
// var r = document.createElement(tag);
// // TODO: Remove all css properties set by the website
// return r;
//}
//
//class OneStat {
// constructor(parent, label) {
// this.currentValue = 0;
//
// var container = createClearElement('div');
// parent.appendChild(container);
//
// var label_e = createClearElement('span');
// label_e.textContent = label + ":";
// container.appendChild(label_e);
//
// this.value_e = createClearElement('span');
// this.value_e.textContent = this.currentValue;
// container.appendChild(this.value_e);
// }
//
// set(value) {
// this.currentValue = value;
// this.value_e.textContent = value;
// }
//
// add(value) {
// this.currentValue += value;
// this.value_e.textContent = this.currentValue;
// }
//}
//
//class Statistics {
// constructor(tabId) {
// this.tabId = tabId;
//
// var div = createClearElement('div');
//
// div.style.position = "fixed";
// div.style.top = "0";
// div.style.right = "0";
// div.style.width = "180px";
// div.style.margin = "10px";
// div.style.padding = "10px";
// div.style.backgroundColor = "#f49a3e";
// div.style.border = "4px solid #3ca3db";
// div.style.zIndex = 10000;
//
//
// var header = createClearElement('div');
// header.style.fontWeight = "bold";
// header.textContent = "CENO Retrieval";
// div.appendChild(header);
//
// this.origin_stat = new OneStat(div, "Origin");
// this.proxy_stat = new OneStat(div, "Proxy");
// this.injector_stat = new OneStat(div, "Injector");
// this.distrib_cache_stat = new OneStat(div, "Distributed Cache");
// this.local_cache_stat = new OneStat(div, "Local Cache");
//
// this.tab_id = createClearElement('div');
// div.appendChild(this.tab_id);
// document.body.appendChild(div);
// }
//
// getStat(which) {
// if (which === "origin") return this.origin_stat;
// if (which === "proxy") return this.proxy_stat;
// if (which === "injector") return this.injector_stat;
// if (which === "dist-cache") return this.distrib_cache_stat;
// if (which === "local-cache") return this.local_cache_stat;
// return null;
// }
//}
//
//function handleMessageFromBackgroundJs(message, sender) {
// var src = message["ouinet-source"];
//
// if (!src) {
// console.log("No ouinet-source in message from background.js");
// return;
// }
//
// if (!document.ceno_statistics) {
// document.ceno_statistics = new Statistics(message.tabId);
// }
//
// document.ceno_statistics.tab_id.textContent = "zzz:" + message.tabId + ":zzz";
// var s = document.ceno_statistics.getStat(src);
//
// s.add(1);
//}
//
//browser.runtime.onMessage.addListener(handleMessageFromBackgroundJs);
//
//// XXX: Why is this in a function that is called right a way?
//(function(){
// function updatePageAction() {
// console.log("Page ready");
// setTimeout(() => browser.runtime.sendMessage({}), 0);
// }
//
// if (document.readyState === 'interactive' || document.readyState === 'complete') {
// console.log("page already loaded ", document.ceno_statistics);
// updatePageAction();
// } else {
// console.log("added listener");
// window.addEventListener('DOMContentLoaded', updatePageAction);
// }
//})();