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

joysound.com: nuisance #7320

Closed
Yuki2718 opened this issue May 7, 2020 · 27 comments
Closed

joysound.com: nuisance #7320

Yuki2718 opened this issue May 7, 2020 · 27 comments

Comments

@Yuki2718
Copy link
Contributor

Yuki2718 commented May 7, 2020

URL(s) where the issue occurs

https://www.joysound.com/web/search/song/746956

Describe the issue

Annoyances: context menu, copy, and text-selection disabled

Screenshot(s)

joysound1

Versions

  • Browser/version: 1.8.90
  • uBlock Origin version: 1.26.0

Settings

  • Default + uBlock Annoyances

Notes

As style overriding didn't work, I added

joysound.com##+js(set, document.body.oncopy, null)
joysound.com##+js(set, document.body.onselectstart, null)
joysound.com##+js(set, document.body.oncontextmenu, null)

as set by https://www.joysound.com/web/feature/search/js/songdetail.min.js, then the page hid the lyrics:

joysound2

@uBlock-user
Copy link
Contributor

set sets the value in early which is causing site breakage(document.body gets set to null as per dev-tools). You will need an event based setter/getter scriptlet or do it manually by copy-pasting in the console after page-load --

document.body.oncontextmenu = document.body.onselectstart = document.body.oncopy = null;

@mapx-
Copy link
Contributor

mapx- commented May 7, 2020

@gorhill

@mapx- mapx- added the can't fix label May 7, 2020
@gorhill
Copy link
Member

gorhill commented May 7, 2020

I could prevent the context menu from being disable with:

joysound.com##+js(aopr, document.body.oncontextmenu)

However, the same approach did not work for the selection.

The reason is how the aopr scriptlet is written and I think this can be overcome with the same fix I did here.

Edit: actually set would also work using the same fix.

@uBlock-user
Copy link
Contributor

joysound.com##+js(aopr, document.body.oncontextmenu)

doesn't it break anything ?

@mapx-
Copy link
Contributor

mapx- commented May 7, 2020

joysound.com##+js(aopr, document.body.oncontextmenu) does not work either, it breaks the "pretender" section (see the pic above)

@gorhill
Copy link
Member

gorhill commented May 7, 2020

Oh I see, I need to investigate more then -- though it wouldn't hurt to ensure that set and aopr are reentrant-resistant.

@gorhill
Copy link
Member

gorhill commented May 7, 2020

Ok, document.body is special, though the scriptlet traps the property to detect when its value changes, the browser is modifying its value internally, bypassing the trap.

@uBlock-user
Copy link
Contributor

@gorhill
Copy link
Member

gorhill commented May 7, 2020

Right... This kind of lead me back to the idea of simple operators which can be chained, in such case it would be to merely add a match-readystate operator and thus all scriptlet operators which would follow would be executed after the target ready state is reached, without keeping duplicating code.

+js:match-readystate(/interactive|complete/):set-constant(document.body.oncontextmenu, null)

@uBlock-user
Copy link
Contributor

uBlock-user commented May 7, 2020

That would be much better ofcourse and without having to resort to adding another scriptlet, also you can shorten :match-readystate to just :readystate as we don't have any such existing operator.

@kulfoon
Copy link

kulfoon commented May 10, 2020

It seems gorhill likes to keep words match/watch as a first part of the name (matches-css, matches-css-before, matches-css-after, watch-attr) for procedural operators, perhaps that will applied to scriplets as well, so I'm curious, following this logic: :watch-attributes ==> :watch-attrs ==> :watch-attr
we get___________________________________:match-readystate ==> :match-ready ==> :match-rdy

@Yuki2718
Copy link
Contributor Author

I guess found another case.
[NSFW] https://www.j-live.tv/

@ghost

This comment has been minimized.

@Yuki2718

This comment has been minimized.

@ghost

This comment has been minimized.

@uBlockOrigin uBlockOrigin locked as off-topic and limited conversation to collaborators Jul 25, 2021
@mapx-
Copy link
Contributor

