You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 --
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.
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.
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.
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
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()
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.
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.
Activity
uBlock-user commentedon May 7, 2020
setsets the value in early which is causing site breakage(document.bodygets set tonullas 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- commentedon May 7, 2020
@gorhill
gorhill commentedon May 7, 2020
I could prevent the context menu from being disable with:
However, the same approach did not work for the selection.
The reason is how the
aoprscriptlet is written and I think this can be overcome with the same fix I did here.Edit: actually
setwould also work using the same fix.uBlock-user commentedon May 7, 2020
doesn't it break anything ?
mapx- commentedon May 7, 2020
joysound.com##+js(aopr, document.body.oncontextmenu)does not work either, it breaks the "pretender" section (see the pic above)gorhill commentedon May 7, 2020
Oh I see, I need to investigate more then -- though it wouldn't hurt to ensure that
setandaoprare reentrant-resistant.gorhill commentedon May 7, 2020
Ok,
document.bodyis 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 commentedon May 7, 2020
https://github.com/NanoAdblocker/NanoFilters/blob/master/NanoFiltersSource/NanoResources.txt#L27 will work for this case.
gorhill commentedon 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-readystateoperator and thus all scriptlet operators which would follow would be executed after the target ready state is reached, without keeping duplicating code.uBlock-user commentedon May 7, 2020
That would be much better ofcourse and without having to resort to adding another scriptlet, also you can shorten
:match-readystateto just:readystateas we don't have any such existing operator.kulfoon commentedon 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-attrwe get___________________________________
:match-readystate==>:match-ready==>:match-rdyYuki2718 commentedon May 29, 2020
I guess found another case.
[NSFW]
https://www.j-live.tv/Yuki2718 commentedon Jul 25, 2021
2 remaining items
mapx- commentedon Apr 1, 2022
document.body.oncopy#12528
mapx- commentedon Apr 13, 2023
This issue should be fixed with the last improvement of
set-constantscriptletTested in firefox,
uBO 1.48.9b1(sometimes I need more than 1 refresh)
gorhill commentedon Apr 13, 2023
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.oncontextmenuisnull, but the event listener that was assigned to it is still executed by the browser.mapx- commentedon 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- commentedon Apr 15, 2023
@gorhill
adding this filter makes right click works in chrome on my end
joysound.com##+js(aeld, DOMContentLoaded, ready)gorhill commentedon Apr 15, 2023
Nice, so the extra parameter was indeed required to solve this issue.
gorhill commentedon Apr 16, 2023
@Yuki2718 Are you satisified that the following filters (using dev build) are taking care of the issue?
Yuki2718 commentedon Apr 19, 2023
Yes, they're working fine, thx!
[-]www.joysound.com[/-][+]joysound.com: nuisance[/+]gorhill commentedon 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:
endorinteractive: atDOMContentLoadedevent timeidleorcomplete: atloadevent timeAnything else will be "as soon as possible".
To be clear,
endandidleare documented in extensions API,interactiveandcompleteare documented in Web API. Using number would be more difficult to remember and thus inconvenient as filter list maintainer.stephenhawk8054 commentedon Apr 28, 2023
So for future filters that need
runAtparameter, we will need to write in JSON format, is it correct?gorhill commentedon Apr 28, 2023
Depends of the scriptlet. For
set-constant, the positional form is available; foraeld, only with the JSON notation.stephenhawk8054 commentedon Apr 28, 2023
Got it