added changes requested
This commit is contained in:
parent
87a2aa5f1e
commit
bd579fe907
2 changed files with 11 additions and 21 deletions
|
@ -244,28 +244,19 @@ const assignManager = {
|
||||||
this.getPermissions();
|
this.getPermissions();
|
||||||
},
|
},
|
||||||
|
|
||||||
getPermissions() {
|
async getPermissions() {
|
||||||
browser.permissions.getAll().
|
const {permissions} = await browser.permissions.getAll()
|
||||||
then((permissions) => {
|
permissions.includes("bookmarks") ? this.makeBookmarksMenu() : browser.contextMenus.remove(this.OPEN_IN_CONTAINER);
|
||||||
if (permissions.permissions.includes("bookmarks")) {
|
|
||||||
this.makeBookmarksMenu();
|
|
||||||
} else {
|
|
||||||
browser.contextMenus.remove(this.OPEN_IN_CONTAINER);
|
|
||||||
}
|
|
||||||
}).
|
|
||||||
catch((err) => {
|
|
||||||
return err.message;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
makeBookmarksMenu() {
|
makeBookmarksMenu() {
|
||||||
this.initBookmarksMenu();
|
this.initBookmarksMenu();
|
||||||
browser.contextualIdentities.onCreated.addListener(this.contextualIdentCreated);
|
browser.contextualIdentities.onCreated.addListener(this.contextualIdentityCreated);
|
||||||
browser.contextualIdentities.onUpdated.addListener(this.contextualIdentUpdated);
|
browser.contextualIdentities.onUpdated.addListener(this.contextualIdentityUpdated);
|
||||||
browser.contextualIdentities.onRemoved.addListener(this.contextualIdentRemoved);
|
browser.contextualIdentities.onRemoved.addListener(this.contextualIdentityRemoved);
|
||||||
},
|
},
|
||||||
|
|
||||||
contextualIdentCreated(changeInfo) {
|
contextualIdentityCreated(changeInfo) {
|
||||||
browser.contextMenus.create({
|
browser.contextMenus.create({
|
||||||
parentId: assignManager.OPEN_IN_CONTAINER,
|
parentId: assignManager.OPEN_IN_CONTAINER,
|
||||||
id: changeInfo.contextualIdentity.cookieStoreId,
|
id: changeInfo.contextualIdentity.cookieStoreId,
|
||||||
|
@ -274,14 +265,14 @@ const assignManager = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
contextualIdentUpdated(changeInfo) {
|
contextualIdentityUpdated(changeInfo) {
|
||||||
browser.contextMenus.update(changeInfo.contextualIdentity.cookieStoreId, {
|
browser.contextMenus.update(changeInfo.contextualIdentity.cookieStoreId, {
|
||||||
title: changeInfo.contextualIdentity.name,
|
title: changeInfo.contextualIdentity.name,
|
||||||
icons: { "16": `img/usercontext.svg#${changeInfo.contextualIdentity.icon}` }
|
icons: { "16": `img/usercontext.svg#${changeInfo.contextualIdentity.icon}` }
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
contextualIdentRemoved(changeInfo) {
|
contextualIdentityRemoved(changeInfo) {
|
||||||
browser.contextMenus.remove(changeInfo.contextualIdentity.cookieStoreId);
|
browser.contextMenus.remove(changeInfo.contextualIdentity.cookieStoreId);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -322,9 +313,8 @@ const assignManager = {
|
||||||
const [bookmarkTreeNode] = await browser.bookmarks.get(info.bookmarkId);
|
const [bookmarkTreeNode] = await browser.bookmarks.get(info.bookmarkId);
|
||||||
if (bookmarkTreeNode.type === "folder") {
|
if (bookmarkTreeNode.type === "folder") {
|
||||||
return await browser.bookmarks.getChildren(bookmarkTreeNode.id);
|
return await browser.bookmarks.getChildren(bookmarkTreeNode.id);
|
||||||
} else {
|
|
||||||
return [bookmarkTreeNode];
|
|
||||||
}
|
}
|
||||||
|
return [bookmarkTreeNode];
|
||||||
}
|
}
|
||||||
|
|
||||||
const bookmarks = await _getBookmarksFromInfo(info);
|
const bookmarks = await _getBookmarksFromInfo(info);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<body>
|
<body>
|
||||||
<form>
|
<form>
|
||||||
<input type="checkbox" id="bookmarksPermissions"/>
|
<input type="checkbox" id="bookmarksPermissions"/>
|
||||||
<label>Enable Bookmark Permissions</label>
|
<label>Enable Bookmark Menus</label>
|
||||||
<p>This setting allows you to open a bookmark or folder of bookmarks in a container.</p>
|
<p>This setting allows you to open a bookmark or folder of bookmarks in a container.</p>
|
||||||
</form>
|
</form>
|
||||||
<script src="js/options.js"></script>
|
<script src="js/options.js"></script>
|
||||||
|
|
Loading…
Add table
Reference in a new issue