user2332319
user2332319

Reputation: 3

Chrome Extension: Event Page For New Bookmark Events

I'm completely new to Chrome Extensions. I want the creation of a bookmark to trigger a xmlhttprequest. Right now, I'm just trying to get a new bookmark event to do a console.log and can't see what I'm missing.

Here is my manifest.json:

{
  "manifest_version": 2,

  "name": "Booky Desktop Integration",
  "description": "Sends New Chrome Bookmarks To Your Booky Desktop.",
  "version": "1.0",

  "background": {
    "scripts": ["background.js"],
    "persistent": false
  },

   "permissions": [
        "bookmarks",
        "http://bookydesktop.com/"
    ]
}

Here is my js:

chrome.bookmarks.onCreated.addListener(function(id, bookmark) {
   console.log("bookmark created");     
});

What am I missing?

Upvotes: 0

Views: 467

Answers (1)

apsillers
apsillers

Reputation: 115910

Your code works perfectly as written. You're probably not viewing the console for your background page. You need to:

  1. Open chrome://extensions/ (or click "Extensions" in Chrome's "Settings" menu)

  2. Ensure "Developer mode" is ticked in the top right

  3. Open the console by clicking "_generated_background_page.html (Inactive)" in the "Inspect views" list under your extension

Each page in Chrome has its own console instance. You were looking at the consoles of ordinary web pages, instead of looking at the console for your background page.

Upvotes: 1

Related Questions