Skip to content

Commit

Permalink
use chrome.contextMenus instead of browser.menus
Browse files Browse the repository at this point in the history
this should make the extension fully functional for all mv2 firefox 
versions (since 48)

tested and working in older esr edition.

v0.2.0
  • Loading branch information
wesinator committed Nov 25, 2022
1 parent b7bd24b commit 037a19c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -9,6 +9,8 @@ Supports MD5, SHA; using [crypto-api](https://github.com/nf404/crypto-api)
#### _Caveat emptor_
- Hashes of selected multi-line text will differ between Windows and macOS/Linux hosts, because of text line-ending encoding. This is not a bug _per se_, something to be aware of.
- Doesn't work on `raw.githubusercontent.com` page text. ([Bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1411641))

- Older versions of Firefox may strip whitespace from the edge of selected text. The hash and text displayed is still correct but doesn't correspond exactly to the selected text with whitespace included.

#### Privacy policy

Expand Down
12 changes: 6 additions & 6 deletions src/background.js
Expand Up @@ -18,31 +18,31 @@ function onError(error) {
console.log(`Error: ${error}`);
}

browser.menus.create({
chrome.contextMenus.create({
id: "MD5",
title: browser.i18n.getMessage("MD5"),
contexts: ["all"]
}, onCreated);

browser.menus.create({
chrome.contextMenus.create({
id: "separator0",
type: "separator",
contexts: ["all"]
}, onCreated);

browser.menus.create({
chrome.contextMenus.create({
id: "SHA1",
title: browser.i18n.getMessage("SHA1"),
contexts: ["all"]
}, onCreated);

browser.menus.create({
chrome.contextMenus.create({
id: "SHA256",
title: browser.i18n.getMessage("SHA256"),
contexts: ["all"]
}, onCreated);

browser.menus.create({
chrome.contextMenus.create({
id: "SHA512",
title: browser.i18n.getMessage("SHA512"),
contexts: ["all"]
Expand All @@ -53,7 +53,7 @@ browser.menus.create({
The click event listener, where we perform the appropriate action given the
ID of the menu item that was clicked.
*/
browser.menus.onClicked.addListener((info, tab) => {
chrome.contextMenus.onClicked.addListener((info, tab) => {
hash = null;
hashType = info.menuItemId;
//console.log(info.selectionText);
Expand Down
4 changes: 2 additions & 2 deletions src/manifest.json
Expand Up @@ -4,13 +4,13 @@
"description": "Hash selected text and pages in the browser.",
"homepage_url": "https://github.com/wesinator/hashzilla",
"default_locale": "en",
"version": "0.1.6",
"version": "0.2.0",
"icons": {
"64": "icons/icon.png"
},

"permissions": [
"menus",
"contextMenus",
"activeTab"
],

Expand Down

0 comments on commit 037a19c

Please sign in to comment.