-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
38 lines (35 loc) · 1.11 KB
/
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
28
29
30
31
32
33
34
35
36
37
38
const FILE_NAME = "payload/names.txt";
const MAX_RESULTS = 0; // it will retrieve as much as it can
// Pulls NSFW keywords -> names
const names = $.get(FILE_NAME, {}, function (content) {
names = content.split("\n");
names = names.map((name) => name.toLowerCase()).slice(0, -1);
});
// Listens to frontend(script.js) and behaves accordingly
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.message === "clearHistory") {
try {
chrome.history.search(
{ text: "", maxResults: MAX_RESULTS },
function (data) {
data.forEach(function (page) {
// clearing history part
for (ele of names) {
if (
page.url.toLowerCase().includes(ele) ||
page.title.toLowerCase().includes(ele)
) {
chrome.history.deleteUrl({ url: page.url });
break;
}
}
});
}
);
sendResponse({ message: "success" });
} catch (err) {
sendResponse({ message: "failed", error: err });
}
}
return true;
});