Greasy Fork is available in English.

Youtube polymer engine fixes

Some fixes for Youtube polymer engine

< Feedback em Youtube polymer engine fixes

Avaliação: OK - script funciona, mas tem bugs

§
Publicado: 16/07/2024
Editado: 16/07/2024

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?

§
Publicado: 16/07/2024

Using UserScripts extension by [quoid](https://github.com/quoid/userscripts) to load userscript in Safari. Your script in Tampermonkey in Firefox works fine

BogudanAutor
§
Publicado: 16/07/2024

What version of the script you are using?

Was it working with previous versions?

§
Publicado: 16/07/2024

Latest v2.26.3. This is my first time with the script. I also tried it with an older version v2.21.1 but it made no difference, same errors and no settings icon appearing. I can see the css applying so it seems the script is working behind the scenes

§
Publicado: 16/07/2024

This is my header

BogudanAutor
§
Publicado: 16/07/2024
Editado: 16/07/2024

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
§
Publicado: 16/07/2024

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?

§
Publicado: 16/07/2024

Tried out just console.log(sbo.getElementsByTagName ('div') to grab the object itself and see the list. Seems the returned object is empty

§
Publicado: 16/07/2024

Output of console.log(sbo)

§
Publicado: 16/07/2024

Found the div, looks like there are no parent objects being inserted into it. There must be some issue with appending the div in the lines before sbo.getElementsByTagName ('div') [0].appendChild (unwrap (aa));

BogudanAutor
§
Publicado: 17/07/2024

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)?

§
Publicado: 17/07/2024

Getting the same undefined is not an object error.

The link to the settings page opens and works👍

§
Publicado: 17/07/2024
Editado: 17/07/2024

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

BogudanAutor
§
Publicado: 18/07/2024

Try to execute from web console following:

alert(document.createElement('ytd-topbar-menu-button-renderer').constructor)
§
Publicado: 18/07/2024

Output is function(){var d=HTMLElement.call(this)||this;d.is=b;if(heb===b)return d.isInert=!0,d;d.createElement();return d}

BogudanAutor
§
Publicado: 18/07/2024

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');
§
Publicado: 18/07/2024

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

§
Publicado: 18/07/2024

Could it be related to this issue?

BogudanAutor
§
Publicado: 19/07/2024
Editado: 19/07/2024

Don't think so. run-at document-start is not technically necessary for this userscript. Can you remove it and test, please?

Publicar resposta

Faça o login para publicar uma resposta.