I want the below code to execute when I push the button I have added to my chrome browser through my extension:
<script>
var formData = new FormData();
var html = document.innerHTML;
formData.append("time", "12:00:00");
formData.append("html",document.getElementsByTagName('html')[0].innerHTML);
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://www.mywebsite.com/index");
xhr.send(formData);
</script>
my issues is I have no idea where does this go? background html? manifest? I cant understand how it works even after reading the document about the architecture can anyone help me?.
This code should go into background page. In order for it to work you need to add
https://www.mywebsite.comto domain permissions first. It is all explained here with examples.To catch browser action button click:
This will work only if you don’t have a popup defined.