Need help with creating a scriptlet, again #2514
-
I tried writing a scriptlet to click a button whenever it shows up on Twitch. [snipped] The above script seemingly runs fine using the developer tools (Firefox 110), but I can't seem to make it work using uBlock Origin (1.47.3b1). Any possible reason(s) as to why? Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
uBO scriptlets cannot trigger any DOM events, such functionality is not implemented for security reasons. #2229 |
Beta Was this translation helpful? Give feedback.
-
replace You also need to add a filter - - |
Beta Was this translation helpful? Give feedback.
-
I think I figured it out. I realised that uBO probably want to inject scriptlets as soon as possible to a given page. This probably means that when the above scriptlet is executed, To fix this, I first observe the While exploring this, I also noticed that scriptlets seem to cannot have a blank line in it. I failed to find that being documented anywhere so might as well let any future reader know. Thank you for the help! |
Beta Was this translation helpful? Give feedback.
I think I figured it out.
I realised that uBO probably want to inject scriptlets as soon as possible to a given page. This probably means that when the above scriptlet is executed,
document.querySelector(".chat-input__buttons-container")
probably returnsnull
because the DOM node has not been loaded yet.To fix this, I first observe the
document
on whether the.chat-input__buttons-container
node that I'm looking for exists. Then, I disconnect that observer and reattach a new one on the node I'm targeting.While exploring this, I also noticed that scriptlets seem to cannot have a blank line in it. I failed to find that being documented anywhere so might as well let any future reader know.
T…