Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Order rulesets by names in popup, Fix #11986 #14678

Merged
merged 4 commits into from
Feb 21, 2018
Merged

Order rulesets by names in popup, Fix #11986 #14678

merged 4 commits into from
Feb 21, 2018

Conversation

cschanaj
Copy link
Collaborator

@cschanaj cschanaj commented Feb 18, 2018

EDIT: It seems that there can be more than 1 main_frame rulesets, please do not merge yet. Luckily, it doesn't matter because the earlier main_frame rulesets do not perform rewrites. Otherwise, the sorting/ insertion logic would be over complicated given the advantages this enhancement can bring us.

this PR makes rulesets shown in the popup sorted by names. Close #11986

Test performed (possibly more needed...)

  • when extension is disabled, counter not shown
  • toggles checkbox to enable/ disable ruleset should works
  • counters should display the correct numbers
  • rulesets are sorted by name case-insensitively, in both stableRules and unstableRules

Not sure if this should be introduced in the next release as well (given #14600).

cc @Hainish @J0WI @jeremyn @Bisaloo

@jeremyn
Copy link
Contributor

jeremyn commented Feb 18, 2018

@cschanaj I tried this out in a browser at https://www.cnn.com and it seems to do the job, good work!

I did not exhaustively test it, but here are some things I noticed:

  • The sort should probably be case-insensitive, but it isn't. For example at https://www.cnn.com it, in my opinion incorrectly, sorts ads-Twitter.com after Twitter.com.

  • The current sort logic appears to list the rulesets in the order they are activated. This has the nice effect of putting the ruleset corresponding to the URL in the address bar at the top of the list. For example, currently CNN.com (partial) is the first ruleset listed at https://www.cnn.com. With the new approach, CNN.com (partial) is buried in the middle of the list. I'm not sure what to propose. We could just move the first ruleset to the top without comment.

  • It would be nice if the ruleset list were updated in real-time, meaning if you have the HTTPS Everywhere UI open while the page is loading, you see the rulesets update while you are looking at the UI. It doesn't do that currently either, so this would be an improvement above-and-beyond the changes you're making. This is of course possible for JavaScript on a normal webpage but maybe it's not possible for extensions, or maybe it would require a ton of extra work.

I also have some minor code suggestions, such as: you should prefer === to ==; avoid the Pythonic if (rulesets) {} "false-y" check; you can still use const even if you are modifying a member of the value. I haven't reviewed and understood the code logic well enough to comment on that though (and I might not ever), so don't take my silence on that as either approval or disapproval.

@jeremyn
Copy link
Contributor

jeremyn commented Feb 19, 2018

f254015 takes care of my case-insensitivity and "main_frame" concerns, thanks!

@cschanaj cschanaj changed the title Order rulesets by names in popup, Fix #11986 [WIP] Order rulesets by names in popup, Fix #11986 Feb 20, 2018
@cschanaj cschanaj changed the title [WIP] Order rulesets by names in popup, Fix #11986 Order rulesets by names in popup, Fix #11986 Feb 20, 2018
@Hainish
Copy link
Member

Hainish commented Feb 20, 2018

@jeremyn

  • It would be nice if the ruleset list were updated in real-time, meaning if you have the HTTPS Everywhere UI open while the page is loading, you see the rulesets update while you are looking at the UI. It doesn't do that currently either, so this would be an improvement above-and-beyond the changes you're making. This is of course possible for JavaScript on a normal webpage but maybe it's not possible for extensions, or maybe it would require a ton of extra work.

This would make it difficult to deactivate a ruleset in the list if resources are still being loaded. Often it will take a while for all resources to be loaded, and if the list is shifting while this is happening it will make it hard to click on the corresponding check box. This problem would be exacerbated by the fact that rulesets are now alphabetical rather than listed in the order they are requested, since previously the checkboxes were be added on to the end, which would not interfere with the position of existing checkboxes.

I would leave off this change for now. We can deal with it separately in the future, but for this PR it seems like an orthogonal change.

} else {
this.active_tab_rules[tabId] = {};
this.active_tab_rules[tabId][ruleset.name] = ruleset;
this.active_tab_rules.set(tabId, [ruleset,]);
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this is strictly necessary. After all, https://github.com/EFForg/https-everywhere/pull/14678/files#diff-81d05cf2685349d7bbbe9f394bd74506R188 will simply override this value when the main_frame is loaded.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this will be necessary when there is no applicable ruleset applied to the main_frame but at least one ruleset applied to the page resources; this is typical when a HTTP-only site serving third-parties HTTPS content.

@jeremyn
Copy link
Contributor

jeremyn commented Feb 20, 2018

@Hainish You make a good point about the difficulty of interacting with the checkboxes while the list is being loaded if the items are being shuffled around. Maybe there is some middle ground between the current approach of doing nothing, and making it fully real-time. In any case I agree it is unrelated to the change of making the rulesets alphabetical, and I'm okay with not requiring related changes in this particular pull request.

@Hainish
Copy link
Member

Hainish commented Feb 20, 2018

@cschanaj I'm ready to merge, pending feedback on #14678 (comment)

@Hainish
Copy link
Member

Hainish commented Feb 21, 2018

Thanks, @cschanaj. This looks great!

@Hainish Hainish merged commit b7306d3 into EFForg:master Feb 21, 2018
@cschanaj cschanaj deleted the order-rulesets-by-name branch February 21, 2018 02:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants