-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to remove DOM element instead of hiding? #2252
Comments
Also quite similar issue is with The advert is hidden with the same filters I posted in first post. I can in fact show the non-ad element with EDIT:
|
What did you mean by manually removing the hidden element? Do you use some userscript / userscript extension? Or manually from the console, etc. ? |
He has explained why he won't do it already: #2211 (comment) |
Because the |
I think it doesn't really matter how I did that. Anyway I used to use my script for a long time. Back in the day most things was not possible to hide with adblock like addons. https://github.com/kasper93/userscripts/blob/master/UkryjWykopPoleca.user.js Recently I decided to port it to uBlock filters. And only three issues are remaining.
While I agree 2 and 3 might be out of the scope for uBlock. I think 1 is something we can discuss further, what do you think? Anyway don't consider this issue to be request for a feature, I simply want to signalize problems I encountered. Maybe we find some solutions :) |
If the "leftover space" is caused from the page deliberately making some part of it less than full-width or full-height ("pulling in", as opposed to having other content "push in"), then it's outside the scope of uBlock Origin. |
I already linked to the comment where @gorhill explains why he won't do it, but thanks for explaining DOM Manipulation 101 to us. |
@lewisje About your comment at https://adblockplus.org/forum/viewtopic.php?f=10&t=52321:
uBO does override inline styles with For example, uBO works fine with http://raymondhill.net/ublock/adbox.html -- where one element to hide uses |
@gorhill You said you wanted real world cases for removing elements - if you use uBlock on a video element, it just hides it while it keeps autoplaying in the background when you reload the page. I'd appreciate a way to force these elements out of the DOM instead of blocking an element thinking it was gone, and several days later getting jumpscared by invisible videos.. |
"Real world cases" means actual URLs where I can see for myself what can be done . |
Here's an example rule that kept autoplaying the video trailer on the site:
|
Blocking large media elements would work for that case. (which is even better than a cosmetic filter since the bandwidth is saved). |
Blocking large media elements does nothing here http://www.digitaltrends.com/mobile/phone-unlocking-guide-for-all-carriers/ or here http://www.pcworld.com/article/2691193/do-the-research-before-you-upgrade-your-ram.html |
Works for me. What your threshold for the size? It's 250 KB here. |
50 kB, only turning it on for individual websites. Both sites still load and autoplay the videos - http://i.imgur.com/Mm0UCxw.png. Using Firefox Developer Edition 54.0a2, 64bit. It also doesn't solve a case where you'd only want some videos to play, for example blocking twitch's mini player but not blocking the main player (you can do this in twitch settings, but just as an example). |
Ok the video is delivered differently on Firefox -- the page is using xhr requests. |
Here is another case: #2609. The page keep changing the |
Another case where hiding leave blank space. When node is removed layout is properly calculated. |
Any update on this? Another website where blocking media doesn't work, at least in FF - http://www.zdnet.com/article/max-memory-limits-for-64-bit-windows-7/ |
|
Blocking |
I don't see any ads on that page. |
Already fixed by the filter |
Nice example why removing elements instead oh hiding would be helpful. They use js to detect hidden state and override it which causes constantly dom changes. Or something like that. |
Try:
|
It would make sense these days to remove specific filtered elements from DOM instead of just hiding. Here is such an example. My filter: I cannot find any working solution for this specific problem. Cosmetic filters are not enough. |
That is a good pro-argument. |
I have found couple more examples where Video blocking via UBlock Orgin picker only hide the video the video is set on autoplay, and you can still hear the sound. major News sites in particularity incorporate this feature. Only way to get rid of video is to delete video element from the DOM http://www.cnn.com/2018/01/12/us/southern-california-mudslides/index.html mine filter http://fortune.com/video/2018/01/11/lyft-made-a-beer-that-comes-with-discounted-rides/ filter used there needs to be a function to delete elements from DOM instead of just adding |
Works with HTML filtering. |
Another case: uBlockOrigin/uAssets#7056. |
*** New procedural cosmetic operator: `:remove()` Related issue: - #2252 The purpose is to outright remove elements from the DOM tree. Since `:remove()` is an "action" operator, it must only be used as a trailing operator (just like the `:style()` operator). AdGuard's cosmetic filter syntax `{ remove: true; }` will be converted to uBO's `:remove()` operator internally. *** New procedural cosmetic operator: `:upward(...)` The purpose is to lookup an ancestor element. When used with an integer argument, it is synonym of `:nth-ancestor()`, which will be deprecated and which will no longer be supported once no longer used in mainstream filter lists. Filter lists maintainers must only use `:upward(int)` instead of `:nth-ancestor(int)` once the new operator become available in all stable releases of uBO. `:upward()` can also accept a CSS selector as argument, in which case the nearest ancestor which matches the CSS selector will be selected.
New procedural cosmetic operator: `:remove()` Related issue: - gorhill/uBlock#2252 The purpose is to outright remove elements from the DOM tree. Since `:remove()` is an "action" operator, it must only be used as a trailing operator (just like the `:style()` operator). AdGuard's cosmetic filter syntax `{ remove: true; }` will be converted to uBO's `:remove()` operator internally. *** New procedural cosmetic operator: `:upward(...)` The purpose is to lookup an ancestor element. When used with an integer argument, it is synonym of `:nth-ancestor()`, which will be deprecated and which will no longer be supported once no longer used in mainstream filter lists. Filter lists maintainers must only use `:upward(int)` instead of `:nth-ancestor(int)` once the new operator become available in all stable releases of uBO. `:upward()` can also accept a CSS selector as argument, in which case the nearest ancestor which matches the CSS selector will be selected. Co-authored-by: gorhill <585534+gorhill@users.noreply.github.com>
ktoś może zerknąć na: gorhill/uBlock#2252 gorhill/uBlock#2810 czy filtr nie zakłóca logiki = ja widzę tylko FB i X.
I know that it is canonical way to hide blocked elements. But sometimes it might be useful to actually remove DOM element. At least I don't have any other idea for the following testcase.
To reproduce those filters are needed.
Any ideas how we can work this out? I know leftovers are not that bad, but still would be nice if we could remove them :)
The text was updated successfully, but these errors were encountered: