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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to disable all the features! #877

Merged
merged 10 commits into from Dec 17, 2017
Merged

Add ability to disable all the features! #877

merged 10 commits into from Dec 17, 2017

Conversation

fregante
Copy link
Member

@fregante fregante commented Dec 15, 2017

Note: npm install needed.

Being developers, everything would ideally be an option
@bfred-it on 12 May 2016

So here we are... 馃槄

  • Doesn't clutter the interface with a thousand options
  • Doesn't clutter the code with a thousand conditions
  • Low maintenance cost

options screen function name logging

Next:

  • Add liability clause (i.e. if you disable something, good luck)
  • Add logging toggle to be able to find the feature names

The rawness of these options should discourage people from disabling stuff but they can if they try hard enough.

Fixes #779 #585 #515 #285 #193 #174 #131 #57 #10

Sadly doesn't fix any of the open change request since they're CSS-related.

@sindresorhus
Copy link
Member

Good idea. I think this is a good balance and now we have a place to refer most "option request" issues.

@sindresorhus sindresorhus changed the title Disable all the features! Add ability to disable all the features! Dec 15, 2017
@fregante
Copy link
Member Author

fregante commented Dec 15, 2017

Cool! Give it a spin and let鈥檚 merge after we update the readme and extend the field description. Commits or suggestions welcome.

*/
export const safely = async fn => fn();
export const enableFeature = async (fn, fileName) => {
Copy link
Member

Choose a reason for hiding this comment

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

Filename is most commonly used as one word, not file name.

<input type="checkbox" name="hideStarsOwnRepos">
Hide other users starring/forking your repos
</label>
List the features to disable, by <a href="https://github.com/sindresorhus/refined-github/tree/master/source/features" target="_blank">file name</a>: <br>
Copy link
Member

Choose a reason for hiding this comment

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

file name => filename

List the features to disable, by <a href="https://github.com/sindresorhus/refined-github/tree/master/source/features" target="_blank">file name</a>: <br>
<textarea name="disabledFeatures" rows="5" placeholder="For example:
log-active-features
hide-own-stars
Copy link
Member

Choose a reason for hiding this comment

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

It's weird to use literal newlines here. I would use \n escape instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

\n doesn鈥檛 work but this might https://stackoverflow.com/a/983988

export const safely = async fn => fn();
export const enableFeature = async (fn, fileName) => {
const {disabledFeatures} = await options;
const log = disabledFeatures.includes('log-active-features') ? () => {} : console.log;
Copy link
Member

Choose a reason for hiding this comment

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

Why have this as an option instead of just enabled by default when in dev mode?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it鈥檚 a user-facing feature also. One might want to see what鈥檚 enabled/disabled on a page. Maybe?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it鈥檚 a user-facing feature also. One might want to see what鈥檚 enabled/disabled on a page. Maybe?

Copy link
Member

Choose a reason for hiding this comment

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

Could we have a checkbox to enable dev/debug mode instead? It doesn鈥檛 really feel like a feature in that sense.

Copy link

Choose a reason for hiding this comment

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

What about enabling logging by default with console.group(), or even better console.groupCollapsed(), so that way console is not cluttered and the user still gets to see what features are enabled.

It doesn鈥檛 really feel like a feature in that sense

馃憤

Copy link
Member Author

@fregante fregante Dec 16, 2017

Choose a reason for hiding this comment

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

I don't think extensions should clutter the console by default, even if it's just one item.

Copy link
Member

Choose a reason for hiding this comment

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

Let's go with a checkbox that is unchecked by default. It can be useful for other production debugging we might want later on too.

},
migrations: [
options => {
if (options.hideStarsOwnRepos === true) {
Copy link
Member

Choose a reason for hiding this comment

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

Should be false

@fregante
Copy link
Member Author

options page

@@ -5,9 +5,16 @@ import dynamicContentScripts from 'webext-dynamic-content-scripts';
// Define defaults
new OptionsSync().define({
defaults: {
hideStarsOwnRepos: true
disabledFeatures: 'log-active-features',
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be empty now?

@@ -5,9 +5,16 @@ import dynamicContentScripts from 'webext-dynamic-content-scripts';
// Define defaults
new OptionsSync().define({
defaults: {
hideStarsOwnRepos: true
disabledFeatures: 'log-active-features',
logFeatures: false
Copy link
Member

Choose a reason for hiding this comment

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

I was thinking we make this more generic so we could use it for other production logging in the future. This locks it into just being logging of features.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. When that happens the feature can be developed further.

@sindresorhus sindresorhus merged commit f4fca5f into master Dec 17, 2017
@sindresorhus sindresorhus deleted the option-hell branch December 17, 2017 10:05
@sindresorhus
Copy link
Member

Awesome! Some people are gonna love this.

@fregante
Copy link
Member Author

Yep! Can you update the readme?

@sindresorhus
Copy link
Member

Sure

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

Successfully merging this pull request may close these issues.

Please make the extension configurable in Chrome settings
3 participants