31
rated 0 times
[
33]
[
2]
/ answers: 1 / hits: 20688
/ 6 Years ago, mon, july 23, 2018, 12:00:00
I am trying create a bookmarks (on this case in chrome)
my code is :
function onCreated(node) {
console.log(node);
}
var createBookmark = browser.bookmarks.create({
title: bookmarks.create() on MDN,
url: https://developer.mozilla.org/Add-ons/WebExtensions/API/bookmarks/create
});
createBookmark.then(onCreated);
<!DOCTYPE html>
<html>
<head>
<title>test</title>
</head>
<body>
<p>text example</p>
</body>
</html>
I got this error when I run the code in chrome:
Uncaught ReferenceError: browser is not defined
I run other code this :
function onFulfilled(bookmarkItems) {
if (bookmarkItems.length) {
console.log(active tab is bookmarked);
} else {
console.log(active tab is not bookmarked);
}
}
function onRejected(error) {
console.log(`An error: ${error}`);
}
function checkActiveTab(tab) {
var searching = browser.bookmarks.search({url: tab.url});
searching.then(onFulfilled, onRejected);
}
browser.browserAction.onClicked.addListener(checkActiveTab);
from :here I got the same error.
Update question :
my manifest.json in this moment:
{
name: add site random,
version: 1.0,
description: this is my first extension in production,
manifest_version: 2
}
any idea because I have this error I am trying create a folder and add a site in my bookmarks from the code?
More From » bookmarks