Skip to content

Commit

Permalink
Update content.js
Browse files Browse the repository at this point in the history
  • Loading branch information
blackstormx committed Jul 29, 2020
1 parent 363697d commit e01a557
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ function checkNode(startNode) {
} else {
if (startNode.nodeType == Node.ELEMENT_NODE) {
if (startNode.tagName == "INPUT" || startNode.tagName == "TEXTAREA") {
if (deepCheck(startNode.value)) {
startNode.value = bannedWord;
const res = deepCheck(startNode.value);
if (res) {
startNode.value = res;
}
} else {
if (startNode.childNodes.length == 0) {
if (deepCheck(startNode.innerText)) {
startNode.innerText = bannedWord;
const res = deepCheck(startNode.value);
if (res) {
startNode.innerText = res;
}
}
}
Expand All @@ -92,12 +94,13 @@ function deepCheck(text) {
text = text.toLowerCase();

if (slogans[text]) {
return true;
return bannedWord;
}
for (var i = 0; i < slogansKeys.length; i++) {
const key = slogansKeys[i];
if (text.includes(key)) {
return true;
let edited = text.replace(key, bannedWord);
return edited;
}
}
return false;
Expand Down

0 comments on commit e01a557

Please sign in to comment.