diff --git a/manifest.json b/manifest.json index 8eb2cab..49abd75 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "version": "1.0", "manifest_version": 2, "description": "Are you a Veep fan? Do you actually believe what Jonah Ryan says? Well, now you can manifest that on your compooter!", - "homepage_url": "", + "homepage_url": "https://github.com/ChessPiece21/Ryanator", "icons": { "16": "icons/icon16.png", "48": "icons/icon48.png", diff --git a/src/inject/inject.js b/src/inject/inject.js new file mode 100644 index 0000000..1141520 --- /dev/null +++ b/src/inject/inject.js @@ -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"); + } + +}); \ No newline at end of file