AdguardTeam / FiltersCompiler

A tool that compiles & validates filters
GNU Lesser General Public License v3.0
52 stars 12 forks source link

Add an opportunity to add JS rules without increasing a trust level for third-party lists #202

Closed slavaleleka closed 8 months ago

slavaleleka commented 9 months ago

e.g. template.txt:

!
@include "https://raw.githubusercontent.com/List-KR/List-KR/master/filter-AdGuard.txt" /exclude="../../exclusions.txt"
! Javascript rules
[tv.nate.com#%#AG_onLoad(()](http://tv.nate.com/#%#AG_onLoad(()) => { var BuildObs, PlayerObs; let PlayerCall = (mutationList, observer) => { mutationList.forEach((e) => { if (Array.from(e.target.classList).some((e) => { return e === "ntv-ad-playing" })) { player.trigger("adended"); PlayerObs.disconnect() }})}; let BuildCall = (mutationList, observer) => { mutationList.forEach((e) => { Array.from(e.addedNodes).filter((o) => { return o.id === "natePlayer" }).forEach((k) => { PlayerObs = new MutationObserver(PlayerCall); PlayerObs.observe(k, { attributes: true }); BuildObs.disconnect() })})}; BuildObs = new MutationObserver(BuildCall); BuildObs.observe(document.querySelector(".player-wrapper"), { childList: true }) })

currently trust level limitations are applied to all rules retrieved from template.txt files which may contain:

that’s why I assume it may be better to implement a new @inlude directive option which allow to ignore trust level limitations:

@include "<file to include>" /ignoreTrustLevel

where <file to include> is same origin file only.

so eventually it will look like template.txt:

!
@include "https://raw.githubusercontent.com/List-KR/List-KR/master/filter-AdGuard.txt" /exclude="../../exclusions.txt"
! 
@include "./additional-rules.txt" /ignoreTrustLevel

filter list directory structure:

filter_227_List-KR
├── additional-rules.txt   <-- new file for js rules
├── diff.txt
├── filter.txt
├── metadata.json
├── revision.json
└── template.txt