Skip to content
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

eBay Sponsored links. Shadow DOM #2297

Open
8 tasks done
JSCFORCE opened this issue Sep 27, 2022 · 59 comments
Open
8 tasks done

eBay Sponsored links. Shadow DOM #2297

JSCFORCE opened this issue Sep 27, 2022 · 59 comments

Comments

@JSCFORCE
Copy link

JSCFORCE commented Sep 27, 2022

Prerequisites

  • I verified that this is not a filter list issue. Report any issues with filter lists or broken website functionality in the uAssets issue tracker.
  • This is not a support issue or a question. For any support, questions or help, visit /r/uBlockOrigin.
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue.
  • The issue is not present after disabling uBO in the browser.
  • I checked the documentation to understand that the issue I am reporting is not normal behavior.

I tried to reproduce the issue when...

  • uBO is the only extension.
  • uBO uses default lists and settings.
  • using a new, unmodified browser profile.

Description

eBay uses the shadow DOM to mark certain listings as SPONSORED.

we can't remove them since we can't target the shadow DOM.

Since sites don't get much bigger than this is is time to add support for a :shadow-root(...) operator?

A specific URL where the issue occurs.

https://www.ebay.com/sch/i.html?_from=R40&_nkw=houses&_sacat=0

Steps to Reproduce

Any attempt to target or distinguish the sponsored listings from the normal ones fail.

Expected behavior

Normally removing an ad would be a snap but not when the CSS is hidden from us.

Actual behavior

Can't remove the sponsored ads with uBlock origin in its current form.

uBO version

1.44.4

Browser name and version

Vivaldi 5.4.2753.51

Operating System and version

Windows 10.0.19044.2006

@gwarser
Copy link

gwarser commented Sep 28, 2022

Can you capture DOM tree with this shadow element? I don't see them in Firefox and Chrome. Only "Sponsored" text in every list entry, but hidden in non-sponsored offers.

@mapx-
Copy link
Contributor

mapx- commented Sep 28, 2022

image

@peace2000
Copy link
Member

peace2000 commented Sep 28, 2022

Also another major service, Facebook has started to use shadow dom: #2280

image

Text "Sponsoroitu" means "Sponsored" in English. Filters can't identify sponsored posts anymore on Facebook.

@krystian3w
Copy link

krystian3w commented Oct 3, 2022

Also I don't found active shadow dom at eBay.

Strange is that page fastly dorpped use span:first-line - maybe script often change method to show text "sponsored".

@JSCFORCE
Copy link
Author

JSCFORCE commented Oct 3, 2022

Also I don't found active shadow dom at eBay.

Strange is that page fastly dorpped use span:first-line - maybe script often change method to show text "sponsored".

eBay is definitely still using shadow DOM.

@krystian3w
Copy link

krystian3w commented Oct 3, 2022

≈30 day ago used :first-line but AdGuard and uBo still don't added this to stable and IMO ABP don't added filter to anti-cv project to these fastly rewrite page.

When they detect adding it in the "beta" they can become a page similar to "soft98.ir".

@ethan-xd
Copy link

ethan-xd commented Oct 9, 2022

I have a filter that blocks Facebook ads, however the attributes are removed by Facebook. Yet another example as to why we need a straight up :remove() filter. Facebook can't fuck with what's not there anymore.

@JSCFORCE
Copy link
Author

JSCFORCE commented Oct 9, 2022

I have a filter that blocks Facebook ads, however the attributes are removed by Facebook. Yet another example as to why we need a straight up :remove() filter. Facebook can't fuck with what's not there anymore.

:remove() is already supported.

@krystian3w
Copy link

krystian3w commented Oct 9, 2022

https://github.com/gorhill/uBlock/releases/tag/1.26.0

or this no works on shadow DOM?


Or we misunderstood "straight up" as "no implemented at all".

@ethan-xd
Copy link

I have a filter that blocks Facebook ads, however the attributes are removed by Facebook. Yet another example as to why we need a straight up :remove() filter. Facebook can't fuck with what's not there anymore.

:remove() is already supported.

?? What??? I looked over for documentation and couldn't find it, I could only find issues saying that it wouldn't be added. Oh well. lol

@mapx-
Copy link
Contributor

mapx- commented Oct 13, 2022

@ethan-xd
Copy link

