New features of Habr: how to unsubscribe from users and advertising blogs

Many on Habré ask how to filter posts of individual authors and corporate blogs. More recently, this feature has appeared - though, this requires the latest version of the Adblock blocker.

For those who do not want to read further, just give the Adblock filter code to unsubscribe from the posts of one of the authors.[href*="username"]) 

True, it does not work in all browsers, and not in all cases. For those who are interested in how and when it works, please under the cat.

The possibility of such filtering appeared with the appearance in the new versions of Adblock the so-called CSS pseudo-selectors, which are not found in the usual CSS. They allow you to lock the parent element if any condition is met in the child element.

First, you need to make sure that your version of the browser and adblock support this feature. The new syntax works in Adblock Plus versions 1.13.3 and higher for Chrome and Opera. Also, from November 6, the opportunity appeared in Adblock Plus 3.0 for Firefox. But this is only true for new browsers, for example, in my Chrome 57 version there is such an option, but in Chrome 49 versions, which I usually use, the option is not supported.

You can check this by entering the filter If this all the pictures on the site disappear, new features are included. If nothing changes, it means that you need to be updated.

How pseudo-selectors work is described in detail here in the section “Extended CSS selectors”. There are also examples. To begin with, when writing a filter, you must replace with (you must enter the domain name). This syntax includes the pseudo-selector mechanism. The selector itself is written as :-abp-properties() or :-abp-has() For elements in parentheses, the same syntax is used as in the ad block. Pseudo-selector nesting is also supported.

Thus, to block the entire post, it is enough to find at least one characteristic field in it, for example, the href attribute with the name of the author, so that you can block the entire post.

Here, for example, blocking the li element, inside of which there is a link with the class default-block__header-link, which in turn refers to a URL with the word megapost:[href*="megapost"]) 

It should be remembered that such pseudo-selectors work rather slowly, since they are only imitations of non-existent properties in CSS, and slightly contradict the way browsers parse this CSS. It describes in detail why this happens. So the inclusion of such rules greatly slows down the loading of pages.

For those who have read the article to this place, an additional bonus: a recipe for unsubscribing from all advertising blogs of Giktams (although I do n’t recommend doing this: among the blogs you find extremely interesting, for example, the blog of the same Yandex)[href*="company"]) 

Now you can easily create your own filters — for example, by filtering articles by rating, number of views, or number of comments.

I hope that with the new Adblock feature, the struggle for readers will reach a new level - now companies will have to write high-quality posts, and not copy the advertising review from their sites.


All Articles