do not remove what has already been removed
This commit is contained in:
parent
786302927d
commit
5c86f87394
1 changed files with 16 additions and 14 deletions
|
@ -34,23 +34,25 @@ export default class Menu {
|
||||||
};
|
};
|
||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
|
(!this.hidden) ? chrome.contextMenus.remove(this.ID) : false;
|
||||||
this.hidden = true;
|
this.hidden = true;
|
||||||
chrome.contextMenus.remove(this.ID);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
this.hidden = false;
|
if (this.hidden || this.hidden == null) {
|
||||||
this.ID = chrome.contextMenus.create(this.#options);
|
this.hidden = false;
|
||||||
|
this.ID = chrome.contextMenus.create(this.#options);
|
||||||
|
|
||||||
if (((this.events && (typeof this.events).includes(`obj`) && !Array.isArray(this.events))) ? Object.keys(events) > 0 : false) {
|
if (((this.events && (typeof this.events).includes(`obj`) && !Array.isArray(this.events))) ? Object.keys(events) > 0 : false) {
|
||||||
(Object.keys(this.events)).forEach((EVENT) => {
|
(Object.keys(this.events)).forEach((EVENT) => {
|
||||||
chrome.contextMenus[EVENT].addListener((info, tab) => {
|
chrome.contextMenus[EVENT].addListener((info, tab) => {
|
||||||
((info.menuItemId) ? info.menuItemId == this.ID : false)
|
((info.menuItemId) ? info.menuItemId == this.ID : false)
|
||||||
? this.events[EVENT](info, tab)
|
? this.events[EVENT](info, tab)
|
||||||
: false;
|
: false;
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the context menu.
|
/* Update the context menu.
|
||||||
|
@ -71,7 +73,7 @@ export default class Menu {
|
||||||
};
|
};
|
||||||
(this.icon) ? this.#options.icon = this.icon : null;
|
(this.icon) ? this.#options.icon = this.icon : null;
|
||||||
|
|
||||||
chrome.contextMenus.update(this.ID, this.#options);
|
(!this.hidden) ? chrome.contextMenus.update(this.ID, this.#options) : false;
|
||||||
|
|
||||||
(((this.events && (typeof this.events).includes(`obj`) && !Array.isArray(this.events))) ? Object.keys(events) > 0 : false)
|
(((this.events && (typeof this.events).includes(`obj`) && !Array.isArray(this.events))) ? Object.keys(events) > 0 : false)
|
||||||
? (Object.keys(this.events)).forEach((EVENT) => {
|
? (Object.keys(this.events)).forEach((EVENT) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue