I am trying to make a chrome extension that can edit and remove parts of Javascript of a webpage preferably before the page is loaded.
For Example, the following script tag is within my test html website.
<script>
document.addEventListener("visibilitychange", onchange);
function onchange(){
console.log('left');
}
</script>
This code tells the console when the user switches tabs. I would like to be able to edit this specific code only to prevent this from happening. Can I modify the text of JavaScript before runtime?