avi12 / youtube-auto-hd

A simple browser extension for changing YouTube videos' quality based on FPS.
https://avi12.com/youtube-auto-hd
GNU General Public License v3.0
235 stars 28 forks source link

[Bug] Fails for 1080p videos where 1080p Premium is the highest option, I don't have premium #80

Closed SpaceSaver closed 1 year ago

SpaceSaver commented 1 year ago

Describe the bug

If you don't have premium and the closest match to your preferred quality is the new 1080p Premium options and you don't have premium you just constantly get the popup telling you to get premium since the extension is clicking it every time a video starts. image There's an image of the option. My preference in the extension is 4k. image This pops up every time I open a video as described. This is quite annoying and happens a lot on the homepage too for some reason. Additionally, the quality remains on auto because it selected an invalid choice for my account tier. Additionally it appears after every ad: image

How to reproduce

Visit a video where the 1080p Premium option is the closest option to your preferred playback quality in the extension. Example video. Also, don't have premium.

Expected behavior

It should ignore the 1080p Premium option unless the user has premium (maybe a toggle in the extension options for allowing premium video qualities?) and go with the free 1080p.

What browser(s) can you reproduce the issue on?

Chrome

What OS does it occur on?

Linux

What's the version you're running?

1.7.5

Additional context

This will probably work in other browsers, I've just only tested in Chrome on a Chromebook.

avi12 commented 1 year ago

What's this video link?

SpaceSaver commented 1 year ago

What's this video link?

Added it. https://www.youtube.com/watch?v=AYW06armuwQ

avi12 commented 1 year ago

Can you reproduce the issue in Incognito mode without being logged in? Or must you be logged in?

SpaceSaver commented 1 year ago

Can you reproduce the issue in Incognito mode without being logged in? Or must you be logged in?

It does not appear to show the "Premium" options in incognito. Only when signed in. Either as a legit option or as an ad if you don't have premium.

SpaceSaver commented 1 year ago

It seems that the "Premium" options are inconsistent and currently only show up on my main account.

avi12 commented 1 year ago

Interesting, I just tried logging into my second (non-premium) account from Incognito but I can't see the 1080p premium It might be an A/B test or something

SpaceSaver commented 1 year ago

Interesting, I just tried logging into my second (non-premium) account from Incognito but I can't see the 1080p premium It might be an A/B test or something

Another thing I can think of is that this is an account that has accepted multiple past premium free trials.

avi12 commented 1 year ago

Ok, since I can't see the 1080p premium, on the video page, when the video is playing, I need you to go to the Console (Ctrl+Shift+J), run the script and copy the output over here:

$(".ytp-settings-button").click();
$$(".ytp-menuitem")[$$(".ytp-menuitem").length - 1].click();
const t = setTimeout(() => {
  console.log(document.querySelector(".ytp-menuitem").parentElement.outerHTML);
});
SpaceSaver commented 1 year ago

Ok, since I can't see the 1080p premium, on the video page, when the video is playing, I need you to go to the Console (Ctrl+Shift+J), run the script and copy the output over here:

$(".ytp-settings-button").click();
$$(".ytp-menuitem")[$$(".ytp-menuitem").length - 1].click();
const t = setTimeout(() => {
  console.log(document.querySelector(".ytp-menuitem").parentElement.outerHTML);
});
<div class="ytp-panel-menu" role="menu" style="height: 217px;"><div class="ytp-menuitem" role="menuitemcheckbox" aria-checked="false" tabindex="0"><div class="ytp-menuitem-icon"><svg height="24" viewBox="0 0 24 24" width="24"><path d="M21 7v10H3V7h18m1-1H2v12h20V6zM11.5 2v3h1V2h-1zm1 17h-1v3h1v-3zM3.79 3 6 5.21l.71-.71L4.5 2.29 3.79 3zm2.92 16.5L6 18.79 3.79 21l.71.71 2.21-2.21zM19.5 2.29 17.29 4.5l.71.71L20.21 3l-.71-.71zm0 19.42.71-.71L18 18.79l-.71.71 2.21 2.21z" fill="white"></path></svg></div><div class="ytp-menuitem-label">Ambient mode</div><div class="ytp-menuitem-content"><div class="ytp-menuitem-toggle-checkbox"></div></div></div><div class="ytp-menuitem" role="menuitemcheckbox" aria-checked="true" tabindex="0"><div class="ytp-menuitem-icon"><svg height="24" viewBox="0 0 24 24" width="24"><path d="M17.5,7c1.93,0,3.5,1.57,3.5,3.5c0,1-0.53,4.5-0.85,6.5h-2.02l0.24-1.89l0.14-1.09l-1.1-0.03C15.5,13.94,14,12.4,14,10.5 C14,8.57,15.57,7,17.5,7             M6.5,7C8.43,7,10,8.57,10,10.5c0,1-0.53,4.5-0.85,6.5H7.13l0.24-1.89l0.14-1.09l-1.1-0.03 C4.5,13.94,3,12.4,3,10.5C3,8.57,4.57,7,6.5,7             M17.5,6C15.01,6,13,8.01,13,10.5c0,2.44,1.95,4.42,4.38,4.49L17,18h4c0,0,1-6,1-7.5 C22,8.01,19.99,6,17.5,6L17.5,6z             M6.5,6C4.01,6,2,8.01,2,10.5c0,2.44,1.95,4.42,4.38,4.49L6,18h4c0,0,1-6,1-7.5 C11,8.01,8.99,6,6.5,6L6.5,6z" fill="white"></path></svg></div><div class="ytp-menuitem-label">Annotations</div><div class="ytp-menuitem-content"><div class="ytp-menuitem-toggle-checkbox"></div></div></div><div class="ytp-menuitem" aria-haspopup="true" role="menuitem" tabindex="0"><div class="ytp-menuitem-icon"><svg height="24" viewBox="0 0 24 24" width="24"><path d="M10,8v8l6-4L10,8L10,8z M6.3,5L5.7,4.2C7.2,3,9,2.2,11,2l0.1,1C9.3,3.2,7.7,3.9,6.3,5z            M5,6.3L4.2,5.7C3,7.2,2.2,9,2,11 l1,.1C3.2,9.3,3.9,7.7,5,6.3z            M5,17.7c-1.1-1.4-1.8-3.1-2-4.8L2,13c0.2,2,1,3.8,2.2,5.4L5,17.7z            M11.1,21c-1.8-0.2-3.4-0.9-4.8-2 l-0.6,.8C7.2,21,9,21.8,11,22L11.1,21z            M22,12c0-5.2-3.9-9.4-9-10l-0.1,1c4.6,.5,8.1,4.3,8.1,9s-3.5,8.5-8.1,9l0.1,1 C18.2,21.5,22,17.2,22,12z" fill="white"></path></svg></div><div class="ytp-menuitem-label">Playback speed</div><div class="ytp-menuitem-content">Normal</div></div><div class="ytp-menuitem" aria-haspopup="true" role="menuitem" tabindex="0"><div class="ytp-menuitem-icon"><svg height="24" viewBox="0 0 24 24" width="24"><path d="M6,14v-4c0-0.55,.45-1,1-1h3c0.55,0,1,.45,1,1v1H9.5v-0.5h-2v3h2V13H11v1c0,.55-0.45,1-1,1H7C6.45,15,6,14.55,6,14z            M14,15h3c0.55,0,1-0.45,1-1v-1h-1.5v0.5h-2v-3h2V11H18v-1c0-0.55-0.45-1-1-1h-3c-0.55,0-1,.45-1,1v4C13,14.55,13.45,15,14,15z            M20,4H4v16h16V4 M21,3v18H3V3.01C3,3,3,3,3.01,3H21L21,3z" fill="white"></path></svg></div><div class="ytp-menuitem-label"><div><span>Subtitles/CC</span><span class="ytp-menuitem-label-count"> (1)</span></div></div><div class="ytp-menuitem-content">Off</div></div><div class="ytp-menuitem" aria-haspopup="true" role="menuitem" tabindex="0"><div class="ytp-menuitem-icon"><svg height="24" viewBox="0 0 24 24" width="24"><path d="M15,17h6v1h-6V17z M11,17H3v1h8v2h1v-2v-1v-2h-1V17z M14,8h1V6V5V3h-1v2H3v1h11V8z            M18,5v1h3V5H18z M6,14h1v-2v-1V9H6v2H3v1 h3V14z M10,12h11v-1H10V12z" fill="white"></path></svg></div><div class="ytp-menuitem-label">Quality</div><div class="ytp-menuitem-content"><div><span>Auto</span> <span class="ytp-menu-label-secondary">(1080p <sup class="ytp-swatch-color-white">HD</sup>)</span></div></div></div></div>
SpaceSaver commented 1 year ago

I think this was what u were looking for:

<div class="ytp-panel-menu" role="menu" style="height: 198px;">
  <div class="ytp-menuitem" tabindex="0" role="menuitemradio">
    <div class="ytp-menuitem-label">
      <div>
        <span>
          1080p Premium 
          <sup class="ytp-swatch-color-white">HD</sup>
          <div class="ytp-premium-label">Enhanced bitrate</div>
        </span>
      </div>
    </div>
  </div>
  <div class="ytp-menuitem" tabindex="0" role="menuitemradio">
    <div class="ytp-menuitem-label">
      <div>
        <span>1080p 
          <sup class="ytp-swatch-color-white">HD</sup>
        </span>
      </div>
    </div>
  </div>
  <div class="ytp-menuitem" tabindex="0" role="menuitemradio">
    <div class="ytp-menuitem-label">
      <div>
        <span>720p</span>
      </div>
    </div>
  </div>
  <div class="ytp-menuitem" tabindex="0" role="menuitemradio">
    <div class="ytp-menuitem-label">
      <div>
        <span>480p</span>
      </div>
    </div>
  </div>
  <div class="ytp-menuitem" tabindex="0" role="menuitemradio">
    <div class="ytp-menuitem-label">
      <div>
        <span>360p</span>
      </div>
    </div>
  </div>
  <div class="ytp-menuitem" tabindex="0" role="menuitemradio">
    <div class="ytp-menuitem-label">
      <div>
        <span>240p</span>
      </div>
    </div>
  </div>
  <div class="ytp-menuitem" tabindex="0" role="menuitemradio">
    <div class="ytp-menuitem-label">
      <div>
        <span>144p</span>
      </div>
    </div>
  </div>
  <div class="ytp-menuitem" tabindex="0" role="menuitemradio" aria-checked="true">
    <div class="ytp-menuitem-label">
      <div>
        <span>Auto</span>
      </div>
    </div>
  </div>
