Skip to content

Instantly share code, notes, and snippets.

@Shubhang
Created August 14, 2023 11:50
Show Gist options
  • Save Shubhang/cd8e942208e9d3db8ed7f966d8be9fd7 to your computer and use it in GitHub Desktop.
Save Shubhang/cd8e942208e9d3db8ed7f966d8be9fd7 to your computer and use it in GitHub Desktop.
Remove short videos from youtube recommendations
// 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