I don't get how I couldn't find this, I looked for like half an hour. Okay, thank you everyone for letting me know.

@gwarser
Copy link

gwarser commented Oct 22, 2022

For me, this span:

<span aria-hidden="true"><wbr>Sponsored</span>

when width is set by var(...) to ~58px (as reported by getComputedStyle, it's 98% in the variable), then "Sponsored" is hidden, but when is set to ~59px, it's shown.

No shadows in Chrome or Firefox.

@krystian3w
Copy link

krystian3w commented Oct 22, 2022

But :matches-css(display: inline) e.g. with has-text works?

@gwarser

This comment was marked as outdated.

@JSCFORCE
Copy link
Author

JSCFORCE commented Oct 23, 2022

This works on Chrome and Firefox:

www.ebay.com##.clearfix.s-item__wrapper span[aria-hidden="true"]:matches-css(height: 20px):upward(.clearfix.s-item__wrapper):remove()

The following filter is a little better, removes some whitespace your filter leaves behind.

www.ebay.com##.clearfix.s-item__wrapper span[aria-hidden="true"]:matches-css(height: 20px):upward(li.s-item):remove()

but still we need a shadow root operator as soon as possible since this filter is very fragile.

I hope gorhill can get to this as soon as he has a free moment.

@JSCFORCE
Copy link
Author

The above filter is no longer valid.

@JSCFORCE
Copy link
Author

JSCFORCE commented Nov 2, 2022

Any update?

@gwarser

This comment was marked as outdated.

@krystian3w
Copy link

This is maximum of move: -7556482px?

@gwarser
Copy link

gwarser commented Nov 2, 2022

Ah, no, just random, you can try simply hiding or removing - this part was left from my other attempts.

@fyrefyre
Copy link

fyrefyre commented Nov 2, 2022

!#if env_firefox
www.ebay.com##li.s-item span[aria-hidden="true"]:matches-css(width: /58\.|62px/):upward(li.s-item):style(position:absolute!important;left:-7556482px!important;)
!#endif
!#if env_chromium
www.ebay.com##li.s-item span[aria-hidden="true"]:matches-css(width: /59\./):upward(li.s-item):style(position:absolute!important;left:-7556482px!important;)
!#endif

?

Chrome, it's a bit hit or miss. Occasionally it removes just Sponsored. Other times it doesn't remove any. And then other times, it removes everything like:

image

@JSCFORCE
Copy link
Author

JSCFORCE commented Nov 3, 2022

Yeah that new filter break this page with chrome.
https://www.ebay.com/sch/i.html?_from=R40&_nkw=knives

Works or breaks it randomly.,..

None of these are good enough, we just don't have the proper tool to address this issue.

@krystian3w
Copy link

Maybe filter works good with GNU/Linux fonts.

@gwarser
Copy link

gwarser commented Nov 3, 2022

You can try setting font-face and fixed size for this element. Even reset some values by https://developer.mozilla.org/en-US/docs/Web/CSS/unset#see_also


Maybe filter works good with GNU/Linux fonts.

Does not work on second page of the results :)

@krystian3w
Copy link

Modern browsers added https://developer.mozilla.org/en-US/docs/Web/CSS/revert when unset does not exist

@JSCFORCE
Copy link
Author

JSCFORCE commented Dec 5, 2022

Does anyone have any update on this issue? I am absolutely sick of seeing ads on ebay. We need a proper and permanent solution to this!!!

@JSCFORCE
Copy link
Author

JSCFORCE commented Dec 6, 2022 via email

@liamengland1
Copy link

liamengland1 commented Dec 6, 2022

@JSCFORCE try these

ebay.com##li.s-item:has(.s-item__detail:nth-last-of-type(1):has(>span>span>span[aria-hidden="true"]:matches-css(width:/5[89]\.[0-9]+/):matches-css(border-right-width:/0\./):not(:matches-css(width:/5[0-7]\.[0-9]+/):matches-css(border-right-width:/1\./)):has(wbr+span))):remove()
!ebay.com##li.s-item:has(.s-item__detail:nth-last-of-type(1):has(>span>span>span[aria-hidden="true"]:matches-css(width:/5[89]\.[0-9]+/):matches-css(border-right-width:/1\./):not(:matches-css(width:/5[0-7]\.[0-9]+/):matches-css(border-right-width:/0\./)):has(wbr+span))):remove()

