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

Automatically convert :has to :-abp-has on filters build #662

Closed
ameshkov opened this issue Aug 25, 2022 · 0 comments
Closed

Automatically convert :has to :-abp-has on filters build #662

ameshkov opened this issue Aug 25, 2022 · 0 comments
Assignees
Labels
Enhancement New feature or request

Comments

@ameshkov
Copy link
Member

Due to AdguardTeam/ExtendedCss#149 we may have a problem with :has rules in AdGuard.

I would like to avoid pushing a hotfix to all AG products and wait until ExtCSS v2.0 is released.

I propose to modify FiltersRegistry and add some code that replaces :has( with :-abp-has( everywhere.

Here's how it should be done:

  1. Modify https://github.com/AdguardTeam/FiltersRegistry/blob/master/index.js, it should look like this:
    /**
     * Replaces all occurrencies of str to repl in the build results.
     *
     * @param {String} str - string to search for in the filters.
     * @param {String} repl - repl is string to replace with.
     */
    async function replaceInFilters(str, repl) {
        // 1. Find all ".txt" files in platformsPath recursively
        // 2. Read their content
        // 3. Replace str with repl in the content
        // 4. Write the content back
    }
    
    /**
     * Compiler entry point.
     */
    async function main() {
        await compiler.compile(
            filtersDir,
            logPath,
            reportPath,
            platformsPath,
            whitelist,
            blacklist,
            customPlatformsConfig,
        );
    
        // TODO: remove this when ExtCSS v2.0 is released to all AG products.
        await replaceInFilters();
    }
    
    main();
  2. Implement replaceInFilters
@ameshkov ameshkov added the Enhancement New feature or request label Aug 25, 2022
zloyden added a commit that referenced this issue Aug 29, 2022
zloyden added a commit that referenced this issue Aug 29, 2022
* Feature #662

* using replace method with the global modifier

* uncomment compile function

* added description to one function and edited param

* added a new line

Co-authored-by: zloyden <33488229+zloyden@users.noreply.github.com>
Co-authored-by: Slava Leleka <v.leleka@adguard.com>
Co-authored-by: Andrey Meshkov <am@adguard.com>
@zloyden zloyden closed this as completed Aug 29, 2022
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