Discussies » Ontwikkeling

youtube function undefined for GM

§
Geplaatst: 27-04-2019
Bijgewerkt: 27-04-2019

youtube function undefined for GM

In youtube video page with last Firefox i get undefined for: document.getElementById("movie_player").setVolume but i see it as function in web console. Why?

woxxomMod
§
Geplaatst: 27-04-2019

Userscripts run in a sandbox, which you can disable by adding @grant none in the header, but there are some things to consider, see https://stackoverflow.com/a/10828021 and other similar answers.

§
Geplaatst: 27-04-2019

I had already added @grant none in the header but also so it not work.

§
Geplaatst: 27-04-2019

// ==UserScript== // @name Youtube Test // @version 1 // @grant none // @author Test // @include https://www.youtube.com/* // ==/UserScript==

alert(typeof document.getElementsByTagName("ytd-player")[0].getPlayer);

§
Geplaatst: 27-04-2019

Greasemonkey changed what @grant none does in version 4. See https://www.greasespot.net/2017/09/greasemonkey-4-for-script-authors.html

§
Geplaatst: 27-04-2019

So can't I solve this problem?

§
Geplaatst: 30-04-2019

to solve the gm4 limit,you can try

  • use tampermonkey or other gm3 base script manager instead of greasemonkey4
  • inject your script into the document
  • use unsafeWindow.document instead of document (maybe)

but as youtube has CSP limit , it may only tampermonkey can run your script

Reactie plaatsen

Log in om antwoord te geven.