blocktube icon indicating copy to clipboard operation
blocktube copied to clipboard

[Request] Give an option to hide watched videos while ignoring Channel videos

Open jaylay99 opened this issue 3 years ago • 1 comments

The feature: "Hide videos watched more than" is great but it hides videos when I go on someone's Channel. I wish to have an extra option that would let me hide watched videos but only on the Homepage.

Thanks!

jaylay99 avatar Oct 25 '22 23:10 jaylay99

I wrote a custom blocking function that blocks watched videos only for the homepage, subscriptions, and related videos sidebar here: https://github.com/amitbl/blocktube/issues/151#issuecomment-1221647020

Adapting this function to only the homepage results in something like this:

// Block watched videos in certain pages
(video, objectType) => {
  const hideVideosWatchedMoreThanPercentage = 90; 
  
  // Do not block videos in pages other than blockedPathnames
  const blockedPathnames = [
    /^\/$/                      // homepage
  ];
  if (!blockedPathnames.some(blockedPathname => blockedPathname.test(window.location.pathname)))
    return false;
  
  // Do not block unwatched videos
  if (video.percentWatched === undefined || parseInt(video.percentWatched) < hideVideosWatchedMoreThanPercentage)
    return false;
  
  // Do not block videos in playlists
  if (objectType === "playlistPanelVideoRenderer")
    return false;
  
  console.log(`BlockTube custom blocking function: "${video.title}" (${video.percentWatched}% watched)`);
  return true;
}

llamatar avatar Jan 05 '23 10:01 llamatar