Ebay employees are likely watching this thread though

@gorhill
Copy link
Member

gorhill commented Dec 6, 2022

I will gladly pay you 100 dollars right now for a proper solution.

Clearly I am not doing this for money, so I suggest you fork and contract another developer.

@JSCFORCE
Copy link
Author

JSCFORCE commented Dec 6, 2022

@gorhill

I was trying to have a conversation. I am desperate and was simply responding to your original comment in the only way I know how. i.e. literally.

@krystian3w
Copy link

krystian3w commented Dec 6, 2022

Github no support direct reply to specific comment in issue - discussion does because is similar to reddit.

But notification on reddit works better than gerneric in any Github discussion.

Shadow root/dom won't escape us anyway as msn already applies it to every embedded object on the homepage #2215 #2252 #2346.

It is enough that the advertising code escapes the possibility of aost.

@uBlock-user
Copy link
Contributor

uBlock-user commented Jan 19, 2023

www.ebay.com##.clearfix.s-item__wrapper span[aria-hidden="true"]:matches-css(height: 20px):upward(li.s-item):remove()

:remove() doesn't work on elements inside shadowRoot.

@mapx-
Copy link
Contributor

mapx- commented Jan 19, 2023

@gwarser
Copy link

gwarser commented Jan 19, 2023

:remove() doesn't work on elements inside shadowRoot.

Still no shadows on my side.

Add a scriptlet to inject stylesheet into shadow DOM

But specific filters work in uBO. ?

@uBlock-user
Copy link
Contributor

Still no shadows on my side.

I was speaking about my experience with shadowRoot, not specific to ebay here.

@krystian3w
Copy link

krystian3w commented Jan 19, 2023

I can hide borders on MSN.com with generic filter on opened shadow DOM/root:

##msft-article-card[class=""]

So scriptlet unlock use long CSS path or for only closed shadow DOM/root?

@pavelmalik
Copy link

Any update on this? I've been using Stylus with approach , but obviously removing the nodes from the tree would be preferable

abp-filters/abp-filters-anti-cv#946 (comment)

@gwarser
Copy link

gwarser commented Jan 20, 2023

@pavelmalik

ebay.com##.s-item__detail--primary:last-child *:style(font-weight: 900 !important;color: red !important;font-size: 220px;line-height: 1.15;)
ebay.com##.s-item__detail--primary:last-child > * > *:style(bottom: 1em !important;left: 0px !important;)
ebay.com##.s-item__detail--primary:last-child > * > * > * > *::before:style(content: "████";)

Does not work.

@krystian3w
Copy link

krystian3w commented Jan 20, 2023

Works under body: https://user-images.githubusercontent.com/35370833/213710303-98c84f4f-13be-407f-be52-a4e289583bb7.png

Maybe glitch in tabs.insertCSS() (scripting.insertCSS()).

@pavelmalik
Copy link

pavelmalik commented Jan 20, 2023

The actual one I'm using

@-moz-document url-prefix("https://www.ebay.com/") {
 .s-item__detail--primary:last-child * {

        font-weight: 900 !important;

        color: #fff0 !important;

        font-size: 220px;

        line-height: 1.1;

    }

    .s-item__detail--primary:last-child > * > * {

        bottom: 1em !important;

        left: 0px !important;

    }.s-item__detail--primary:last-child > * > * > * > *:before {

        content: "█████";

    }
}

Screen Shot 2023-01-20 at 8 51 25 AM

@gwarser
Copy link

gwarser commented Jan 20, 2023

Works under body

And other entries down below? The whole page is marked red for me.

The actual one I'm using

This one looks OK

ebay.com##.s-item__detail--primary:last-child *:style(font-weight: 900 !important;color: #fff0 !important;font-size: 220px;line-height: 1.1;)
ebay.com##.s-item__detail--primary:last-child > * > *:style(bottom: 1em !important;left: 0px !important;)
ebay.com##.s-item__detail--primary:last-child > * > * > * > *::before:style(content: "█████";)

@liamengland1
Copy link

this filter also works :P

ebay.com##li.s-item:has(.s-item__detail:nth-last-of-type(1):has(>span>span>span[aria-hidden="true"]:matches-css(width:/5[89]\.[0-9]+/):matches-css(border-right-width:/0\./):not(:matches-css(width:/5[0-7]\.[0-9]+/):matches-css(border-right-width:/1\./)):has(wbr+span))):not(:has(symbol)):remove()

