0

i'm trying to write an Opera extension. I need to add a page to favourites when user click submit button. For example there is a web page:

<html>
....
  <input id="button-submit" type="submit" value="Submit" onclick="doSomething();">
...
</html>

and i want to make an extension that provides additional action (create bookmark) when user click submit. I wrote something, but it doesn't work:

var button = document.getElementById('button-submit');
button.addEventListener("click", function() {
chrome.bookmarks.create({'parentId': 1,
                         'title': 'My extension'});
});

Please help :)

pma
  • 1
  • 1
  • Maybe this will help http://stackoverflow.com/questions/18872679/function-as-google-chrome-bookmark – Ilya Zinkevych Apr 21 '17 at 18:42
  • 3
    chrome.bookmarks API [isn't available](https://developer.chrome.com/extensions/content_scripts) in a content script. Send a message to your background/event page script which has access to this API (provided it's added in your manifest.json "permissions"). – wOxxOm Apr 21 '17 at 18:57
  • thanks @wOxxOm, i'll try this :) – pma Apr 21 '17 at 19:17

0 Answers0