Created
August 14, 2023 11:50
-
-
Save Shubhang/cd8e942208e9d3db8ed7f966d8be9fd7 to your computer and use it in GitHub Desktop.
Remove short videos from youtube recommendations
This file contains 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
// Open YouTube: Navigate to the YouTube homepage. | |
// Open Developer Console: Press F12 or right-click anywhere on the page and select "Inspect" to open the developer console. Then, click on the "Console" tab. | |
// Paste and Run the Script: Copy and paste the following code into the console, then press Enter. | |
// This code searches for video duration elements on the page and hides the corresponding video if its duration is less than 10 minutes. | |
// Repeat as Needed: If you scroll down and more videos load, or if you navigate to a different page, you'll need to run the script again. | |
const hideVideosUnderMinutes = (minMinutes) => { | |
const videoDurations = document.querySelectorAll('ytd-thumbnail-overlay-time-status-renderer'); | |
videoDurations.forEach(durationElement => { | |
const durationText = durationElement.innerText.trim(); | |
const [minutes, seconds] = durationText.split(':').map(Number); | |
if (minutes < minMinutes || (minutes === minMinutes && seconds === 0)) { | |
const videoElement = durationElement.closest('ytd-rich-item-renderer'); | |
if (videoElement) { | |
videoElement.style.display = 'none'; | |
} | |
} | |
}); | |
}; | |
hideVideosUnderMinutes(10); // Replace 10 with the desired number of minutes | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment