Last active
October 30, 2025 23:06
-
-
Save jhauga/c21475673dee3816b6ce3f9ed7fe35ec to your computer and use it in GitHub Desktop.
Bookmarklet - use this bookmarklet for when you want to watch all videos in home feed at once, and can't pick one to watch. Ensure to copy/paste the top condensed line of the bookmarklet. Info at "https://github.com/isocialPractice/bookmarklets".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// *********************************************************** /// | |
| // ****************** BROWSER BOOKMARKLET GIST ***************** // | |
| // ************************************************************* // | |
| // // | |
| // LICENSE ///////////////////////////////////////////////////// | |
| // ******* // | |
| // The code in this gist is public domain. // | |
| // Licensed as Public Domain CC0 // | |
| ////////////////////////////////////////////////////////////////// | |
| // | |
| // COPY / PAST BELOW LINE TO USE | |
| javascript:(function() { /* Config variable - 1 to oepn in new tab, 0 to not. */ var openInNewTabWatchRandomVideo = 1; /* Class name of element holding link for video. */ var videoFeedWatchRandomVideo = /* HOT-GLUE - may change */ document.getElementsByClassName("yt-lockup-view-model__content-image"); /* Length of all videos in home feed. */ var videoFeedWatchRandomVideoLen = videoFeedWatchRandomVideo.length; /* Generate random value using length. */ var randomValWatchRandomVideo = Math.floor(Math.random() * videoFeedWatchRandomVideoLen); /****************************************************************************************** MAIN FUNCTION ******************************************************************************************/ function watchRandomVideo(target) { /* Make sure video links are loaded. */ if (videoFeedWatchRandomVideo.length >= 1 && /* at least one loaded */ videoFeedWatchRandomVideo[0].hasAttribute("href") /* good guess load correctly */ ) { /* get video link */ let videoURL = videoFeedWatchRandomVideo[randomValWatchRandomVideo].href; /* watch random video */ window.open(videoURL, target); } else { /* do nothing */ let skip; } } /* Check if configured to open in new tab. */ if (openInNewTabWatchRandomVideo == 1) { /* if so, open in new tab */ watchRandomVideo("_blank"); } else { /* if not, open in current window */ watchRandomVideo("_self"); }})(); | |
| // MAKE ANY EDITS AS NEEDED | |
| // ************************************************************* | |
| // Use the JS Formatted Bookmarklet below to see if any changes | |
| // need to be made in accordance to the page you want to use | |
| // it for. After making needed changes ensure that the revised | |
| // bookmarklet is condensed before using it in your browser. | |
| // For more info on this bookmarklet visit: | |
| // https://github.com/isocialPractice/bookmarklets | |
| // ************************************************************* | |
| // ************************************************************* | |
| // ************************JS-FORMATTED************************* | |
| javascript:(function() { | |
| /* Config variable - 1 to oepn in new tab, 0 to not. */ | |
| var openInNewTabWatchRandomVideo = 1; | |
| /* Class name of element holding link for video. */ | |
| var videoFeedWatchRandomVideo = /* HOT-GLUE - may change */ | |
| document.getElementsByClassName("yt-lockup-view-model__content-image"); | |
| /* Length of all videos in home feed. */ | |
| var videoFeedWatchRandomVideoLen = videoFeedWatchRandomVideo.length; | |
| /* Generate random value using length. */ | |
| var randomValWatchRandomVideo = | |
| Math.floor(Math.random() * videoFeedWatchRandomVideoLen); | |
| /****************************************************************************************** | |
| MAIN FUNCTION | |
| ******************************************************************************************/ | |
| function watchRandomVideo(target) { | |
| /* Make sure video links are loaded. */ | |
| if (videoFeedWatchRandomVideo.length >= 1 && /* at least one loaded */ | |
| videoFeedWatchRandomVideo[0].hasAttribute("href") /* good guess load correctly */ | |
| ) { | |
| /* get video link */ | |
| let videoURL = | |
| videoFeedWatchRandomVideo[randomValWatchRandomVideo].href; | |
| /* watch random video */ | |
| window.open(videoURL, target); | |
| } else { | |
| /* do nothing */ | |
| let skip; | |
| } | |
| } | |
| /* Check if configured to open in new tab. */ | |
| if (openInNewTabWatchRandomVideo == 1) { | |
| /* if so, open in new tab */ | |
| watchRandomVideo("_blank"); | |
| } else { | |
| /* if not, open in current window */ | |
| watchRandomVideo("_self"); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment