This is my first attempt at making an extension, and I basically just followed and rewrote the code from my JS book.
Manifest.json
{
"name": "My first extension",
"version": "1.0",
"description": "Hello World extension",
"manifest_version": 2,
"browser_action": {
"default_icon": "icon.png",
"popup": "popup.html"
}
}
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Extension Test</title>
<style>
body {
width:350px;
}
div {
border: 1px solid;
padding:20px;
font: 20px normal helvetica, verdana, sans-serif;
}
</style>
<script>
function sayhello() {
var message = document.createTextNode("Hello World");
var out = document.createElement("div");
out.appendChild(message);
document.body.appendChild(out)
}
window.onload = sayhello;
</script>
</head>
<body>
</body>
</html>
I've enabled the extension, and the icon appears, but when I click it, nothing happens. The inspect popup button is also grayed out, and cannot be clicked.
What am I doing wrong?
Note: I'm also not really sure what the code is supposed to do. Again, I'm just doing what the book says.
I tried to insert an alert()
inside the function, but nothing changed. The extension still doesn't work.