amitbl / blocktube

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

[Request] Add option to schedule activation and deactivation of video filters #289

Open dylantjb opened 1 year ago

dylantjb commented 1 year ago

I would like to suggest adding a feature to the extension that would allow people to activate and deactivate video filters on a schedule. This would be especially useful for productivity purposes.

To implement this feature, I suggest adding an additional option in the extension menu that would let people specify the days of the week and times that the schedule should be active. This would provide more flexibility and control over the video filters.

Currently, I am using the custom blocking function, but I am unable to block videos and channels from the context menu with the schedule in mind. The function uses a set of predefined keywords to block certain titles and channels.

const TITLE_OPTIONS = [
  "Titles",
  "I",
  "want",
  "to",
  "block",
];

const CHANNEL_OPTIONS = [
  "Channels",
  "I",
  "want",
  "to",
  "block",
];

(video) => {
  const currentTime = new Date();
  const activateTime = new Date(
    currentTime.getFullYear(),
    currentTime.getMonth(),
    currentTime.getDate(),
    09,
    0,
    0
  );
  const deactivateTime = new Date(
    currentTime.getFullYear(),
    currentTime.getMonth(),
    currentTime.getDate(),
    17,
    0,
    0
  );

  if (currentTime >= activateTime && currentTime < deactivateTime) {
    for (let i = 0; i < TITLE_OPTIONS.length; i++)
      if (video.title.match(TITLE_OPTIONS[i])) return true;

    for (let i = 0; i < CHANNEL_OPTIONS.length; i++)
      if (video.channelName.match(CHANNEL_OPTIONS[i])) return true;
  }

  return false;
};
BradKML commented 1 year ago

Sounds like a good ideas to be paired with other productivity apps, what do you have in mind? Also, won't that conflict with blocking general spam content vs media content?