-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 ability to disable all the features! #877
Conversation
Each feature has its own file; start/stop logic should not be outside. This keeps function names as intended and not `setup`
Good idea. I think this is a good balance and now we have a place to refer most "option request" issues. |
Cool! Give it a spin and let’s merge after we update the readme and extend the field description. Commits or suggestions welcome. |
source/libs/utils.js
Outdated
*/ | ||
export const safely = async fn => fn(); | ||
export const enableFeature = async (fn, fileName) => { |
There was a problem hiding this comment.
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.
source/options.html
Outdated
<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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file name
=> filename
source/options.html
Outdated
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\n doesn’t work but this might https://stackoverflow.com/a/983988
source/libs/utils.js
Outdated
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it’s a user-facing feature also. One might want to see what’s enabled/disabled on a page. Maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it’s a user-facing feature also. One might want to see what’s enabled/disabled on a page. Maybe?
There was a problem hiding this comment.
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’t really feel like a feature in that sense.
There was a problem hiding this comment.
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’t really feel like a feature in that sense
👍
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
source/background.js
Outdated
}, | ||
migrations: [ | ||
options => { | ||
if (options.hideStarsOwnRepos === true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be false
source/background.js
Outdated
@@ -5,9 +5,16 @@ import dynamicContentScripts from 'webext-dynamic-content-scripts'; | |||
// Define defaults | |||
new OptionsSync().define({ | |||
defaults: { | |||
hideStarsOwnRepos: true | |||
disabledFeatures: 'log-active-features', |
There was a problem hiding this comment.
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?
source/background.js
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Awesome! Some people are gonna love this. |
Yep! Can you update the readme? |
Sure |
Note:
npm install
needed.So here we are... 😅
Next:
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.