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
222 stars 26 forks source link

YouTube Auto HD + FPS

A browser extension that sets the quality of YouTube videos according to the user's preference, based on the video's FPS. Available for:

A screenshot from the extension's pop-up page

Made by avi12

Powered by Plasmo

Contact me

You can suggest a feature or report a bug

Known issue

Due to the way the browsers handle extensions, when an extension receives an update, content scripts in previously-open web pages cannot use the Storage API until the user reloads them, which means that if YTHD received an update and the user attempts to change a setting, he must reload the such pages for the settings to take effect

A semi working solution

To provide a smooth user experience, I decided to use the last settings that were fetched

Translating

You can translate the extension to your own language by filling this form Filling will grant you access to a Google Spreadsheet via email, in which you can contribute your translations

Requirements for setting up

Install Node.js and PNPM

Install dependencies

pnpm i

Start the dev server

Chromium browsers

pnpm dev

Firefox

pnpm build:firefox

Running

Chromium/Chrome

pnpm run-chromium

Chromium/Chrome RTL

pnpm run-chromium:rtl

Edge on Windows 10/11

pnpm run-edge:windows

Opera on Windows 10/11

As of September 30th, 2023, Opera 102's installer automatically sets itself as the default browser, and therefore I recommend installing it on a virtual machine like Windows Sandbox Of course, if you decide to go through this route, you'll need to build & pack every time you modify a script

pnpm run-opera:windows

Firefox

pnpm run-firefox

Phone/tablet

  1. Install Android Studio on your operating system
  2. Create an AVD (Android Virtual Device)
  3. Run the emulator:
    emulator @DEVICE_NAME
  4. I recommend creating a Google account specifically to be used with the emulator

    Chromium for Android testing

    1. Install Kiwi Browser
    2. First get the emulator ID:
      adb devices

      Then:

      • On Windows 10/11, you can run:
        set id=ID & pnpm build-pack:test-push
      • Otherwise, if you're using PowerShell, run:
        pnpm build-pack:test; `
        $zip = "chrome-mv3-prod.zip"; `
        $destAndroid = "/storage/emulated/0/TestYTHD/$zip"; `
        $ID = "emulator-####"; `
        adb -s $ID shell rm $destAndroid; `
        adb -s $ID push "build/$zip" $destAndroid;

        where you assign $ID with the emulator ID

    3. Side-load the extension on Kiwi Choose zip from storage
    4. Select the ZIP in the TestYTHD folder
    5. To reload, you must first remove the extension and then repeat steps 2-4
    6. To debug, enter chrome://inspect/#devices

Firefox for Android testing

  1. Install Firefox
  2. In the terminal:
     adb shell pm grant org.mozilla.firefox android.permission.READ_EXTERNAL_STORAGE
  3. In the app:
    1. Press ⋮ (menu button) → Settings → Enable "Remote debugging via USB"
    2. Get the emulator ID via
      adb devices
  4. Create 2 terminals
    • In the first one, run dev:firefox
    • In the second one, run
      pnpm run-firefox:android --android-device=ID

      where you replace ID with the emulator ID

  5. To reload:
    1. Modify a script
    2. Wait until the extension is re-added
    3. Reload the web page Notice that due to web-ext run using the same files that Plasmo uses to convert the development files into extension-usable script files, Plasmo might crash and so you'll have to restart it every time that you modify a script
  6. To debug:
    1. Open Firefox on your desktop
    2. In the terminal of run-firefox:android, find the remote Firefox debugger port (search "TCP port")
    3. Open about:debugging#/setup in Firefox
    4. Type in the text box: localhost:PORT
    5. In the left sidebar, next to localhost:PORT, click Connect and then click on that list item
    6. Under "Tabs" click Inspect

Sideloading onto your daily driver browser

Build & pack

pnpm build-pack

Build & pack for Firefox

pnpm build-pack:firefox

Contribution

Feel free to contribute! Keep in mind that the license I chose is GPL v3. If you want to fork, make sure to credit Avi and link to this repository.