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

  • Tutorial
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 for unsubscribing from the posts of one of the authors.

geektimes.ru#?#li:-abp-has(a.user-info[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 verify this by entering a filter.geektimes.ru#?#imgIf at the same time all the pictures on the site disappear, the 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, it is necessary to replace the filter when writing domain.com##selectorto domain.com#?#selector(enter the domain name required). 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 itself. 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:

geektimes.ru#?#li:-abp-has(a.default-block__header-link[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)

geektimes.ru#?#li:-abp-has(a.inline-list__item-link[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.

Also popular now: