Creating Adguard custom filters from Ad Muncher custom filters

Discussion in 'Discussion (Adguard for Windows)' started by Nick, Jun 2, 2014.

  1. Nick

    Nick Member

    Joined:
    May 13, 2014
    Messages:
    59
    As I mentioned in another thread, creating filters for Ad Muncher seemed so much easier. After scanning the source code, I'd just add a filter based on what I wanted to filter (Remove images/etc with URL, Block retrieval of URL, Remove scripts with text etc, etc) and it would just work 9 times out of 10. Very rarely I would have to delve a little deeper into the source code.

    I'm struggling a little with Adguard in this sense but I'm sure it will improve as my experience of the app grows. At the moment, I seem to be spending lots of time trying out filters which don't seem to have any effect which is kinda frustrating.

    Is it possible to filter objects in Adguard based on the following? If yes, could someone provide an example filter please?
    Remove links to URL
    Remove images/etc with URL
    Block retrieval of URL
    Remove scripts with text
    Remove tables with text
    Remove divs/spans with text

    Thanks :)
     
  2. Nameless

    Nameless Beta Tester

    Joined:
    Mar 19, 2014
    Messages:
    723
    Like most things it depends on the situation.

    Remove links to URL - Probably needs JS to do this
    Remove images/etc with URL - Single file: ||adguard.com/images/logo.png Folder: ||adguard.com/images/
    Block retrieval of URL Like above ||adguard.com
    Remove scripts with text - never done this myself check http://adguard.com/en/filterrules.html#htmlContentFilter or http://adguard.com/en/filterrules.html#javascriptInjection
    Remove tables with text - Table title, class, id name or you meanwithin the table?
    Remove divs/spans with text - ID/Class name? Or text within the div?

    im sure someone will correct me if they see something wrong, hell maybe im doing it wrong.
    You can also use https://adblockplus.org/en/filter-cheatsheet
     
  3. Nick

    Nick Member

    Joined:
    May 13, 2014
    Messages:
    59
    Thanks (again) Nameless...that should come in handy.

    As for the Remove tables/divs with text, yes I mean any text within the div itself although ID/Class, title etc are also good.

    I owe you some rep!
     
  4. avatar

    avatar Administrator Staff Member Administrator

    Joined:
    Oct 26, 2010
    Messages:
    12,244
    it's done automatically if this URL is blocked by standard URL-blocking rules.

    http://adguard.com/en/filterrules.html#baseRules

    Something like this:
    Code:
    $$script[tag-content="substring of the script"]
    $$div[tag-content="substring inside this div"]
    $$span[tag-content="substring inside this span"]
    $$table[tag-content="substring inside this table"]
    
    Also it's highly recommended to add attributes and length restrictions for divs and tables.
    max-length attribute of this rule allows removing of those elements only which length is lesser than "max-length" value.
    Code:
    $$div[tag-content="substring inside this div"][class="substring of class attribute"][max-length="4000"]
    $$table[tag-content="substring inside this table"][class="substring of class attribute"][max-length="8000"]
    
    More info here: http://adguard.com/en/filterrules.html#htmlContentFilter

    $$ rules do not work in our browser extensions.
     
  5. Nameless

    Nameless Beta Tester

    Joined:
    Mar 19, 2014
    Messages:
    723
    Never used the max length rule myself must give it ago. Thanks for a better explenation than mine too.
     
  6. avatar

    avatar Administrator Staff Member Administrator

    Joined:
    Oct 26, 2010
    Messages:
    12,244
    max-length is recommended to reduce chance for removing normal element.
    Adguard removes the biggest element suitable for the rule.
    That's why it's also good to use attributes restrictions.
     
  7. streetwolf

    streetwolf Beta Tester

    Joined:
    Apr 9, 2014
    Messages:
    500
    I've found that since coming from AM I see more popups/popovers/sliders etc. since I started using AG. What was AM doing to prevent these that AG isn't? Whatever AM was doing is AG going to duplicate it?
     
  8. Nameless

    Nameless Beta Tester

    Joined:
    Mar 19, 2014
    Messages:
    723
    Funny, im seeing less thanks to https support and anything i do see i want removing then gets added to my personal filter list, im guessing you have reported these popups/popovers/sliders etc s that maybe they get added to the lists?
     
  9. avatar

    avatar Administrator Staff Member Administrator

    Joined:
    Oct 26, 2010
    Messages:
    12,244
    It's better to report those. If we see something common in them - we'll add this pattern to our popup blocker extension.