@JSCFORCE
Copy link
Author

this filter also works :P

ebay.com##li.s-item:has(.s-item__detail:nth-last-of-type(1):has(>span>span>span[aria-hidden="true"]:matches-css(width:/5[89]\.[0-9]+/):matches-css(border-right-width:/0\./):not(:matches-css(width:/5[0-7]\.[0-9]+/):matches-css(border-right-width:/1\./)):has(wbr+span))):not(:has(symbol)):remove()

That filter does not work for me.

@liamengland1
Copy link

That filter does not work for me.

Sorry that it didn't work for you, it worked for me as you can see in this video. It's possible (likely?) that eBay slightly varies the DOM and CSS values so that this filter is not consistently effective.

ebay.mp4

@krystian3w
Copy link

But we use 1 line = 1 product.

@stephenhawk8054
Copy link
Member

stephenhawk8054 commented Feb 10, 2023

I see that in the href of sponsored product, the length of the end characters after %3A are shorter than normal products.

Can anyone test

www.ebay.com##li.s-item a.s-item__link[href]:matches-attr(href="/%3A\w{12}(&.+)?$/"):upward(li.s-item)

?

If {12} doesn't work, try {11,13}

@JSCFORCE
Copy link
Author

JSCFORCE commented Feb 10, 2023

I see that in the href of sponsored product, the length of the end characters after %3A are shorter than normal products.

Can anyone test

www.ebay.com##li.s-item a.s-item__link[href]:matches-attr(href="/%3A[a-zA-Z0-9]{11,13}$/"):upward(li.s-item)

?

Appears to be working.

https://www.ebay.com/sch/i.html?_from=R40&_nkw=ti-84+plus+ce

@krystian3w
Copy link

But how long?

@JSCFORCE
Copy link
Author

JSCFORCE commented Feb 12, 2023

@stephenhawk8054
Copy link
Member

stephenhawk8054 commented Feb 12, 2023

doesn't work here: https://www.ebay.com/sch/i.html?_from=R40&_nkw=ti-85&_sacat=0&rt=nc&LH_ItemCondition=3

sigh, what a mess.

It's because of the &LH_ItemCondition=3 at the end.

Test

www.ebay.com##li.s-item a.s-item__link[href]:matches-attr(href="/%3A\w{12}(&.+)?$/"):upward(li.s-item)

This takes care most of the sponsored products except few products at the top in some searches for me.


@gwarser idea works for me too

www.ebay.com##li.s-item .s-item__detail--primary span[role="text"] > span:matches-css(width: /59\.[5-9]/):upward(li.s-item):remove()

But at this point, it just depends on each person's DOM.

@MasterKia
Copy link
Member

Can this help?
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/dom/openOrClosedShadowRoot

@krystian3w

This comment was marked as spam.

@rileyvel
Copy link

rileyvel commented Nov 3, 2023

None of the above still works after eBay's updates. However, window.find can be used to infiltrate closed shadow DOMs - see https://book.hacktricks.xyz/pentesting-web/xss-cross-site-scripting/shadow-dom

I created a proof-of-concept that can be used as a userscript to remove eBay sponsored search results: https://gist.github.com/rileyvel/7162ed1049420e68c0913e52d220366b
Works on Chromium and Firefox, but not Safari.

Maybe ublock origin can use this to enforce :has-text filters globally?
Otherwise, filter lists can be asked to provide selectors of elements expected to host closed shadow roots (in eBay's case, span.s-item__sep > div). chrome.dom.openOrClosedShadowRoot can then be used to create "portals" between the light DOM and shadow DOM, and cosmetic filters can pass right through.

@JSCFORCE
Copy link
Author

JSCFORCE commented Nov 3, 2023

Amazing! Thank you for your detective work and making the script. I can confirm it does indeed work.

I would like to subscribe to your newsletter sir!

:)

@gorhill
Copy link
Member

gorhill commented Apr 15, 2024

Please evaluate whether issue can be closed with gorhill/uBlock@52b46eb.

@krystian3w
Copy link

They can do the creating shadow DOM-s/roots (as childs) in a loop to avoid single exposure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests