el1t / uBlock-Safari

uBlock Origin - An efficient blocker for Chromium, Firefox, and Safari. Fast and lean.
GNU General Public License v3.0
2.75k stars 97 forks source link

Having problems with network filters for background elements on some pages #33

Open ptkovsky opened 7 years ago

ptkovsky commented 7 years ago

So basically trying to block background ads on example sites doesn't work. When you add a network filter it doesn't seem to apply. I have seen similar problems on sites like 3dnews.ru where the new background sometimes doesn't like to be hidden till some time. I have observed this issues in the last few months for sure and I am fully aware that this does look like an Apple sort of API issue, but decided to describe it anyway so that maybe it can be resolved somehow in the future.

URLs:

ko.com.ua gameinside.ua

Screenshot:

Just open the site and see the big background ad. This seems like a common practice nowadays. screen shot 2017-03-10 at 3 50 24 pm

Steps for anyone to reproduce the issue:

  1. Open the above-mentioned urls.
  2. Try to hide the annoying colorful background: right click on any part of the page, click Block element in the appearing context menu.
  3. Click another time so the cursor will look like a crosshair.
  4. Click another time somewhere on the background so it registers that you want to block it and so the Preview panel appears in the lower right corner of your screen if you move your cursor there.
  5. Click Preview and click on the proposed network filter so you can see the desired result when the background seems to be hidden and click Create after.
  6. Background now appears to be hidden and the network filter seems to be applied and working.
  7. Now reload the page and see that the annoying background is back. Filtering fails.

Configuration:

Settings seem to be almost default. Just tried installing Opera or using Chrome with the same configuration and it correctly hides the background in the above-mentioned cases.

Safari version is 10.0.3 uBlock Origin version is 1.11.3b1 MacOS version is 10.12.3

Filters:

They look like mostly default ones plus the BitBlock and RU AdList. Custom filters were created in case of this example and do look like this: ||ko.com.ua/sites/all/themes/ko/i/OKI_KO_branding.jpg$image

gorhill commented 7 years ago

I could reproduce with Chromium 56. However, the reason was that the image had been cached by the browser in its memory-based cache (a very short term cache, as opposed to the disk-based cache), which caused the network request to not be fired, and as a consquence to not go through the webRequest API. The workaround is to force a hard reload by pressing shift while clicking the reload button.

Possibly a similar situation with Safari?

ptkovsky commented 7 years ago

Alright, the famous Safari caching mechanics and all the latest battery life buzzing in the tech press. Thanks for reminding us about that interesting feature. Could indeed be the case here. However, Shift+clicking refresh button does nothing in my case. Why does it cache only some of the backgrounds and other ones get filtered just fine? Not like I only visit the aforementioned sites, but I did notice the issue on them so gave it as a particular example. In fact this sites are more like the least visited.

el1t commented 7 years ago

Unfortunately, I think the issue is with Safari's extension API—for whatever reason beforeload isn't called for url() requests inside stylesheets... a pretty serious omission. Not sure if there's a viable workaround.