Some fixes for Youtube polymer engine
< Valutazione su Youtube polymer engine fixes
Using UserScripts extension by [quoid](https://github.com/quoid/userscripts) to load userscript in Safari. Your script in Tampermonkey in Firefox works fine
What version of the script you are using?
Was it working with previous versions?
Try replacing following line of code in script:
sbo.getElementsByTagName ('div') [0].appendChild (unwrap (aa)); // created by YT scripts
with this:
try { sbo.getElementsByTagName ('div') [0].appendChild (unwrap (aa)); } catch (ex) { return; } // created by YT scripts
No error now but still nothing. I tossed in console.log(ex);console.log(sbo.getElementsByTagName ('div') [0]);
into the catch statement, and get this thrown exception in console output. So it seems the error is valid. Going to dive into the DOM and see if maybe the layout is different. What should the output of console.log(sbo.getElementsByTagName ('div') [0]);
be?
Thanx for debugging.
There must be some issue with appending the div
The issue is that in FF this div is created by YT scripts, not by me. So I rely on this behaviour, which is not instant.
Please, try removing following line of code (this may create multiple icons):
toolBar.insertBefore (mark, sb);
Also, can you try to open https://www.youtube.com/fix-settings (ison leads there)?
Getting the same undefined is not an object
error.
The link to the settings page opens and works👍
I guess the problem is that the div is not being created for some reason. If I force create the div by adding the following code before the line sbo.getElementsByTagName ('div') [0].appendChild (unwrap (aa));
, the error goes away. Though the layout of the icon becomes broken, it does work and is visible. I can now access the settings page as normal. Now why isn't polymer creating the div...
Code:
const tempdiv = document.createElement('div');//create the missing div
tempdiv.id = 'button';//assign the attributes that should be there
tempdiv.className = 'style-scope ytd-topbar-menu-button-renderer';
sbo.insertBefore (tempdiv, sbo.childNodes [0]);//insert it where it should be
Try to execute from web console following:
alert(document.createElement('ytd-topbar-menu-button-renderer').constructor)
Expected value... Try replacing in usersript
const sb = document.createElement ('ytd-topbar-menu-button-renderer');
with
const sb = unwrap (document).createElement ('ytd-topbar-menu-button-renderer');
Same as before hmm :( Looks like it's hard to say if it's polymer, Safari, or the userscript implementation of the userscript manager. Might open an issue on their repo to see their take
Could it be related to this issue?
Don't think so. run-at document-start
is not technically necessary for this userscript. Can you remove it and test, please?
Am having issues in Safari 17.5 on macOS 14.5, the settings icon does not appear. I get this error in the console. Anything I can plug in to help debug?