Tinychat YouTube Playback Script

Opens a separate window for YouTube video playback on Tinychat.

As of 2023-05-07. See the latest version.

Author
meth0dz
Ratings
0 0 0
Version
1.33
Created
2023-05-07
Updated
2023-05-07
Size
4.71 KB
License
CC0-1.0
Applies to

This userscript enables users to play YouTube videos in a separate window while on Tinychat. The script is compatible with webpages that match the URL pattern https://tinychat.com/room/*. Key features of the script include the creation of a search bar for YouTube videos, a video button to play the selected video, and integration with the YouTube API for search functionality.

The script starts by defining a regular expression for matching YouTube URLs and a function to fetch the YouTube API key securely.
It then defines a function openVideoWindow to open a separate window for video playback, setting parameters such as window size and autoplay.
Custom CSS styles are added for the video button using GM_addStyle. A menu command is created to clear the stored video URL using GM_registerMenuCommand.

The script checks for a stored video URL and displays the video button if found. The createSearchBar function is defined to create the YouTube search bar, including: Creating a search input field and datalist element for search suggestions. Adding an event listener to fetch search results using the YouTube API when the input is updated. Creating a search button to play the selected video and store its URL. Adding the search bar to the document body. Finally, the search bar is created by invoking the createSearchBar function.

This userscript enhances the Tinychat experience by allowing users to conveniently search and play YouTube videos without leaving the Tinychat platform.

Edit the 'ADD_YOUR_API_KEY' with your own key on line 26

Get your API Key here: https://console.cloud.google.com


Step 1. Create New Project

Step 2. Go To Credentials Screen

Step 3. Click Create Credentials

Step 4. Click Enabled APIs

Step 5. Search & Choose YouTube V3 API

Step 6. Go to Credentials, Edit API Key, API Restrictions, Choose YouTube V3 API