I'm starting to work with extensions in Google Chrome and after some time reading tutorials I have so far been unable to access anything in the DOM of the page. I need to modify the CSS of the page or execute some script inside it. Could anyone give me some example?
I'm looking for something like this:
index.html
<html>
<head>
<title>teste de extensão</title>
</head>
<body>
<button id="btn1" onclick="fundoAzul()">fundo azul</button>
<br>
<button id="btn1" onclick="fundoVermelho()">fundo vermelho</button>
<script>
function fundoAzul(){
document.querySelector('body').style.background = 'blue';
};
function fundoVermelho(){
document.querySelector('body').style.background = 'red';
};
</script>
</body>
</html>
In the tutorials I saw, one of them showed me how to do a alert
(I can not remember which one now) but my alert
was executed within the extension and not on the current page.