Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add settings checkbox #276

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [@ENT8R](https://github.com/ENT8R)
- [@OogieBoogieInJSON](https://github.com/OogieBoogieInJSON)
- [@redagavin](https://github.com/redagavin)
- [@starborne-nova](https://github.com/starborne-nova)
- [@Thammarith](https://github.com/Thammarith)
- [@xlomonosvx](https://github.com/xlomonosvx)
- Alexander Knipping ([@obitech](https://github.com/obitech))
Expand Down
16 changes: 11 additions & 5 deletions src/background/modules/ContextMenu.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunicationTypes.js";
import { createMenu } from "/common/modules/ContextMenu.js";
import * as AddonSettings from "/common/modules/AddonSettings/AddonSettings.js";

const CONVERT_TEXT_SELECTION = "qr-convert-text-selection";
const CONVERT_LINK_TEXT_SELECTION = "qr-convert-link-text-selection";
Expand Down Expand Up @@ -132,8 +133,13 @@ function menuShown(info) {
* @returns {Promise}
*/
export function init() {
return createItems().then(() => {
browser.menus.onClicked.addListener(menuClicked);
browser.menus.onShown.addListener(menuShown);
});
}
const menuDisabled = AddonSettings.get("disableContextMenu")

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

that empty line is not helpful IMHO ;)


if(menuDisabled === false){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(menuDisabled === false){
if (menuDisabled === false) {

another codeormat thing to keep spaces here

return createItems().then(() => {
browser.menus.onClicked.addListener(menuClicked);
browser.menus.onShown.addListener(menuShown);
});
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

Please mind to keep the code-format in tact. Some IDEs can autoformat the files.

1 change: 1 addition & 0 deletions src/common/modules/data/DefaultSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const defaultSettings = Object.freeze({
qrErrorCorrection: "Q",
autoGetSelectedText: false,
monospaceFont: false,
disableContextMenu: false,
qrCodeSize: {
sizeType: "fixed",
size: 220
Expand Down
207 changes: 207 additions & 0 deletions src/log2022-2-21_21-46-22.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
21:42:28.783 Offline QR code [WARN] could not get managed options Error: Managed storage manifest not found Logger.js:76:21
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this log file was accidentally committed and you may delete it 🙃

21:42:28.783 Offline QR code [INFO] AddonSettings module loaded. Logger.js:79:21
21:42:28.784 Offline QR code [WARN] Could not get option "debugMode". Using default. false Logger.js:76:21
21:42:28.784 Offline QR code [WARN] Could not get option "popupIconColored". Using default. false Logger.js:76:21
21:42:28.784 Offline QR code [WARN] Could not get option "disableContextMenu". Using default. false Logger.js:76:21
21:42:55.378 Offline QR code [WARN] null does not exist. Skip registering message type. 2 Logger.js:76:21
21:42:55.387 Offline QR code [WARN] could not get managed options Error: Managed storage manifest not found Logger.js:76:21
21:42:55.387 Content Security Policy: The page’s settings blocked the loading of a resource at eval (“script-src”). moz-extension:2:91524
21:42:55.388 Offline QR code [INFO] AddonSettings module loaded. Logger.js:79:21
21:42:55.389 Offline QR code [WARN] could not get managed options Error: Managed storage manifest not found Logger.js:76:21
21:42:55.391 Offline QR code [WARN] Could not get option "debugMode". Using default. false Logger.js:76:21
21:42:55.392 Offline QR code [WARN] The following defined default value of type object is not frozen. It is recommend that all default options are frozen.
Object { debugMode: false, popupIconColored: false, qrColor: "#0c0c0d", qrBackgroundColor: "#d7d7db", qrErrorCorrection: "Q", autoGetSelectedText: false, monospaceFont: false, disableContextMenu: false, qrCodeSize: {…}, qrQuietZone: 1, … }
Logger.js:76:21
21:42:55.392 Offline QR code [WARN] The following defined default value of type object is not frozen. It is recommend that all default options are frozen.
Object { sizeType: "fixed", size: 220 }
Logger.js:76:21
21:42:55.393 Offline QR code [WARN] The following defined default value of type object is not frozen. It is recommend that all default options are frozen.
Object { tips: {} }
Logger.js:76:21
21:42:55.393 Offline QR code [WARN] Could not get option "monospaceFont". Using default. false Logger.js:76:21
21:42:55.393 Offline QR code [WARN] Could not get option "qrBackgroundColor". Using default. #d7d7db Logger.js:76:21
21:42:55.394 Offline QR code [WARN] The following defined default value of type object is not frozen. It is recommend that all default options are frozen.
Object { sizeType: "fixed", size: 220 }
Logger.js:76:21
21:42:55.394 Offline QR code [WARN] Could not get option "qrCodeSize". Using default.
Object { sizeType: "fixed", size: 220 }
Logger.js:76:21
21:42:55.394 Offline QR code [WARN] Could not get option "autoGetSelectedText". Using default. false Logger.js:76:21
21:42:55.394 Offline QR code [INFO] Synced setting got for "randomTips".
Object { tips: {…}, triggeredOpen: 1 }
Logger.js:79:21
21:42:55.395 Offline QR code [WARN] The following defined default value of type object is not frozen. It is recommend that all default options are frozen.
Object { tips: {} }
Logger.js:76:21
21:42:55.400 Uncaught (in promise) Error: show no random tip, because randomize did not pass
showRandomTipIfWanted moz-extension://41d70f35-2c45-421a-be42-844a9d7fb6a4/common/modules/RandomTips/RandomTips.js:333
<anonymous> moz-extension://41d70f35-2c45-421a-be42-844a9d7fb6a4/popup/qrcode.js:17
promise callback* moz-extension://41d70f35-2c45-421a-be42-844a9d7fb6a4/popup/qrcode.js:15
RandomTips.js:333:31
21:42:55.400 Uncaught (in promise) Error: using selection is disabled
gettingSelection moz-extension://41d70f35-2c45-421a-be42-844a9d7fb6a4/popup/modules/InitQrCode.js:37
promise callback* moz-extension://41d70f35-2c45-421a-be42-844a9d7fb6a4/popup/modules/InitQrCode.js:35
InitQrCode.js:37:31
21:44:47.276 could not get managed options Error: Managed storage manifest not found AddonSettings.js:98:21
21:44:47.276 AddonSettings module loaded. AddonSettings.js:342:13
21:44:47.323 could not get managed options Error: Managed storage manifest not found
disableManagedStore moz-extension://41d70f35-2c45-421a-be42-844a9d7fb6a4/common/modules/AddonSettings/tests/helper/AddonSettingsStub.js:71
stubSettings moz-extension://41d70f35-2c45-421a-be42-844a9d7fb6a4/common/modules/AddonSettings/tests/helper/AddonSettingsStub.js:117
<anonymous> moz-extension://41d70f35-2c45-421a-be42-844a9d7fb6a4/tests/iconHandler.test.js:93
callFn https://unpkg.com/[email protected]/mocha.js:4550
run https://unpkg.com/[email protected]/mocha.js:4542
runTest https://unpkg.com/[email protected]/mocha.js:5078
next https://unpkg.com/[email protected]/mocha.js:5196
next https://unpkg.com/[email protected]/mocha.js:4992
next https://unpkg.com/[email protected]/mocha.js:5002
next https://unpkg.com/[email protected]/mocha.js:4926
next https://unpkg.com/[email protected]/mocha.js:4965
done https://unpkg.com/[email protected]/mocha.js:4497
callFn https://unpkg.com/[email protected]/mocha.js:4573
run https://unpkg.com/[email protected]/mocha.js:4542
next https://unpkg.com/[email protected]/mocha.js:4940
hook https://unpkg.com/[email protected]/mocha.js:4970
timeslice https://unpkg.com/[email protected]/mocha.js:82
setTimeout handler*[1]</</Mocha.Runner.immediately https://unpkg.com/[email protected]/mocha.js:98
hook https://unpkg.com/[email protected]/mocha.js:4969
next https://unpkg.com/[email protected]/mocha.js:4995
hooks https://unpkg.com/[email protected]/mocha.js:5006
hookUp https://unpkg.com/[email protected]/mocha.js:5018
next https://unpkg.com/[email protected]/mocha.js:5228
done https://unpkg.com/[email protected]/mocha.js:4497
callFn https://unpkg.com/[email protected]/mocha.js:4555
promise callback*callFn https://unpkg.com/[email protected]/mocha.js:4553
run https://unpkg.com/[email protected]/mocha.js:4542
runTest https://unpkg.com/[email protected]/mocha.js:5078
next https://unpkg.com/[email protected]/mocha.js:5196
next https://unpkg.com/[email protected]/mocha.js:4992
next https://unpkg.com/[email protected]/mocha.js:5002
next https://unpkg.com/[email protected]/mocha.js:4926
hook https://unpkg.com/[email protected]/mocha.js:4970
timeslice https://unpkg.com/[email protected]/mocha.js:82
setTimeout handler*[1]</</Mocha.Runner.immediately https://unpkg.com/[email protected]/mocha.js:98
hook https://unpkg.com/[email protected]/mocha.js:4969
next https://unpkg.com/[email protected]/mocha.js:4995
hooks https://unpkg.com/[email protected]/mocha.js:5006
hookUp https://unpkg.com/[email protected]/mocha.js:5018
next https://unpkg.com/[email protected]/mocha.js:5228
done https://unpkg.com/[email protected]/mocha.js:4497
callFn https://unpkg.com/[email protected]/mocha.js:4555
promise callback*callFn https://unpkg.com/[email protected]/mocha.js:4553
run https://unpkg.com/[email protected]/mocha.js:4542
runTest https://unpkg.com/[email protected]/mocha.js:5078
next https://unpkg.com/[email protected]/mocha.js:5196
next https://unpkg.com/[email protected]/mocha.js:4992
next https://unpkg.com/[email protected]/mocha.js:5002
next https://unpkg.com/[email protected]/mocha.js:4926
hook https://unpkg.com/[email protected]/mocha.js:4970
timeslice https://unpkg.com/[email protected]/mocha.js:82
AddonSettings.js:98:21
21:44:47.323 Synced setting got for "popupIconColored". true AddonSettings.js:251:21
21:44:47.326 could not get managed options Error: Managed storage manifest not found
disableManagedStore moz-extension://41d70f35-2c45-421a-be42-844a9d7fb6a4/common/modules/AddonSettings/tests/helper/AddonSettingsStub.js:71
stubSettings moz-extension://41d70f35-2c45-421a-be42-844a9d7fb6a4/common/modules/AddonSettings/tests/helper/AddonSettingsStub.js:117
<anonymous> moz-extension://41d70f35-2c45-421a-be42-844a9d7fb6a4/tests/iconHandler.test.js:101
callFn https://unpkg.com/[email protected]/mocha.js:4550
run https://unpkg.com/[email protected]/mocha.js:4542
runTest https://unpkg.com/[email protected]/mocha.js:5078
next https://unpkg.com/[email protected]/mocha.js:5196
next https://unpkg.com/[email protected]/mocha.js:4992
next https://unpkg.com/[email protected]/mocha.js:5002
next https://unpkg.com/[email protected]/mocha.js:4926
next https://unpkg.com/[email protected]/mocha.js:4965
done https://unpkg.com/[email protected]/mocha.js:4497
callFn https://unpkg.com/[email protected]/mocha.js:4573
run https://unpkg.com/[email protected]/mocha.js:4542
next https://unpkg.com/[email protected]/mocha.js:4940
hook https://unpkg.com/[email protected]/mocha.js:4970
timeslice https://unpkg.com/[email protected]/mocha.js:82
setTimeout handler*[1]</</Mocha.Runner.immediately https://unpkg.com/[email protected]/mocha.js:98
hook https://unpkg.com/[email protected]/mocha.js:4969
next https://unpkg.com/[email protected]/mocha.js:4995
hooks https://unpkg.com/[email protected]/mocha.js:5006
hookUp https://unpkg.com/[email protected]/mocha.js:5018
next https://unpkg.com/[email protected]/mocha.js:5228
done https://unpkg.com/[email protected]/mocha.js:4497
callFn https://unpkg.com/[email protected]/mocha.js:4555
promise callback*callFn https://unpkg.com/[email protected]/mocha.js:4553
run https://unpkg.com/[email protected]/mocha.js:4542
runTest https://unpkg.com/[email protected]/mocha.js:5078
next https://unpkg.com/[email protected]/mocha.js:5196
next https://unpkg.com/[email protected]/mocha.js:4992
next https://unpkg.com/[email protected]/mocha.js:5002
next https://unpkg.com/[email protected]/mocha.js:4926
next https://unpkg.com/[email protected]/mocha.js:4965
done https://unpkg.com/[email protected]/mocha.js:4497
callFn https://unpkg.com/[email protected]/mocha.js:4573
run https://unpkg.com/[email protected]/mocha.js:4542
next https://unpkg.com/[email protected]/mocha.js:4940
hook https://unpkg.com/[email protected]/mocha.js:4970
timeslice https://unpkg.com/[email protected]/mocha.js:82
setTimeout handler*[1]</</Mocha.Runner.immediately https://unpkg.com/[email protected]/mocha.js:98
hook https://unpkg.com/[email protected]/mocha.js:4969
next https://unpkg.com/[email protected]/mocha.js:4995
hooks https://unpkg.com/[email protected]/mocha.js:5006
hookUp https://unpkg.com/[email protected]/mocha.js:5018
next https://unpkg.com/[email protected]/mocha.js:5228
done https://unpkg.com/[email protected]/mocha.js:4497
callFn https://unpkg.com/[email protected]/mocha.js:4555
promise callback*callFn https://unpkg.com/[email protected]/mocha.js:4553
run https://unpkg.com/[email protected]/mocha.js:4542
runTest https://unpkg.com/[email protected]/mocha.js:5078
next https://unpkg.com/[email protected]/mocha.js:5196
next https://unpkg.com/[email protected]/mocha.js:4992
next https://unpkg.com/[email protected]/mocha.js:5002
next https://unpkg.com/[email protected]/mocha.js:4926
hook https://unpkg.com/[email protected]/mocha.js:4970
timeslice https://unpkg.com/[email protected]/mocha.js:82
setTimeout handler*[1]</</Mocha.Runner.immediately https://unpkg.com/[email protected]/mocha.js:98
hook https://unpkg.com/[email protected]/mocha.js:4969
next https://unpkg.com/[email protected]/mocha.js:4995
hooks https://unpkg.com/[email protected]/mocha.js:5006
hookUp https://unpkg.com/[email protected]/mocha.js:5018
next https://unpkg.com/[email protected]/mocha.js:5228
done https://unpkg.com/[email protected]/mocha.js:4497
callFn https://unpkg.com/[email protected]/mocha.js:4555
promise callback*callFn https://unpkg.com/[email protected]/mocha.js:4553
run https://unpkg.com/[email protected]/mocha.js:4542
runTest https://unpkg.com/[email protected]/mocha.js:5078
next https://unpkg.com/[email protected]/mocha.js:5196
next https://unpkg.com/[email protected]/mocha.js:4992
next https://unpkg.com/[email protected]/mocha.js:5002
next https://unpkg.com/[email protected]/mocha.js:4926
hook https://unpkg.com/[email protected]/mocha.js:4970
timeslice https://unpkg.com/[email protected]/mocha.js:82
AddonSettings.js:98:21
21:44:47.327 Synced setting got for "popupIconColored". false AddonSettings.js:251:21
21:45:21.109 Content Security Policy: The page’s settings blocked the loading of a resource at eval (“script-src”). moz-extension:2:91524
21:45:21.215 Offline QR code [WARN] could not get managed options Error: Managed storage manifest not found Logger.js:76:21
21:45:21.215 Offline QR code [INFO] AddonSettings module loaded. Logger.js:79:21
21:45:21.216 Offline QR code [WARN] Could not get option "debugMode". Using default. false Logger.js:76:21
21:45:21.220 Offline QR code [WARN] null does not exist. Skip registering message type. 2 Logger.js:76:21
21:45:21.225 Offline QR code [WARN] could not get managed options Error: Managed storage manifest not found Logger.js:76:21
21:45:21.229 Offline QR code [WARN] The following defined default value of type object is not frozen. It is recommend that all default options are frozen.
Object { debugMode: false, popupIconColored: false, qrColor: "#0c0c0d", qrBackgroundColor: "#d7d7db", qrErrorCorrection: "Q", autoGetSelectedText: false, monospaceFont: false, disableContextMenu: false, qrCodeSize: {…}, qrQuietZone: 1, … }
Logger.js:76:21
21:45:21.230 Offline QR code [WARN] The following defined default value of type object is not frozen. It is recommend that all default options are frozen.
Object { sizeType: "fixed", size: 220 }
Logger.js:76:21
21:45:21.230 Offline QR code [WARN] The following defined default value of type object is not frozen. It is recommend that all default options are frozen.
Object { tips: {} }
Logger.js:76:21
21:45:21.231 Offline QR code [WARN] Could not get option "monospaceFont". Using default. false Logger.js:76:21
21:45:21.231 Offline QR code [WARN] Could not get option "qrBackgroundColor". Using default. #d7d7db Logger.js:76:21
21:45:21.231 Offline QR code [WARN] The following defined default value of type object is not frozen. It is recommend that all default options are frozen.
Object { sizeType: "fixed", size: 220 }
Logger.js:76:21
21:45:21.232 Offline QR code [WARN] Could not get option "qrCodeSize". Using default.
Object { sizeType: "fixed", size: 220 }
Logger.js:76:21
21:45:21.232 Offline QR code [WARN] Could not get option "autoGetSelectedText". Using default. false Logger.js:76:21
21:45:21.232 Offline QR code [WARN] The following defined default value of type object is not frozen. It is recommend that all default options are frozen.
Object { tips: {} }
Logger.js:76:21
21:45:21.238 Uncaught (in promise) Error: using selection is disabled
gettingSelection moz-extension://41d70f35-2c45-421a-be42-844a9d7fb6a4/popup/modules/InitQrCode.js:37
promise callback* moz-extension://41d70f35-2c45-421a-be42-844a9d7fb6a4/popup/modules/InitQrCode.js:35
InitQrCode.js:37:31
7 changes: 7 additions & 0 deletions src/options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ <h1 data-i18n="__MSG_titleAddonBehavior__">Addon behavior</h1>
</div>
</li>

<li>
<div class="line">
<input class="setting save-on-change" type="checkbox" id="disableContextMenu" name="disableContextMenu">
<label data-i18n="__MSG_optionDisableContextMenu__" for="disableContextMenu">Disable the context menu item for selected text</label>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great you added that option and i18n entry. However please also provide the translation string in the message.json file, so people can translate it. It is enough to provide the English translation, of course, so you can just copy and paste the string from here.
This ensures, that text snippet is ready for translation and can be localized.

For more information, please see the MDN guide on how to localize WebExtensions and our internationalization (i18n) guide.

</div>
</li>

<li>
<div class="line">
<input class="setting save-on-change" type="checkbox" id="debugMode" name="debugMode">
Expand Down