I am learning to write javascript and Chrome extensions. I want an extension that will show a button, and when a user clicks the button it will add a bookmark folder in the bookmarks.
So far so good (the button appears), but clicking it adds nothing.
I suppose my JavaScript is not correct.
Here is the code:
Manifest:
{
"name": "My First Extension",
"version": "1.0",
"background_page": "background.html",
"permissions": [
"tabs", "http://*/*", "bookmarks"
],
"browser_action": {
"default_icon": "icon.png",
"name": "HELLO WORLD"
}
}
background.html:
<html>
<head>
<script>
function updateIcon() {
chrome.bookmarks.create({parentId: bookmarkBar.id,
title: 'Extension bookmarks'});
}
chrome.browserAction.onClicked.addListener(updateIcon);
updateIcon();
);
</script>
</head>
</html>
I suppose it is this part:
function updateIcon() { chrome.bookmarks.create({parentId: bookmarkBar.id,
title: 'Extension bookmarks'});
}
That code is wrong.
Please, advise me and any good places for learning JavaScript. I have read this web page already.
You have an obvious syntax error.