amitbl / blocktube

YouTube™ content blocker
GNU General Public License v3.0
963 stars 68 forks source link

[Request] Block/allow by view count. #467

Open htAngryFace opened 1 month ago

htAngryFace commented 1 month ago

I literally do not want to see 64 view videos. That's all.

Thank!

f4grx commented 1 month ago

You can do that with advanced blocking I guess, the video object passed to the filter function has a viewcount field.

https://github.com/amitbl/blocktube/wiki/Advanced-Blocking

Can you test it?

GithubAnon0000 commented 1 month ago

It does work @f4grx @htAngryFace. Here is an example:

(video, objectType) => {

  // block videos with less than 1,000,000 views
  if (video.viewCount <= 1000000) {
    return true;
  }

  return false;
}

Very easy to do. Obviously replace the view count with your desired value.

nadir-advian commented 1 month ago

@GithubAnon0000 it does not work with 0 views (No views) videos.

GithubAnon0000 commented 1 month ago

@nadir-advian do you have an example video so that I can check? The condition would be video.viewCount < 1.

nadir-advian commented 1 month ago

@GithubAnon0000 I tried your suggestion and it does not work. Instead of linking to a specific video, here's a search query that will lead to many 0 views videos: https://www.youtube.com/results?search_query=MVI&sp=EgIIAQ%253D%253D I believe youtube uses a different logic for 0 views videos since they display as "No views" instead of 0views. So it's probably not an integer, but something like Null or None.

GithubAnon0000 commented 1 month ago

@nadir-advian You're right, console.log(JSON.stringify(video)); shows null for viewCount.

The following works for me:

// block videos with 0 views
let viewCountStr = JSON.stringify(video.viewCount);
if (viewCountStr.includes("null")) {
  return true;
}

PS: ignore my previous now deleted comment if you see it in your mail history. That is buggy and would block every single video.

nadir-advian commented 1 month ago

@GithubAnon0000 Finally, I can now block the AI videos slop. Thanks, your solution works.