Andrews54757 / FastStream

Stream videos without buffering in the browser. An extension that gives you a better, accessible video player designed for your needs.
https://faststream.online/
Other
405 stars 28 forks source link

[BUG] Exclusion rules aren't applied to standalone URLs #241

Closed pintassilgo closed 2 weeks ago

pintassilgo commented 2 weeks ago

I tried to add a few exceptions to when I load .m3u8 as tab URL, so that FastStream shouldn't act on them, but it doesn't work.

Andrews54757 commented 2 weeks ago

I don't know how to do that with Chrome's manifest v3 system. Feel free to let me know, make a pull request, if you have an idea.

pintassilgo commented 2 weeks ago

FastStream already uses excludedRequestDomains to exclude self, it could also be used for exclusion rules. I know it would be limited to domains/sub-domains and without regex support, so it should be a special type, like prepending two ! instead of one.

regexFilter is currently used to match filetype, could be expanded to integrate exclusion rules. Example of an URL that FastStream should not process:

https://github.com/xfcheng0122/hello-world/blob/7c4798e537f1096bb228cdb88e5f0194cac65340/4k.m3u8

If you load this URL, you'll see this is not a direct link (raw) to .m3u8 file, it's a normal page from GitHub. But FastStream thinks it's a direct link and obviously fails to play anything from there. So I'd like to add this exclusion rule in FastStream preferences:

!~^https:\/\/github\.com\/.+?\/blob\/

A second user exclusion rule could be, for instance:

!~^https:\/\/example\.com\/

Then it could be something like this (just a concept):

let exclusionRulesArr = getExclusionRules();
// exclusionRulesArr = ['^https:\/\/github\.com\/.+?\/blob\/', '^https:\/\/example\.com\/']

let exclusionRulesRegexExpansion = '';

if (exclusionRulesArr.length) {
  exclusionRulesRegexExpansion = '(?!' + exclusionRulesArr.map(rule => {
    if (rule.startsWith('^')) {
      return rule.slice(1);
    }
    return '.*' + rule;
  }).join('|') + ')';
}

Then, this line:

https://github.com/Andrews54757/FastStream/blob/5f0f7fd881e241ce933aaf250526641c84253344/chrome/background/background.mjs#L780

could be replaced by something like

regexFilter: '^' + exclusionRulesRegexExpansion + '.+\\.(' + filetypes.join('|') + ')([\\?|#].*)?$',

In this example, final expanded regex would be:

^(?!https://github.com/.+?/blob/|https://example.com/).+\.(m3u8|mpd|mp4)([\?|#].*)?$

Result:

image

As you see, exclusion rules work as expected.

Andrews54757 commented 2 weeks ago

You can now exclude specific domains by prepending -

pintassilgo commented 1 week ago

This is not working for me. And "Auto enable URLs" description in options says nothing about "prepending -".

  1. Enable Use player to load HLS/DASH.
  2. Add this rule: -github.com
  3. Load this URL: https://github.com/xfcheng0122/hello-world/blob/7c4798e537f1096bb228cdb88e5f0194cac65340/4k.m3u8

FastStream shouldn't load the player, as it's from an excluded domain, but it loads.