-
Notifications
You must be signed in to change notification settings - Fork 31
/
content.js
119 lines (107 loc) · 3.94 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
119
var browser = (window.browser) ? window.browser : window.chrome;
var url = window.location.hostname + window.location.pathname;
var last = url.slice(-1);
window.addEventListener("load", function () {
setTimeout(function () {
chrome.runtime.sendMessage({ 'speed': window.performance.getEntriesByType("navigation")[0].loadEventEnd});
}, 0);
});
if (last != '/' && url != "secure.eicar.org/eicar.com.txt") {
url = url + '/';
}
const malwareBlocklist = [
'secure.eicar.org/eicar.com.txt/',
'secure.eicar.org/eicar.com/',
'maliciouswebsitetest.com/',
'aiosetup.com/',
'downloadhardware.com/',
'www.amtso.org/check-desktop-phishing-page/',
'amtso.eicar.org/PotentiallyUnwanted.exe/',
'amtso.eicar.org/cloudcar.exe/',
'www.ikarussecurity.com/wp-content/downloads/eicar_com.zip/'
];
const pageHeader = `
h3{
color:red;
}
body{
background-color: lightblue !important;
display:flex;
align-items:center;
justify-content:center;
font-family: 'Segoe UI', Arial, Helvetica, 'Lucida Sans', sans-serif;
}
#info{
display:flex;
align-items:center;
justify-content:center;
flex-direction:column;
background-color:white;
border-radius:20px;
padding:5px;
word-wrap:break-word;
width:450px;
height:280px;
position:absolute;
top: 50%;
left:50%;
transform:translate(-50%,-50%);
box-shadow: 0 2px 8px 2px rgba(0, 0, 0, 0.16);;
}
#myPara{text-align:center;}
#myPara2{font-size:75%;}
#mailAnchor{text-decoration:none;}`;
function run() {
malwareBlocklist.find(element => {
if (element === url) {
document.documentElement.innerHTML = '';
var style = document.createElement('style');
style.appendChild(document.createTextNode(pageHeader));
var title = document.createElement('title');
title.textContent = "RR Adblocker-Malware Protection";
document.getElementsByTagName('head')[0].appendChild(title);
document.getElementsByTagName('head')[0].appendChild(style);
var myDiv = document.createElement("div");
myDiv.setAttribute("id", "info");
var h3 = document.createElement("h3");
h3.textContent = "A dangerous website has been blocked";
var infoPara = document.createElement("p");
infoPara.setAttribute("id", "myPara");
infoPara.textContent = "You were protected from visiting this website by RR Adblocker.";
var p2 = document.createElement("p");
p2.setAttribute("id", "myPara2");
p2.textContent = "If this website has been wrongly blocked. Reach to us at: rutujrunwal001@gmail.com ";
myDiv.appendChild(h3);
myDiv.appendChild(infoPara);
myDiv.appendChild(p2);
document.body.appendChild(myDiv);
}
});
}
var scripts = document.getElementsByTagName("script");
var urlDataSet = new Set();
if (scripts.length != 0) {
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].src) {
if (!scripts[i].src.includes(window.location.hostname) && !scripts[i].src.includes("bootstrap") && !scripts[i].src.includes("jsdelivr") && !scripts[i].src.includes("jquery") && !scripts[i].src.includes("static") && !scripts[i].src.includes("cloudfront") && !scripts[i].src.includes("recaptcha")) {
urlDataSet.add(scripts[i].src.split("//")[1]);
}
}
}
if (urlDataSet.size == 0 && (!url.includes("localhost") && !url.includes("127"))) {
urlDataSet.add("www.google-analytics.com/analytics.js");
}
}
else {
urlDataSet.add("www.google-analytics.com/analytics.js");
}
const urlData = [...urlDataSet];
chrome.runtime.sendMessage({'blockedItems':urlData});
var domain = document.location.hostname;
chrome.storage.sync.get('*', function (disabled) {
if (disabled['*']) return;
chrome.storage.sync.get(domain, function (disabled) {
if (disabled[domain]) { return; }
run();
});
});