</div>
SpaceSaver commented 1 year ago

Now that was comedy

avi12 commented 1 year ago

Unfortunately, I won't start extensive debugging right now due to my time, but as soon as I have something, I'll let you know

SpaceSaver commented 1 year ago

Unfortunately, I won't start extensive debugging right now due to my time, but as soon as I have something, I'll let you know

Are you EDT as well?

EDIT: Read your Bio. image

avi12 commented 1 year ago

Let me know if this works: youtube-auto-hd-fps-1.7.6.zip This is how to install

SpaceSaver commented 1 year ago

Let me know if this works: youtube-auto-hd-fps-1.7.6.zip This is how to install

Nope, it still opens the premium popup and the quality is still set to auto. I uninstalled the one from the Webstore, and installed the zip.

avi12 commented 1 year ago

No need to uninstall anything, disabling the extension will have the same effect Okay, let's try something: youtube-auto-hd-fps-1.7.6.zip What output do you get? Right now logging qualitiesAvailable

SpaceSaver commented 1 year ago

No need to uninstall anything, disabling the extension will have the same effect Okay, let's try something: youtube-auto-hd-fps-1.7.6.zip What output do you get? Right now logging qualitiesAvailable

Still doesn't work, this is a screenshot of the log: image

SpaceSaver commented 1 year ago

If you set the extension to 1080p it's fine, it's only if you set it above 1080p.

avi12 commented 1 year ago

So qualitiesAvailable is set correctly, I expected index 0's to be value 0 Lemme log a different thing, iQuality: youtube-auto-hd-fps-1.7.6.zip

SpaceSaver commented 1 year ago

So qualitiesAvailable is set correctly, I expected index 0's to be value 0 Lemme log a different thing, iQuality: youtube-auto-hd-fps-1.7.6.zip

image

avi12 commented 1 year ago

Ok I realized what line I had to change, try out this version: youtube-auto-hd-fps-1.7.6.zip

SpaceSaver commented 1 year ago

Ok I realized what line I had to change, try out this version: youtube-auto-hd-fps-1.7.6.zip

It works!!!!

SpaceSaver commented 1 year ago

Now the only consideration is, what about Premium subscribers?

avi12 commented 1 year ago

I mean, I don't see this option at all and I've been a Premium subscriber in the past 3 years or so, so I assume I just get the enhanced version by default

SpaceSaver commented 1 year ago

I mean, I don't see this option at all and I've been a Premium subscriber in the past 3 years or so, so I assume I just get the enhanced version by default

My thinking is that it's not fully rolled out yet.

avi12 commented 1 year ago

I could technically add an additional check to whether the YouTube logo has "Premium", and if it doesn't then I apply this fallback algorithm

SpaceSaver commented 1 year ago

I could technically add an additional check to whether the YouTube logo has "Premium", and if it doesn't then I apply this fallback algorithm

Wouldn't it be two different URLs for the img src? Also, is there a variable that you could use that has the premium check?

avi12 commented 1 year ago

My web dev instinct is to rely on the DOM Plus, if I were to rely on a variable, I'd need to figure out a way to fetch the YouTube web page while applying the user cookie correctly

After comparing the two logos, I noticed that the YouTube logo text's element selector is g#youtube-red-paths while the normal logo is g#youtube-paths

SpaceSaver commented 1 year ago

They're probably referencing YouTube Red, that's a throw back

avi12 commented 1 year ago

I added the additional check, please ensure it's still working: youtube-auto-hd-fps-1.7.6.zip

SpaceSaver commented 1 year ago

I added the additional check, please ensure it's still working: youtube-auto-hd-fps-1.7.6.zip

Now it's showing the thing again.

avi12 commented 1 year ago

How about this one? youtube-auto-hd-fps-1.7.6.zip

SpaceSaver commented 1 year ago

How about this one? youtube-auto-hd-fps-1.7.6.zip

That works!

SpaceSaver commented 1 year ago

Thank you!

avi12 commented 1 year ago

You're welcome! Thanks for reporting the bug and assisting me in fixing it :)

avi12 commented 1 year ago

@SpaceSaver Hey pal, can you try sideloading this version and let me know if it works the same? youtube-auto-hd-fps-1.7.14.zip

SpaceSaver commented 1 year ago

@SpaceSaver Hey pal, can you try sideloading this version and let me know if it works the same? youtube-auto-hd-fps-1.7.14.zip

Yep!

avi12 commented 1 year ago

I pushed an update