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

Script to generate css commons automatically #745

Closed
appeasementPolitik opened this issue Nov 24, 2022 · 5 comments
Closed

Script to generate css commons automatically #745

appeasementPolitik opened this issue Nov 24, 2022 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@appeasementPolitik
Copy link
Contributor

Hey, I had an idea which I have been working on a little. What about a script that can automatically check the amount of duplicate css rules, and automatically generates a commons list based on the values with the most duplicates and also changes the affected rules. Is something like this interesting?

If so, is there a specific programming language I should use? For now I managed to generate a list of all css values (including commons) and the amount of their occurences using shell script, but I'm open to implement it in another language if this is more usable.

Also, should only the 100 css rules with the most usage be used like it's currently done or more? In theory every value that is used at least twice could have a commons, but I'm not sure if this is desirable.

@OhMyGuus
Copy link
Owner

That would be indeed a good idea!

About the programming language, I would of chosen nodejs for the simplicity for this, since you can just import the rules.js so it doesn't require parsing. but any language should work, but even a shell script should work since it doesn't have to run that often so yeah 👍

Oh and in my opinion it's if it's more than 4/5 it can be a common

@appeasementPolitik
Copy link
Contributor Author

Hey, I wrote the script, you can find it at:

https://github.com/appeasementPolitik/ruleclean

I've also made a branch with the changes this script would make at:

https://github.com/appeasementPolitik/I-Dont-Care-About-Cookies/tree/clean-rules

It's not ready to be merged, as it's just a showcase and can be improved (some commons could be merged for example)

@appeasementPolitik
Copy link
Contributor Author

appeasementPolitik commented Nov 25, 2022

I've now cleaned up the commons as well, so now the only thing left is checking if nothing went wrong during the cleaning.

Also something I've realized, this script can very easily be modified to make uBlock Origin filters with the rules, like what existed in the original IDCAC. I'm not sure if it's a good idea, but it might be something interesting to look at as well.

@OhMyGuus
Copy link
Owner

OhMyGuus commented Nov 26, 2022

Oh this seems to be quite nice, and good job implementing it in nodejs 😄

@OhMyGuus OhMyGuus added enhancement New feature or request high priority NICE and removed high priority labels Nov 26, 2022
@OhMyGuus OhMyGuus self-assigned this Nov 26, 2022
@appeasementPolitik
Copy link
Contributor Author

Thank you, it was fun to practice with javascript again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants