This repository has been archived by the owner on Mar 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
67 lines (59 loc) · 1.85 KB
/
main.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
/*jshint esversion: 8 */
// NDev 2020 https://github.com/NDevTK/CacheAttack
document.addEventListener('DOMContentLoaded', async _ => {
setTimeout(async _ => {
clearTable();
await getWebsites(displayName => addData(displayName));
loaded();
}, 150);
});
async function addData(displayName) {
dataTable.hidden = false;
data.insertRow(0).insertCell(0).innerText = displayName[1];
}
function loaded() {
if (dataTable.hidden === true) {
info.innerText = "No result found :(";
} else {
info.hidden = true;
}
}
function clearTable() {
var rowCount = dataTable.rows.length; while(--rowCount) dataTable.deleteRow(rowCount);
dataTable.hidden = true;
info.innerText = "Loading...";
info.hidden = false;
}
async function windowMode() {
if(!navigator.userAgent.includes("Firefox") && !confirm("Warning: for chrome window mode will brake CacheAttack after the first run.")) return;
clearTable();
initChecker();
ifCached = ifCached_window;
setTimeout(async _ => {
let results = await getWebsites(addData, null, false);
loaded();
}, 1000);
}
async function domainRule(domain) {
var rules = await getRules();
for (let rule of rules) {
if(new URL(rule).host === domain) {
return rule;
}
}
return "https://" + domain + "/favicon.ico";
}
async function blocker() {
var domain = prompt("What domain to block?", "www.google.com");
if (domain === null) return;
domain = domain.toLocaleLowerCase();
initChecker();
var url = await domainRule(domain);
blockerFrame(url);
if (navigator.userAgent.includes("Firefox")) return alert("Feature not supported on Firefox :(");
ifCached = ifCached_window;
setTimeout(_=> {
block(url);
ifrm.src = "https://ndev.tk/icon.webp";
}, 1000);
}