Greasy Fork is available in English.

Youtube polymer engine fixes

Some fixes for Youtube polymer engine

< 脚本Youtube polymer engine fixes的反馈

评价:一般 - 脚本能用,但还有一些问题

§
发表于:2024-07-16
编辑于:2024-07-16

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?

§
发表于:2024-07-16

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

Bogudan作者
§
发表于:2024-07-16

What version of the script you are using?

Was it working with previous versions?

§
发表于:2024-07-16

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

§
发表于:2024-07-16

This is my header

Bogudan作者
§
发表于:2024-07-16
编辑于:2024-07-16

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
§
发表于:2024-07-16

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?

§
发表于:2024-07-16

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

§
发表于:2024-07-16

Output of console.log(sbo)

§
发表于:2024-07-16

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

Bogudan作者
§
发表于:2024-07-17

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

§
发表于:2024-07-17

Getting the same undefined is not an object error.

The link to the settings page opens and works👍

§
发表于:2024-07-17
编辑于:2024-07-17

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

Bogudan作者
§
发表于:2024-07-18

Try to execute from web console following:

alert(document.createElement('ytd-topbar-menu-button-renderer').constructor)
§
发表于:2024-07-18

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

Bogudan作者
§
发表于:2024-07-18

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');
§
发表于:2024-07-18

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

§
发表于:2024-07-18

Could it be related to this issue?

Bogudan作者
§
发表于:2024-07-19
编辑于:2024-07-19

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

发表回复

登录以发表回复。