ghostery / ghostery-extension

Ghostery Browser Extension for Firefox, Chrome, Opera, Edge and Safari
Mozilla Public License 2.0
1.37k stars 139 forks source link

Custom Filters exception tag not working as expected #1798

Open gortron opened 1 month ago

gortron commented 1 month ago

I noticed an issue with the Experimental Ad-Blocking Filters > Customer filters setting.

Environment:

Repro steps:

  1. Add ||youtube.com^$document as a custom filter
  2. Add @@||youtube.com/watch as a custom filter
  3. See DNR output which includes:
    {
    "id": 2,
    "priority": 101,
    "action": {
    "type": "block"
    },
    "condition": {
    "resourceTvpes": [
      "main frame"
    ],
    "urlFilter": "||youtube.com^"
    }
    }
    {
    "id": 2,
    "priority": 100001,
    "action": {
    "type": "allow"
    }, 
    "condition": {
    "urlFilter": "||youtube.com/watch"
    }
    }

Expected behavior: youtube.com/ home page is blocked, BUT youtube.com/watch?v=... videos are NOT blocked.

Actual behavior: youtube.com/ home page is blocked, AND youtube.com/watch?v=... videos ARE blocked.

Let me know if there are any other details I can provide for this issue.

chrmod commented 1 month ago

hi @gortron - thank you for reporting. Have looked into this issue and it looks like the block filter for youtube main page should be slightly different. Does this one works for you ||youtube.com/^$document?

gortron commented 3 weeks ago

Thanks @chrmod!

Doing so updates the DNR output to be:

{
  "id": 2,
  "priority": 101,
  "action": {
    "type": "block"
  },
  "condition": {
    "resourceTvpes": [
      "main frame"
    ],
    "urlFilter": "||youtube.com/^"
  }
}
{
  "id": 2,
  "priority": 100001,
  "action": {
    "type": "allow"
  }, 
  "condition": {
    "urlFilter": "||youtube.com/watch"
  }
}

And the Actual behavior: youtube.com/ home page AND youtube.com/watch?v=... videos are NOT blocked.

Generally, it seems like Exclusion tags are not working as expected.

chrmod commented 3 weeks ago

@GRadziejewski can you test this please? It works fine on my end.

@gortron when testing do you force-refresh the page? Youtube is using service workers for caching, so the page may load from cache and network filter wont be able to stop that.

GRadziejewski commented 2 weeks ago

@chrmod On my machines it looks like this:

||youtube.com^$document
@@||youtube.com/watch

macOS:

https://github.com/user-attachments/assets/a1fce53e-5d6a-413a-9dcd-d1416e7e8ab8

image

iOS (I had to wait a bit for it to work, but at the end check the results):

https://github.com/user-attachments/assets/470473bc-a9f4-4558-a3fc-e9fd48afaf49