privacybadger
privacybadger copied to clipboard
Disabling Privacy Badger based on site URL param
I'd love to have an option to whitelist based on part of a URL or parameter. As it is, I can only whitelist a domain. For example, I whitelist several YouTube creators to allow ads on their videos with uBlock using a script/extension and a specific param, but they still get blocked by PB. I don't want to disable PB on YouTube as a whole, nor do I want to allow ads on every video. If there is there a way to do this currently, please disregard.
I've got an image of what my modified URL for uBlock looks like.

You could whitelist all subdomains of a domain (#624), but that doesn't seem to help here.
We should be mindful of performance (#1507) when revising isPrivacyBadgerEnabled() as it gets called frequently in performance-critical code paths. It might make sense to implement this specifically as a way to whitelist individual YouTube channels (friendlier UI, little performance impact outside of YouTube), as opposed to supporting querystring-based pattern matching in general.
As noted above, uBlock Origin allows whitelisting individual YouTube channels with the help of userscripts: https://github.com/gorhill/uBlock/wiki/How-to-whitelist-a-web-site#a-youtube-channel.
AdBlock seems to have this functionality built in: https://help.getadblock.com/support/solutions/articles/6000067131-how-do-i-whitelist-a-specific-youtube-channel-.
@ghostwords One easy way we might be able to achieve this is with the include_globs and exclude_globs properties in the content_scripts manifest field. This would work nicely with the contentScripts.register() method listed in #1865.
However, given that solution would only work for Firefox 59+, supporting this functionality with other methods would require more effort.
But would this cover all the places we check isPrivacyBadgerEnabled()? This isn't just about the content scripts.
Oh, definitely not. I was thinking of how this would play with the proposed changes to content script injection.
Giving it a closer look, it appears the approach the uBlock Origin script uses requires the HTML to be returned then the page to be reloaded with an updated URL. If we adopt an approach similar to this, relative performance would be far worse anyway on YouTube. I think this could be added in such a way that it wouldn't cause any additional overhead to existing isPrivacyBadgerEnabled() calls. For example, the function could contain a simple check like this:
if (origin.match('youtube.com') !== -1) {
return isEnabledYouTubeChannel(origin);
} else {
// whatever we do now
}
Exciting to see the discussion friends - wish I knew more! If there's anything else I can provide that'd be helpful or time-saving, let me know!
I would like to have a look into implementing this, if there's interest
If anyone implements this, keep in mind that contentScripts.register now has a polyfill for Chrome