Import YouTube video broken on latest Chrome (Windows 10) with userscript

I have the following to YouTube importer user scripts (Tampermonkey v5.1.1) installed on latest Chrome (Version 128.0.6613.138 (Official Build) (64-bit)) and Firefox (130.0 64-bit) on Windows (Microsoft Windows [Version 10.0.19045.4894])

On Chrome the userscript is currently (don’t know when it stopped) not working

whereas on Firefox I still get the “Add to MusicBrainz” button

Can anybody confirm ?

I don’t know but maybe it’s because of Manifest v3 thing…
Tampermonkey recently migrated to MV3 for Chrome.

Where did you get that userscript?
Do you have any errors in the console (F12)?

I have to check for errors …
Got them from Guides/Userscripts - MusicBrainz Wiki

so for the link https://www.youtube.com/watch?v=z8Yos7RUpaU I get the following errors… any idea what’s going on here ?

1 Like

This document requires ‘TrustedSite’ assignment.

Uncaught EvalError: Refused to evaluate a string as JavaScript because this document requires ‘Trusted Site’ assignment.

Is it Import videos from YouTube (release) ver. 2024-04-29.1 or Import videos from YouTube (recording) ver. 2014-09-07?

Need to check tomorrow

When I started this topic … both YouTube userscripts were active.

When I enable just the “Import YouTube video as release” one I get:

and when i enable just the “Import YouTube video” I get

In both cases it’s not working under Chrome

When BOTH are enabled I get:

1 Like

There seems to be a workaround at Google Issue Tracker

But its beyond my skills to implement … injecting the following snippet inbetween the HEAD and HTML tags to resolve the issue.

<!DOCTYPE html>
<html>

<head>
  <base target="_top">
  <script src="https://unpkg.com/dompurify/dist/purify.min.js"></script>
</head>

<script>
  if (window.trustedTypes && trustedTypes.createPolicy) {
      trustedTypes.createPolicy('default', {
        createHTML: string => DOMPurify.sanitize(string, {RETURN_TRUSTED_TYPE: true})
      });
    }
</script>

<script src="https://code.jquery.com/jquery-3.7.1.js" integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4="
  crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"
  integrity="sha256-xLD7nhI62fcsEZK2/v8LsBcb4lG7dgULkuXoXB/j91c=" crossorigin="anonymous"></script>

<body>
  <span id='test'>hi</span>
</body>

<script>
  $(document).ready(function() {
    $("#test").html("<b>bye</b>");
});
</script>


</html>
1 Like

Hi! I made the “as release” version. I’m not a chrome user so I didn’t notice it.
I’ll try to see what’s wrong later.

1 Like

While you’re at it … could you change the button text to something which makes it clear that the youtube video will be imported “as release” ?

This would distinguish the button from the other (recording based) user userscript which right now uses the same text. Maybe also allow both scripts at the same time.

Right now when both are enabled the “import as recording” one wins. At least on Firefox it works like that.

Since the latest update there is a problem with the “Add as release” script. Depending how you enter some pages it sometimes hides the important youtube buttons and hamburger menu as can be seen here

whereas the good one has all the youtube buttons

The “Save” button is essential for me …

In the upper right corner there is the button from the “add as recording” script

Could these two be somehow merged ?

Argh. Why does it keeps breaking on other’s computers…

The import button as recording isn’t mine. I don’t have control of the code.

The release one is the one broken. From my testing it shouldn’t be able to overwrite the buttons but might be a platform specific bug… Or some spagetti code left over from me forking the recording userscript. I’ll try to rewrite the hooking script to remove the mess and it should get fixed hopefully.

As to merge it, I’m not sure. I’d love to merge it, but I also don’t want to just steal the idea for myself.