-
Notifications
You must be signed in to change notification settings - Fork 0
/
zen.js
21 lines (18 loc) · 840 Bytes
/
zen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function contains(string, matchStrings) {
return Boolean(matchStrings.find(matchString => string.includes(matchString)))
}
function increaseZen() {
chrome.runtime.sendMessage({ request: "filters" }, function(response) {
const { filteredKeywords } = response
const activeFilteredKeywords = Object.keys(filteredKeywords).filter(keyword => filteredKeywords[keyword])
const elements = Array.from(document.getElementsByTagName('*'))
.filter(element => Array.from(element.children).length === 0)
.filter(element => {
const content = element.textContent.toLowerCase()
return contains(content, activeFilteredKeywords)
})
elements.forEach(element => element.style.display = "none")
});
}
increaseZen()
setInterval(increaseZen, 500)