-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
131 lines (118 loc) · 4.31 KB
/
popup.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
119
120
121
122
123
124
125
126
127
128
129
130
131
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, { action: "detectAds", tabUrl: tabs[0].url});
});
document.getElementById('not_per').addEventListener('click', function() {
chrome.tabs.query({active: true, currentWindow: true}, (tabs)=>{
console.log("popup not_per");
chrome.tabs.sendMessage(
tabs[0].id,
{
action: "noti_per",
tabURL: tabs[0].url
},(response) => {
if (response) {
console.log(response);
}
}
);
});
});
document.getElementById('ch_redi').addEventListener('click', function(){
chrome.tabs.query({active:true,currentWindow:true},(tabs)=>{
console.log("popup ch_redi");
chrome.tabs.sendMessage(
tabs[0].id,
{
action:"ch_redi",
tabURL:tabs[0].url
},(response)=>{
if(response)
{
console.log(response);
}
}
)
});
});
document.getElementById('ui_decep').addEventListener('click',function(){
chrome.tabs.query({active:true,currentWindow:true},(tabs)=>{
console.log("ra");
chrome.tabs.sendMessage(
tabs[0].id,
{
action:"mlmodel",
tabURL:tabs[0].url
},(response)=>{
if(response)
{
console.log(response);
}
}
)
});
});
document.getElementById('price-trend').addEventListener('click',function(){
chrome.tabs.query({active:true,currentWindow:true},(tabs)=>{
console.log("popup graph");
chrome.tabs.sendMessage(
tabs[0].id,
{
action:"price-trend",
tabURL:tabs[0].url
},(response)=>{
if(response)
{
console.log(response);
}
}
)
});
});
document.getElementById('ssl').addEventListener('click',function(){
chrome.tabs.query({active:true,currentWindow:true},(tabs)=>{
console.log("popup ssl");
chrome.tabs.sendMessage(
tabs[0].id,
{
action:"ssl",
tabURL:tabs[0].url
},(response)=>{
if(response)
{
console.log(response);
}
}
)
});
});
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
if (message.action === "adDetectionResult") {
const adResult = message.adResult;
const freetrialResult = message.freetrialResult;
const wrong = '<svg xmlns="http://www.w3.org/2000/svg" height="25" width="25" viewBox="0 0 512 512"><path fill="#007a56" d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"/></svg>';
const right = '<svg xmlns="http://www.w3.org/2000/svg" height="25" width="22.5" viewBox="0 0 448 512"><path fill="#e52e2e" d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>';
const adStatus = adResult ? ( right ) : ( wrong );
const freetrialStatus = freetrialResult ? (right) : ( wrong) ;
const adsResultElement = document.getElementById("ads-value");
const statusElement = document.getElementById("freetrial-value");
adsResultElement.innerHTML = '';
statusElement.innerHTML = '';
const adsTempContainer = document.createElement("div");
const freetrialTempContainer = document.createElement("div");
adsTempContainer.innerHTML = adStatus;
freetrialTempContainer.innerHTML = freetrialStatus;
while (adsTempContainer.firstChild) {
adsResultElement.appendChild(adsTempContainer.firstChild);
}
while (freetrialTempContainer.firstChild) {
statusElement.appendChild(freetrialTempContainer.firstChild);
}
}
// if(message.action === "permissionresponse"){
// const receiveddata=(message.datafromserver);
// for(const key in receiveddata.permission){
// console.log(key, receiveddata.permission[key]);
// }
// document.getElementById("p").innerHTML = "<div>camera="+message.datafromserver.permission.Camera_permission+"<div>";
// }
});