forked from vishnuvrj7/CryptoPatrol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
27 lines (26 loc) · 878 Bytes
/
background.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
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
const blockedDomains = ["cryptojacking-domain1.com", "cryptominer.io"];
const url = new URL(details.url);
if (blockedDomains.includes(url.hostname)) {
console.log(`Blocked cryptojacking attempt from ${url.hostname}`);
return { cancel: true };
}
},
{ urls: ["<all_urls>"] },
["blocking"]
);
// Monitor CPU usage
let isMining = false;
setInterval(() => {
chrome.system.cpu.getInfo(cpuInfo => {
const totalUsage = cpuInfo.processors.reduce((total, proc) => total + proc.usage.kernel + proc.usage.user, 0);
const averageUsage = totalUsage / cpuInfo.numOfProcessors;
if (averageUsage > 80) { // Threshold for suspicious usage
isMining = true;
console.warn("Potential cryptojacking detected!");
} else {
isMining = false;
}
});
}, 5000);