AdguardTeam / AdguardFilters

AdGuard Content Blocking Filters
https://adguard.com/
GNU General Public License v3.0
2.93k stars 615 forks source link

Extend $replace syntax -- handling JSON objects #5828

Closed ameshkov closed 6 years ago

ameshkov commented 6 years ago

As you know, we have some issues with matching complex JSON files with regular expressions. It is always a pain to handle.

The question is what can we do to solve that?

What are the most frequent problems? Removing a JSON from an array of objects? I need more real-life examples of it.

Can it help if we use JSONPath ?

Alex-302 commented 6 years ago

Examples:

`"type": "direct"` ``` }, { "url": "https://yabs.yandex.ru/count/****", "title": "Земля в Подмосковье недорого", "body": "От 160 тыс. ****", "domain": "ydacha.ru", "age": "", "warning": "", "linkTail": "=*****", "image": ["//avatars.mds.yandex.net/get-direct/***", "164", "150"], "linkHead": "https://yabs.yandex.ru/count/***", "type": "direct", "size": 1 }, { ```
AdamWr commented 6 years ago

I do not know if it is the good example, but maybe - https://embed.tune.pk/play/6364616?autoplay=no&ssl=yes&inline=true In this case there are yellow "dots" on the player progress bar, and if you rewind video after that dot, movie stops, because it wants to display ads. It is annoying that you need to click to unpause video, so I wanted to block/avoid this. Only way I found to block this, it is use $replace rule here - https://tune.pk/api_public/playerConfigs/?api_key=777750fea4d3bd585bf47dc1873619fc&id=6364616 and remove overlayAd content (maybe there is easier way to block this, but I did not found it yet).

Content of playerConfigs ``` { "code": 200, "status": "success", "message": "success", "www": 5, "time_took": 0.018313884735107, "data": { "error": { "fineprint": "Visit Tune.pk<\/a>" }, "autoplay": "true", "container": "#player-container", "dpreffix": "pk", "details": { "videoid": 7209524, "video_id": 7209524, "country": "xxx", "duration": 6711, "date_added": "2017-07-19 01:22:02", "autoplay": "true", "owner_id": 647342, "uid": 647342, "sex": "male", "player": { "sources": [{ "file": "https:\/\/compute4.tune.pk\/files\/videos\/2017\/07\/19\/15004093224677f-720.mp4?h=B0eEl4dFspqIyhy5ggQMvg&ttl=1500785350", "bitrate": 720, "label": 720, "type": "mp4", "width": "100%", "height": "100%" }, { "file": "https:\/\/compute4.tune.pk\/files\/videos\/2017\/07\/19\/15004093224677f-360.mp4?h=pC-skPGyIilcRGFx5Phjdg&ttl=1500785350", "bitrate": 360, "label": 360, "type": "mp4", "width": "100%", "height": "100%", "default": true }, { "file": "https:\/\/compute4.tune.pk\/files\/videos\/2017\/07\/19\/15004093224677f-240.mp4?h=W799qsVeSWpVJ77yn2QD0w&ttl=1500785350", "bitrate": 240, "label": 240, "type": "mp4", "width": "100%", "height": "100%" }], "configurations": { "plugins": [] } }, "views": 23211, "live": false, "region": { "host": null, "filter": null }, "servers": { "application": "https:\/\/tune.pk", "related": "https:\/\/graph.tune.pk\/related", "html5": "https:\/\/player.tune.pk", "flash": "https:\/\/static2.tune.pk\/tune_player" }, "video": { "id": 7209524, "title": "DN 03", "category": 1, "link": "https:\/\/tune.pk\/video\/7209524\/dn-03", "list": false, "status": "Successful", "thumb": "https:\/\/thumbs2.tunefiles.com\/95,02f8b642d22eb834.jpg", "duration": 6711, "date_added": "2017-07-19 01:22:02", "views": 23211, "embed_code": "