Skip to content

Commit

Permalink
Use menus API instead of contextMenus
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Mar 9, 2020
1 parent 0835790 commit d2698de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions webextensions/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ browser.runtime.onMessage.addListener((aMessage, aSender) => {
showInContent: configs.showProgress
});
if (gLastContextTab == aSender.tab.id)
browser.contextMenus.update('waiting', {
browser.menus.update('waiting', {
title: browser.i18n.getMessage(`menu_waiting_label`, [progress])
});
}
Expand Down Expand Up @@ -156,7 +156,7 @@ const MENU_ITEMS = [
var gLastContextTab = 0;

async function initContextMenuForWaiting(aTabId) {
browser.contextMenus.removeAll();
browser.menus.removeAll();

var count = 0;
for (let id of MENU_ITEMS) {
Expand All @@ -171,7 +171,7 @@ async function initContextMenuForWaiting(aTabId) {
var progress = await browser.tabs.sendMessage(aTabId, {
type: kCOMMAND_FETCH_MATCH_ALL_PROGRESS
});
browser.contextMenus.create({
browser.menus.create({
id: 'waiting',
title: browser.i18n.getMessage(`menu_waiting_label`, [progress || 0]),
enabled: false,
Expand All @@ -180,7 +180,7 @@ async function initContextMenuForWaiting(aTabId) {
}

function initContextMenuForURIs(aURIs) {
browser.contextMenus.removeAll();
browser.menus.removeAll();
if (aURIs.length == 0)
return;

Expand All @@ -200,7 +200,7 @@ function initContextMenuForURIs(aURIs) {

var parentId = null;
if (visibleCount > 1) {
browser.contextMenus.create({
browser.menus.create({
id: 'group',
title: browser.i18n.getMessage(`menu.group.${type}`, [aURIs.length, first, last]),
contexts: ['selection']
Expand All @@ -214,7 +214,7 @@ function initContextMenuForURIs(aURIs) {
let title = browser.i18n.getMessage(`menu.${id}.${type}`);
if (visibleCount == 1)
title = browser.i18n.getMessage(`menu.direct.${type}`, [title, first, last]);
browser.contextMenus.create({
browser.menus.create({
id, title, parentId,
contexts: ['selection']
});
Expand All @@ -227,7 +227,7 @@ function getShortURIString(aURI) {
return aURI;
}

browser.contextMenus.onClicked.addListener((aInfo, aTab) => {
browser.menus.onClicked.addListener((aInfo, aTab) => {
switch (aInfo.menuItemId) {
case 'openCurrent':
browser.tabs.sendMessage(aTab.id, {
Expand Down
2 changes: 1 addition & 1 deletion webextensions/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"description": "__MSG_extensionDescription__",
"permissions": [
"clipboardWrite",
"contextMenus",
"menus",
"find",
"storage"
],
Expand Down

0 comments on commit d2698de

Please sign in to comment.