-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ecd0c20
commit 33c515b
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
chrome.extension.sendMessage({}, function(response) { | ||
var readyStateCheckInterval = setInterval(function() { | ||
if (document.readyState === "complete") { | ||
clearInterval(readyStateCheckInterval); | ||
|
||
main(); | ||
} | ||
}, 10); | ||
|
||
function main() { | ||
// Replace page title | ||
document.title = generateReplacment(document.title); | ||
|
||
// Get all text nodes to check | ||
var textNodes = $('body *').contents().filter(function() { | ||
return this.nodeType == Node.TEXT_NODE; | ||
}); | ||
|
||
// Replace all text nodes | ||
textNodes.each(function(index, textNode) { | ||
textNode.nodeValue = generateReplacment(textNode.nodeValue); | ||
}); | ||
} | ||
|
||
function generateReplacment(text) { | ||
var regex1 = /algebra/gi; | ||
return text.replace(regex1, getName()).replace("algebra", "Al-Jazeera"); | ||
} | ||
|
||
}); |