amitbl / blocktube

YouTube™ content blocker
GNU General Public License v3.0
912 stars 66 forks source link

Combining Advanced Blocking Filters #317

Open Apposite245 opened 1 year ago

Apposite245 commented 1 year ago

Trying to write an advanced filter that will block videos that have more than X views and are shorter than X seconds.

I'm using video.vidLength and video.viewCount, I can get each filter working individually, but can't get them working together.

I've tried combining them into a single filter like

if (video.vidLength < 1200) && (video.viewCount > 2000)

and creating two separate filters, but it doesn't work in either case.

I don't know any JS but the syntax seems wrong to me but I'm not sure where exactly.

ClawhammerLobotomy commented 11 months ago

The documentation shows an example of how to do this.

  // If video title contains "something"
  //                                and If the channel name contains "otherthing"
  if (video.title.match("something") && video.channelName.match("otherthing")) {
    // Block the video
    return true;
  }

Your parenthesis are formatted incorrectly for what you're trying. if (video.vidLength < 1200 && video.viewCount > 2000)