window.Twitch is not defined on the popout

I’m trying to develop an extension for my channel.

I’ve added <script src="https://extension-files.twitch.tv/helper/v1/twitch-ext.min.js"></script> to my panel.html head tag.

When I open it on my pc (localhost/panel.html), window.Twitch is defined, but window.Twitch.ext.viewer have all empty values (which is ok/expencted, because there’s no user logged).

But when I add the extension to my channel and open its popout window (https://www.twitch.tv/popout/channel/extensions/someid-0.0.1/panel), window.Twitch is simply not defined, even with twitch.ext.min.js being loaded just fine on the network tab.

I’m not sure this is a development-phase issue/limitation, but I need to get the logged user data to make my extension works as I want it to, that’s why I tried ‘testing’ it on the popout window… but that’s not helping me.

Any suggestion on how to proceed on this?

Thanks!

Working as expected here

I tested a live/released extension and one using localtest with github pages as the Testing base URI. tested on two channels

it’s not defined/callable in console or in your code?

Ok this is weird.

If I type “window.Twitch.ext” on the popout’s console, it comes as undefined (actually an error, because window.Twitch itself is undefined).

But if whatever code I already have on my panel.js tries to access window.Twitch.ext, it works just fine.

Since I always try to check stuff on the console before using them on code, it seems this is me not understading the scope of variables or ‘where’ they’re actually stored. Regardless, my problem is solved. Since I DO can access the data (just not on the console itself), I can do whatever I want now.

Thanks for the reply, @BarryCarlyon !

You did select the correct frame in the console?

image

In the popup window the shortest method is to right click and inspect your extension, this tells console to auto select the correct frame.

if you have “top” as highlighted then your console is talking to the wrong frame.

1 Like

Yep, that’s exactly it. I’m used to just hit f12 and starting ‘consoling’, lol. If I select the right frame, it all comes together.

Problem solved, thanks!

1 Like