amitbl / blocktube

YouTube™ content blocker
GNU General Public License v3.0
860 stars 60 forks source link

pass-on configuration into advanced blocking script parameters #302

Open drzraf opened 1 year ago

drzraf commented 1 year ago

Whitelisting isn't supported for now (#133).

An alternative is to do it programmatically using an advanced blocking. but it would be handy to reuse configuration (so my whitelisted channel live inside the configuration instead of being hardcoded into the script).

Sadly, chrome isn"t available inside the content script

chrome.storage.local.get('storageData', (storageRes) => { // doesn't work
        console(storageRes.storageData);
});

Coudn't this be implemented to make it more powerful and act as an efficient way to create a variety of workarounds for other missing core-features?

drzraf commented 9 months ago

Small up on this one since it paves the way to #133 in an elegant way.

Dashyyy commented 2 months ago

To add on this conversation I've achieved whitelisting without breaking any other aspects of youtube with the following code:

(video, objectType) => {

  // List of allowed Channels
  const allowList =  new Set([
    "Channel1",
    "Channel2",
  ]);

  // Do not remove comments and video information
  const allowedObjects = new Set([
    "guideEntryRenderer",
    "videoPrimaryInfoRenderer",
    "videoSecondaryInfoRenderer",
    "commentRenderer",
    "videoDetails"
  ])

  // Block the video
  if (video.channelId.length == 24 && !allowList.has(video.channelName.trim()) && !allowedObjects.has(objectType)) return true;

  // Custom conditions did not match, do not block
  return false;
}

I find the idea to store the channel names in a local file to be very nice. Will maybe work on a way to actually implement it like this and create a PR.