I'm new to chrome extensions development. I'm trying to build a very basic extension just to see how things work.
The extension I want to build needs to add a button along with all "h1" elements in a web page.
this is my js file:
function myFunction(element) {
alert(element.innerText);
};
var elements = document.querySelectorAll("h1");
for (var i = 0; i < elements.length; i++)
{
var element = elements[i];
// element.innerHTML += "<form><button type='button' value='Copy' onclick='myfunction(element)'></form>";
element.innerHTML += "<button onclick='myFunction()'>Click me</button>";
};
When I click the button nothing happens, it seems that "myFunction" is not recognized.
This is my manifest:
{
"manifest_version": 2,
"name": "MagiCopy",
"description": "This extension shows a Google Image search result for the current page",
"version": "1.0",
"browser_action":
{
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"chrome_url_overrides":
{
"newtab" : "newtab.html"
},
"background":
{
"scripts": ["background.js"]
},
"permissions":
[
"activeTab",
"https://ajax.googleapis.com/"
],
"content_scripts":
[
{
"matches": ["http://*/*", "https://*/*"],
"js": ["myscript.js"],
"run_at" : "document_end"
}
]
}
What am I doing wrong?