AI intelligent summary
GPT
The article discusses blocking ads on the Monolith website using Adguard's custom rules. It notes that traditional CSS selector-based rules are ineffective due to inaccurate DOM element positioning. The proposed solution involves targeting the 'rel=nofollow' attribute present in ad 'a' tags. The Monolith website has numerous ads in headers, footers, articles, and comments, which the author aims to block.
This article discusses how to use Adguard's custom rules to block ads on the Dreamlite website. Since the ads of The dom element cannot be accurately positioned and Adguard Plugin Generated css selector based interception rules It doesn't work. , proposing a new approach: using the fact that the a tags in advertisements all have a fixed attribute in them rel value is nofollow to perform ad blocking.
1. Status of advertisements on the Mengli website
There are a lot of advertisements on the Monolithic website, such as larger advertisements in the header and footer of the website, in the beginning and end parts of the articles, and in the comments section, which I have decided to block for a variety of reasons
Don't get hung up on why you're blocking, if you're hung up on that then why are you reading this article


2. Analysis of the problem
After opening the developer tools via F12, selecting the element reveals that the dom element of its advertisement cannot be accurately positioned and is A randomized class approach was taken


But analyzing its class style shows that in fact the also known as pseudorandomization Libyan Arab Jamahiriya Uncertain if it will change So. Regular class positioning element masking is not appropriate

Alongside this, there are also css selector-based blocking rules generated by the Adguard plugin, but as far as the It doesn't work as well as I've tried. Because The result is Highly bound to the DOM tree structure s, and because the DOM structure is different from page to page, and its The advertising structure is similar It can easily lead to Mistakenly killed on other pages The results generated by the Adguard plugin do not actually Not much optimization for ad blocking It's used. both Screening rules for non-universality , one is the ID of the article, and also a The previously mentioned randomly generated class

To avoid this, either the URL path itself in the secondary restrictions or through other means, but that would ultimately be too complex
3. Solutions
So it can only be intercepted in other ways, but it can be noted that the a tags in its ads all have the A fixed attribute rel value is nofollow

The nofollow link attribute was introduced by Google in 2005 to deal with spammy links used to trick the system. In general, the nofollow link attribute should be used for unnatural links and when the website owner does not want to be associated with the target URL of the link. Simply put, because this link is to the advertisement, it does not want this link to be indexed by the search engine, so his advertisement attributes have this attribute
So we can write the following rule for their ads
moeli-desu.com##div > a[rel="nofollow"]interpretation of rules
exist
moeli-desu.com domain name <div> Within the element, select the element with the rel The value of the attribute is nofollow (used form a nominal expression) <a> element with a mask (hide) operation.This rule will select
moeli-desu.com All of the domains under the <div> Elements with rel="nofollow" attribute <a> element and tries to block it out for filtering purposes.consultation
- Adblocking using webpage modification is not the best way, the most general and best way is still to carry out url interception. But according to my analysis of its Its ad url is not distinguishable from the normal image url. Targeted interception of specific images at most But that's even less of a sustainable solution.
primary reference
acceptable become a member Telegram's Little Warehouse of Seven Rows | Internet Memories | Blogs cap Seven lines Technical Exchange Group Find more tips oh 🥰 and also discuss various issues in the chat group ❓
Welcome to the Bottom comment section. Share your thoughts and experiences with Let's discuss and improve together!
- Author:Qi Xing
- URL:https://blog.qixing1217.top/article/adguard-custom-ad-blocking-rules-rel-nofollow-example-mengli
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!



