Ok, so I'm making a Chrome extension and I would like to have it so that the extension has 2 buttons, one to turn the extension on, and one to turn it off. While the extension is running, I would like it to replace all instances on the webpage of "ab" to "ef" (just an example). This means that after the user clicks on, the extension will ALWAYS convert "ab" to "ef" on every webpage without having to turn it on each time. I am doing this by means of Javascript. Here is my code (HTML and Javascript), please see what you can do!
JSFiddle: https://jsfiddle.net/syf5f687/
HTML:
<!doctype html>
<html>
<head>
<title>AB to EF</title>
<script src="popup.js"></script>
</head>
<body>
<h1>AB to EF Converter</h1>
<button id="turnOn">Turn On</button>
<button id="turnOff">Turn Off</button>
</body>
</html>
JS (which I think is completely wrong, I haven't even put in the turn off button):
var markup = document.documentElement.innerHTML;
document.addEventListener('DOMContentLoaded', function() {
var checkPageButton = document.getElementById('turnOn');
checkPageButton.addEventListener('clickOn', function() {
chrome.tabs.getSelected(null, function(tab) {
markup.replace(/ab/, "ef")
});
}, false);
}, false);