Skip to content

Commit

Permalink
update content.js
Browse files Browse the repository at this point in the history
  • Loading branch information
RootUp authored Oct 13, 2024
1 parent d65e4e1 commit 5ec1c19
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions SmuggleShield/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ class HTMLSmugglingBlocker {
}

setupObserver() {
const observer = new MutationObserver(() => {
this.analyzeContent();
const observer = new MutationObserver((mutations) => {
if (mutations.some(mutation => mutation.addedNodes.length > 0)) {
this.analyzeContent();
}
});

observer.observe(document.documentElement, {
Expand All @@ -91,7 +93,7 @@ class HTMLSmugglingBlocker {
if (pattern.test(htmlContent)) {
score += weight;
detectedPatterns.push(pattern.toString());
if (score >= this.threshold) break; // Early exit if threshold is reached
if (score >= this.threshold) break;
}
}

Expand Down

0 comments on commit 5ec1c19

Please sign in to comment.