Writing Adblock Plus filters Introduction to Adblock Plus filters Basic filter rules Defining exception rules Matching at beginning/end of an address Marking separator characters Comments Special comments Advanced features Specifying filter options Using regular expressions Element hiding Basic rules Limiting rules to certain domains Attribute selectors Advanced selectors Exception rules Simplified element hiding syntax Implementing a sitekey on the serverCurrent Adblock Plus versions allow you to "tweak" your filters in many different ways. This document explains the choices that you have and how they can be used.Disclaimer: All filter examples given here are really only examples and are not meant to be used.Introduction to Adblock Plus filtersThe options described in this section should be enough for users who have to create a filter occasionally.Basic filter rulesThe most trivial filter you can define is of course the address of banner you want to block. However, often this address changes every time you open a page. For example it could be http://example.com/ads/banner123.gif where 123 is a random number. Here blocking the complete address won't help you, you need a more general filter — like http://example.com/ads/banner*.gif. Or maybe even http://example.com/ads/*.Note: Make sure that you are not replacing too much by wildcards. The filter http://example.com/* will definitely block all banners but it will also block everything else from example.com that you still might want to see.Xác định quy định ngoại lệĐôi khi bạn sẽ nhận thấy rằng một trong các bộ lọc của bạn thường làm việc khá tốt khối trong một số trường hợp khối một cái gì đó mà nó không nên ngăn chặn. Bạn không muốn để loại bỏ bộ lọc này nhưng bạn vẫn không muốn nó sẽ trùng khớp trong trường hợp một trong những này.Đó là những gì quy định ngoại lệ là tốt cho — chúng cho phép bạn để xác định các trường hợp mà bộ lọc không nên được áp dụng. Ví dụ: nếu bạn không hài lòng với bộ lọc của bạn adv http://example.com/advice.html chặn, bạn có thể xác định một ngoại lệ quy tắc @@advice. Ngoại lệ quy định là không có khác nhau từ quy tắc lọc, bạn có thể sử dụng ký tự đại diện hoặc biểu thức thông thường. Bạn chỉ phải đứng trước chúng bằng Anh... để cho biết các quy tắc ngoại lệ.Ngoại lệ quy tắc có thể làm nhiều hơn nữa. Nếu quy tắc ngoại lệ bắt đầu với http:// hoặc https:// (tùy chọn với một ống trước khi nó) nó sẽ làm cho toàn bộ trang một ngoại lệ. Ví dụ, nếu quy tắc ngoại lệ của bạn @@ | http://example.com và bạn mở một số trang từ example.com — Adblock Plus sẽ được hoàn toàn vô hiệu hóa trên Trang này và không có gì sẽ bị chặn.Phù hợp với đầu/cuối của địa chỉAdblock Plus thường đối xử với mỗi bộ lọc như nếu nó có một ký tự đại diện tại của nó bắt đầu và kết thúc, ví dụ như có không phải là sự khác biệt giữa quảng cáo bộ lọc và * quảng cáo *. Trong khi đây là thường unproblematic, đôi khi bạn muốn có bộ lọc bạn đã xác định chỉ phù hợp với ở đầu hoặc cuối của một địa chỉ. Ví dụ: bạn có thể muốn chặn tất cả Flash, nhưng nếu bạn thêm bộ lọc swf http://example.com/swf/index.html địa chỉ cũng sẽ bị chặn.Các giải pháp cho vấn đề này: thêm một biểu tượng ống để các bộ lọc để hiển thị rằng không nên có chắc chắn cuối địa chỉ tại thời điểm này. Ví dụ: bộ lọc swf| sẽ chặn http://example.com/annoyingflash.swf nhưng không http://example.com/swf/index.html. Và bộ lọc | http://baddomain.example/ sẽ chặn http://baddomain.example/banner.gif nhưng không http://gooddomain.example/analyze?http: / / baddomain.example.Đôi khi ai muốn chặn http://example.com/banner.gif cũng như https://example.com/banner.gif và http://www.example.com/banner.gif. Điều này có thể đạt được bằng cách đặt hai ống biểu tượng ở phía trước của các bộ lọc mà làm cho chắc chắn phù hợp với bộ lọc đầu tên miền: ||example.com/banner.gif sẽ chặn tất cả các địa chỉ này trong khi không chặn http://badexample.com/banner.gif hoặc http://gooddomain.example/analyze?http://example.com/banner.gif (yêu cầu Adblock Plus 1.1 hoặc cao hơn).Đánh dấu phân cách nhân vậtThường, bạn cần phải chấp nhận bất kỳ ký tự phân tách trong một bộ lọc. Ví dụ, bạn có thể viết một bộ lọc chặn http://example.com/ và http://example.com:8000 / nhưng không http://example.com.ar/. Đây là biểu tượng ^ có thể được sử dụng như một giữ chỗ cho một ký tự phân tách duy nhất: http://example.com ^ (yêu cầu Adblock Plus 1.1 hoặc cao hơn).Separator character is anything but a letter, a digit, or one of the following: _ - . %. The end of the address is also accepted as separator. In the following example all separator characters are shown in red: http://example.com:8000/foo.bar?a=12&b=%D1%82%D0%B5%D1%81%D1%82. So this address can be blocked with the filter ^example.com^ or ^%D1%82%D0%B5%D1%81%D1%82^ or ^foo.bar^.CommentsAny rule that starts with an exclamation mark is considered a comment. It will still show up in the filter list but in grey instead of black. Adblock Plus will ignore this rule for actual blocking so it is safe to write there whatever you want. You can place a comment rule above a real filter to describe what it is doing. Or you can put a comment on top of your filter list stating your authorship (most filter list authors do that).Special commentsSpecial comments will only have an effect in downloaded filter lists, not in custom filters. They can set a number of parameters for the filter list: ! Homepage: http://example.com/ This comment determines which webpage should be linked as filter list homepage. ! Title: FooList This comment sets a fixed title for the filter list. If this comment is present the user will no longer be able to change the title. ! Expires: 5 days This comment sets the update interval for the filter list, the value can be given in days (e.g. 5 days) or hours (e.g. 8 hours). Any value between 1 hour and 14 days is possible. Note that the update will not necessarily happen after this time interval. The actual update time is slightly randomized and depends on some additional factors to reduce server load. ! Checksum: OaopkIiiAl77sSHk/VAWDA This comment makes sure that accidental corruption of the data won't result in broken filters. For example, some firewall software might modify the filter */adnetwork/* on download in an attempt to protect the user against ads. It will remove part of the filter so that Adblock Plus will only see the filter **. A checksum comment in the filter list protects against this scenario, any modifications will have the result that the checksum no longer matches and Adblock Plus will ignore the data. To calculate the checksum the following steps need to be performed: Remove the existing checksum comment if any. Encode filter list text using UTF-8 encoding. Convert all line breaks to Unix style (replace
by
if present). Remove empty lines (replace sequences of the
character by a single
character). Calculate the base64-encoded MD5 checksum of the text, remove trailing = characters if any. You can also have a look at the Python-based reference implementations to validate a checksum and to add a checksum to a file. ! Redirect: http://example.com/list.txt This comment indicates that the filter list has moved to a new download address. Adblock Plus will ignore any file contents beyond that comment and immediately try downloading from the new address. In case of success the address of the filter list will be updated in the settings. This comment is ignored if the new address is the same as the current address, meaning that it can be used to enforce the "canonical" address of the filter list. ! Version: 1234 This comment defines a numerical version of the filter list. This version number will be displayed in issue reports and can be used to verify that the report refers to the current version of the filter list.Advanced featuresThe features described in this section are usually used only by power users and filterlist creators. Feel free to skip it.Specifying filter optionsAdblock Plus allows you to specify a number of options to modify the behavior of a filter. You list these options separated with commas after a dollar sign ($) at the end of the filter, for example:*/ads/*$script,match-caseHere */ads/* is the actual filter and script and match-case are its options. Currently the following options are supported: Type options: determine which types of elements a filter can block (or whitelist in case of an exception rule). Multiple type options can be specified to indicate that the filter should be applied to several types of elements. Possible types are: script — external scripts loaded via HTML script tag image — regular images, typically loaded via HTML img tag stylesheet — external CSS stylesheet files object — content handled by browser plugins, e.g. Flash or Java xmlhttprequest — requests started by the XMLHttpRequest object object-subrequest — requests started plugins like Flash subdocument — embedded pages, usually included via HTML frames document — the page itself (only exception rules can be applied to the page) elemhide — for exception rules only, similar to document but only disables element hiding rules on the page rather than all filter rules (Adblock Plus 1.2 and higher required) other — types of requests not covered in the list above The type options background, xbl, ping and dtd are outdated and should no longer be used. Inverse type options: specify the element types the filter should not be applied to. Possible inverse type options: ~script, ~image, ~stylesheet, ~object, ~xmlhttprequest, ~object-subrequest, ~subdocument, ~document, ~elemhide, ~other Restriction to third-party/first-party requests: If the third-party option is specified, the filter is only applied to req
đang được dịch, vui lòng đợi..
