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

Install/run a web extension using custom preferences #88

Closed
kumar303 opened this issue Mar 1, 2016 · 18 comments
Closed

Install/run a web extension using custom preferences #88

kumar303 opened this issue Mar 1, 2016 · 18 comments

Comments

@kumar303
Copy link
Contributor

kumar303 commented Mar 1, 2016

A run/install command was added in #6 but it only launches Firefox with default preferences. Allow the caller to specify custom preferences. This would be a more lightweight way of customizing Firefox as opposed to creating a custom profile (#69).

@kumar303
Copy link
Contributor Author

I think this should be a pretty easy change actually, so I'm putting back the good first bug label. It only needs:

  • A new repeatable option like --pref="key:value" --pref="key2:value2" ...
  • An update to firefox.configureProfile() to add each preference
  • Tests

I am happy to mentor this.

@kumar303
Copy link
Contributor Author

Here is a good use case: Let's say you want to test your extension in 30 different locales. Instead of making 30 profiles, you could just run it like web-ext --pref=general.useragent.locale:fr-FR for each locale.

@wagnerand
Copy link
Member

Please refer to https://wiki.mozilla.org/Add-ons/Contribute/AMO/Code if this is your first contribution.

If you want to work on this issue and need more information on how or where to fix it, please comment here and we will be happy to provide more details.

Mentor: @kumar303

@davidamidon
Copy link

Hello, I would like to try my hand at this fix. Although I will certainly require direction, I am very eager to participate.

@kumar303
Copy link
Contributor Author

Hi @davidamidon ! I'm here to help, let me know if you have any questions about how to get started.

@davidamidon
Copy link

@kumar303 Thank you! Should I ask in here or is there a better place? I've got everything installed I think. For this fix the code would go in /src/firefox/index.js?

@kumar303
Copy link
Contributor Author

Yes, this is a good place to ask questions. The locations are as follows:

  • Custom preferences are applied to profiles here.
  • New command line options are defined here.
  • The configuration of profiles is tested here.

@davidamidon
Copy link

Ok, I've been looking this over but I'm not sure how to start it. From what I understand;

  • In web-ext/src/firefox/preferences.js the below is used to hard code the contained preferences
    const prefsCommon: FirefoxPreferences = {
  • They are then being exported over to web-ext/src/firefox/index.js
  • web-ext/src/program.js is the list of what we want as custom preferences?

You stated

A new repeatable option like --pref="key:value" --pref="key2:value2" ...

So some form of a loop to take in 1 or more custom preferences.

Hopefully I am on the correct path so far.

@kumar303
Copy link
Contributor Author

Hi. I wouldn't worry about making a repeating option yet, that can be added later. An easy first step is to accept this new option:

web-ext run --pref="key:value"

You can use log.info(...) in the run() function to make sure you configured the new option correctly.

After that, take a look at configureProfile(). This feature would set a new preference in the profile probably within this function. However, there is no need to modify src/firefox/preferences.js because that's a separate feature. The code for adding a custom preference needs to call profile.setPreference(customPref, customValue).

The configureProfile() function is called by copyProfile() and createProfile(). The run command calls either of these in getProfile().

@saintsebastian
Copy link
Contributor

@kumar303 if there is not work currently done on that issue, I'd like to try a hand

@kumar303
Copy link
Contributor Author

@saintsebastian I haven't seen a pull request for this yet (unless I missed it?) so, yeah, feel free to work on a patch for this. Thanks!

@kumar303
Copy link
Contributor Author

kumar303 commented Jan 3, 2017

@saintsebastian this is a great feature, thanks for all your work on it!

We just released it in 1.7.0 so the next step is to add it to the run command documentation. Could you try to add it? I can help if you have questions and can also review the docs after you add them.

@saintsebastian
Copy link
Contributor

@kumar303 thank you, it was fun working on it.
Here is the draft I have for this occasion. I think that’s pretty much everything a given user need to know, but we can also include information on where to find those preferences in the first place (about:config) or that some of them cannot be changed.

--pref
Repeated option that allows to customise certain Firefox profile settings without creating of modifying a profile. Accepts arguments in a form of --pref ‘general.useragent.locale=fr-FR’. Can be used in combination with specified Firefox profile.

@kumar303
Copy link
Contributor Author

kumar303 commented Jan 3, 2017

That looks good to me! Just a few small nits:

  • We use international English spelling elsewhere in the docs so customise should be customize
  • "creating of modifying..." (typo) -> "creating or modifying..."
  • The example should be --pref general.useragent.locale=fr-FR without the quotes because Luca and I have been testing this and it works fine without quotes (surprisingly).

Please sign into the MDN page via Github and make the edit. Let me know if you run into issues.

@saintsebastian
Copy link
Contributor

@kumar303 I have a question - how to add numbered lines in a code block in editor?

@kumar303
Copy link
Contributor Author

kumar303 commented Jan 3, 2017

Thanks for the edit! It requires you to edit the source and add a new css class to the pre tag (which is annoying). I updated it for you. What you wrote was great but while I was in there I just made the tense and tone more consistent with how the other options are documented.

I also mentioned the environment variable for the option which we do in all option docs. However, I was unsure how it works since this is the first option we have that can be specified multiple times. Could you look at this issue when you get a chance? #725

@kumar303
Copy link
Contributor Author

kumar303 commented Jan 3, 2017

@saintsebastian
Copy link
Contributor

Sure, thank you for the edits!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants