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

Allow setting dynamic enable/disable behavior per userscript/userstyle #3315

Open
mxmou opened this issue Aug 17, 2021 · 12 comments
Open

Allow setting dynamic enable/disable behavior per userscript/userstyle #3315

mxmou opened this issue Aug 17, 2021 · 12 comments
Labels
scope: addon.json About the addon.json file structure type: enhancement New feature for the project
Milestone

Comments

@mxmou
Copy link
Member

mxmou commented Aug 17, 2021

Is your request related to a problem? Please describe.

dynamicEnable, dynamicDisable, injectAsStyleElt (is that for faster loading? This one might also need a better name) and updateUserstylesOnSettingChange can't have different values for each userscript and userstyle. This is sometimes a problem: for addons that add new UI, it would be helpful to be able to not remove the CSS when it's disabled to prevent flashes when enabling and disabling. It also means that it isn't possible to make an addon that runs on multiple different pages only support dynamic enable/disable on some of them.

Describe the solution you'd like

Make them properties of userscript/userstyle objects, not the addon itself.

@mxmou mxmou added type: enhancement New feature for the project scope: addon.json About the addon.json file structure labels Aug 17, 2021
@apple502j
Copy link
Member

injectAsStyleElt is used by themes that require dynamic modification of style content, AFAIK.

Could be a problem for userscripts: Addon object is per-addon and not per-userscript (this is by design) and so is addon.self, which means state management is a mess.

@cobaltt7
Copy link
Contributor

cobaltt7 commented Aug 17, 2021 via email

@WorldLanguages
Copy link
Member

injectAsStyleElt is also used for addons that need higher specificity then if they were in a file.

No. Specificity stays unchanged.
injectAsStyleElt is only for faster loading. Some addons don't need faster loading and still use it, tho.
But realistically, it's built for website dark mode.

@WorldLanguages
Copy link
Member

To avoid the flash of content, I think we should first make sure the style loads, then send the reenabled event to the userscript.

It also means that it isn't possible to make an addon that runs on multiple different pages only support dynamic enable/disable on some of them.

Any examples of addons that could make use of that?

@WorldLanguages
Copy link
Member

To avoid the flash of content, I think we should first make sure the style loads, then send the reenabled event to the userscript.

This gets a bit more tricky if addon.tab.displayNoneWhileDisabled is used instead of JavaScript, but it still can be done.

@mxmou
Copy link
Member Author

mxmou commented Aug 18, 2021

It also means that it isn't possible to make an addon that runs on multiple different pages only support dynamic enable/disable on some of them.

Any examples of addons that could make use of that?

ocular.

@WorldLanguages
Copy link
Member

Waiting for response by myself

@WorldLanguages WorldLanguages added the status: awaiting answer/followup A comment will be sent if there's no activity for 7 days, for issues that have this label. label Mar 1, 2023
@scratchaddons-bot
Copy link
Contributor

Ping! There has been no activity for 7 days.

@scratchaddons-bot scratchaddons-bot bot added the status: stale Issue or PR marked stale by a bot label Mar 9, 2023
@WorldLanguages
Copy link
Member

I think the flashing problem deserves its own "type: bug" issue here

@WorldLanguages
Copy link
Member

Note: dynamicDisable never meant anything to userscripts. They get the "disabled" event anyway.

We also need to consider that currently, the settings page does not distinguish between dynamic and non-dynamic addons. We could possibly create a new manifest property that if set to true, reminds the user to refresh after enabling/disabling (and possibly changing any addon settings), that can be arbitrarily set by the addon author, no matter the actual dynamic-ness of the addon.

@WorldLanguages
Copy link
Member

injectAsStyleElt (is that for faster loading? This one might also need a better name)

injectAsStyleElt is also used for addons that need higher specificity then if they were in a file.

No. Specificity stays unchanged.

I aim to solve this confusion and properly explain the functioning and purpose of injectAsStyleElt as part of the new userstyle docs: ScratchAddons/website-v2#311

@scratchaddons-bot scratchaddons-bot bot removed the status: stale Issue or PR marked stale by a bot label Apr 3, 2023
@scratchaddons-bot
Copy link
Contributor

Ping! There has been no activity for 7 days.

@scratchaddons-bot scratchaddons-bot bot added the status: stale Issue or PR marked stale by a bot label Apr 11, 2023
@WorldLanguages WorldLanguages removed status: awaiting answer/followup A comment will be sent if there's no activity for 7 days, for issues that have this label. status: stale Issue or PR marked stale by a bot labels Aug 5, 2023
@WorldLanguages WorldLanguages added this to the Backlog milestone Aug 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: addon.json About the addon.json file structure type: enhancement New feature for the project
Projects
None yet
Development

No branches or pull requests

4 participants