mapx- commented Apr 1, 2022

document.body.oncopy
#12528

@mapx-
Copy link
Contributor

mapx- commented Apr 13, 2023

This issue should be fixed with the last improvement of set-constant scriptlet

Add ability to defer set-constant execution
A new optional parameter has been added to `set-constant`
scriptlet: `runAt`, default to `0`.

 ..##+js(set, document.body.oncontextmenu, null, 2)

When the `runAt` parameter is present, uBO will take it into
account to possibly defer execution of `set-constant`:

- `runAt` not present: execute immediately
- `runAt` = 1: execute immediately
- `runAt` = 2: execute when document state is "interactive"
- `runAt` = 3: execute when document state is `"complete"

Tested in firefox, uBO 1.48.9b1

(sometimes I need more than 1 refresh)

joysound.com##+js(set, document.body.oncopy, null, 3)
joysound.com##+js(set, document.body.onselectstart, null, 3)
joysound.com##+js(set, document.body.oncontextmenu, null, 3)
joysound.com##body:style(-webkit-touch-callout: default !important; -webkit-user-select: text !important; -moz-user-select: text !important; -ms-user-select: text !important; user-select: text !important;)
joysound.com##style:has-text(@media print):remove()

@gorhill
Copy link
Member

gorhill commented Apr 13, 2023

This issue should be fixed with the last improvement of set-constant scriptlet

I used the case here to test but it didn't fix it on my side (at least in Chromium). There is this weird state in the DOM where document.body.oncontextmenu is null, but the event listener that was assigned to it is still executed by the browser.

@mapx-
Copy link
Contributor

mapx- commented Apr 13, 2023

maybe it's why even in firefox the right-click is still disabled but upon refreshing the page it will finally work

@mapx-
Copy link
Contributor

mapx- commented Apr 15, 2023

@gorhill

adding this filter makes right click works in chrome on my end

joysound.com##+js(aeld, DOMContentLoaded, ready)

@gorhill
Copy link
Member

gorhill commented Apr 15, 2023

Nice, so the extra parameter was indeed required to solve this issue.

@gorhill
Copy link
Member

gorhill commented Apr 16, 2023

@Yuki2718 Are you satisified that the following filters (using dev build) are taking care of the issue?

joysound.com##+js(set, document.body.oncopy, null, 3)
joysound.com##+js(set, document.body.onselectstart, null, 3)
joysound.com##+js(set, document.body.oncontextmenu, null, 3)
joysound.com##+js(aeld, DOMContentLoaded, ready)
joysound.com##body:style(user-select: unset !important)

@mapx- mapx- closed this as completed in 3fc9d4b Apr 19, 2023
@mapx- mapx- removed the can't fix label Apr 19, 2023
@Yuki2718
Copy link
Contributor Author

Yes, they're working fine, thx!

@MasterKia MasterKia changed the title www.joysound.com joysound.com: nuisance Apr 19, 2023
@gorhill
Copy link
Member

gorhill commented Apr 27, 2023

I am going to change the last parameter to make the purpose more clear, and to align the values with already existing documentation out there. So it will be:

  • end or interactive: at DOMContentLoaded event time
  • idle or complete: at load event time

Anything else will be "as soon as possible".


To be clear, end and idle are documented in extensions API, interactive and complete are documented in Web API. Using number would be more difficult to remember and thus inconvenient as filter list maintainer.

@stephenhawk8054
Copy link
Member

So for future filters that need runAt parameter, we will need to write in JSON format, is it correct?

@gorhill
Copy link
Member

gorhill commented Apr 28, 2023

Depends of the scriptlet. For set-constant, the positional form is available; for aeld, only with the JSON notation.

@stephenhawk8054
Copy link
Member

Got it

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

No branches or pull requests

7 participants
@gorhill @mapx- @uBlock-user @kulfoon @Yuki2718 @stephenhawk8054 and others