Giter Club home page Giter Club logo

twitch-hls-adblock's Introduction

Motivation

Twitch is playing a 15-30 second advertisement whenever one starts watching a new channel. For people who jump around a bit this is pretty annoying.

Twitch staff has been fairly quick to remove client side fixes that disable advertisements. Since they're able to inject advertisementst into the HLS stream directly (SSAI, Twitch's SureStream if you want to research further), I believe such fixes will not always be available.

This extension monkey patches the web worker (among others) Twitch uses and edits the m3u8 playlist that gets requested every few seconds to simply remove segments that are marked as advertisments with SCTE-35 flags.

Right now Twitch also makes the actual stream available in those playlist files after a few seconds, which means that after just around 5 seconds the real stream begins, instead of 30 seconds of advertisements.

Installation

To install manually for Chrome:

  1. Check releases for the latest zip or download the source
  2. Unzip into a directory and keep the directory in mind
  3. Go to chrome://extensions/ and enable Developer Mode
  4. Click on 'Load unpacked' and go to the directory with the extension (see if manifest.json is in the directory)

To install manually for FireFox:

  1. Download the latest release (xpi file)
  2. Go to about:addons and load addon from file

Limitations

Generally it seems to work fine. Whenever one loads up a new channel, if there's an advertisment injected by Twitch, after a few seconds of loading the real stream begins without any indication of an advertisment.

However I've seen rare instances where the stream breaks, which requires a browser reload. This happened once when the advertisment loaded 2-3 seconds after the stream has started normally.

Currently this is only tested on the latest stable chromium browser and latest Firefox stable.

Contributing

I appreciate any contributions, be it pull requests or issues. Right now there's no tests however, so make sure to test extensively on Twitch before submitting a pull request.

twitch-hls-adblock's People

Contributors

instance01 avatar millhioref avatar solevic avatar stoically avatar toofar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twitch-hls-adblock's Issues

CSP violation

Extension does not work for me on Chromium Version 69 Linux (64-bit). Initialization fails with the following error:

Refused to create a worker from 'blob:https://www.twitch.tv/eb0de64b-1bbe-4a30-8aed-629568a05928' because it violates the following Content Security Policy directive: "worker-src 'none'".

I tried diabling CSP headers with the "Disable Content-Security-Policy" extension.
Also tried adding "content_security_policy": "worker-src 'blob'; script-src 'self'; object-src 'self'" to manifest.json
The CSP seems to be overwritten somewhere else.

opera broswer

hey

can we get this working for the opera browser as well please

currently not working

Thanks for creating this. It worked at first, but now, in Firefox at least, when switching streams, the screen goes black and the loading icon appears. It seems to last as long as the ad would have, then the stream starts.

Never ending black screen + some error

Hey, I think twitch found a work around for ublock origin because it stopped working for me last night. I found this and tried it out but the screen stays black with a loading symbol in the middle and never ends up showing the stream (tried waiting ~5 minutes)

I'm not sure if this is related but when I view my extensions, I noticed the extension had errors and it were these:

Image 09-29-2020 18-11-16

request

is there any chance to get this working for opera browers 1 day

taking 30 seconds to play; ad or not

Greetings,
I like what you're trying to do with this. I wanted to report that this extension is indeed preventing the ads from playing. (0.6.0) But instead of it taking 5 seconds to play video, I get black video that says it's live for about 30 seconds. (Same amount of time as the ad.) This happens even for situations I wouldn't normally see an add.

Keep up the good work!

Stream freezes when sequence is rewritten to 0

A side-effect of self._seq and self._wasAd keeping their values when switching streams (through xhr website-navigation which doesnt reload the wasmworker) is that the sequence can "always" get set to 0 - if the sequence of the new stream is smaller than the already set _seq - resulting in a stream-freeze (even if no Ad plays).

How do we provide ad chunk definitions?

Me again, I seem to be getting pre-roll and mid-roll ads again; based on #25 I think I understand how to create a PR to update the ad chunk defs, but if someone could tell me how to find those new definitions in a stream I'd be grateful.

Doesn't seem to be working

Win 10, Chrome 76.0.3809.132

Installed as indicated, extension seems to have loaded fine but I'm still getting ads before streams. Is there a way to access logging so I can understand if anything is getting blocked/if there are errors being generated?

Black Screen on all streams and VODs

#6 (comment)

It appears this same issue has returned some time in the past week, only this time it is in the main Firefox release. Streams and VODs never load on Firefox with the extension enabled, they just sit in a black screen.

Unable to change stream quality to below Auto or Source in some streams

With this loaded, when I try to set a stream's video quality, the settings gear spins continuously unless I select Auto or Source, and changes to lower qualities don't take effect. Upon a stream's loading or refresh, the preferred quality setting is applied for a few seconds, after which Auto is applied. The stream I've observed this on is TwitchPresents, and I have noticed it happen on other streams, but am not sure if it applies to all streams or not.

Chrome Warning

Hey, the extensions works fine but I have too issues.

  1. Everytime I start Chrome it says that I should disable this extension if I'm not a developer.
  2. I want the extension to be hidden from my Chrome bar, but after a restart the message from #1 pops up and I have to remove it from the Chrome bar again.

Multiple errors, doesn't work, using latest Chrome

Tried opening Forsen. Pre-roll ads open immediately and load/play -- nothing is blocked. Here's my console:

lib.js:227 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.

getWasmBinaryVersion | @ | lib.js:227
-- | -- | --
  | Worker | @ | injected.js:7
  | v | @ | player-core-variant-…2eb7469728bd35.js:1
  | (anonymous) | @ | core-c7103c2….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | a | @ | vendor-b62d9c6….js:1
  | Promise.then (async) |   |  
  | u | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | l | @ | vendor-b62d9c6….js:1
  | A | @ | core-c7103c2….js:1
  | t.maybeLoadPlayer | @ | core-c7103c2….js:1
  | t.componentDidMount | @ | core-c7103c2….js:1
  | Ws | @ | vendor-b62d9c6….js:1
  | t.unstable_runWithPriority | @ | vendor-b62d9c6….js:1
  | po | @ | vendor-b62d9c6….js:1
  | Hs | @ | vendor-b62d9c6….js:1
  | Ms | @ | vendor-b62d9c6….js:1
  | du | @ | vendor-b62d9c6….js:1
  | pu | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | Us | @ | vendor-b62d9c6….js:1
  | _u | @ | vendor-b62d9c6….js:1
  | render | @ | vendor-b62d9c6….js:1
  | e.mount | @ | core-c7103c2….js:1
  | n | @ | core-c7103c2….js:1
  | (anonymous) | @ | core-c7103c2….js:1
  | d | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | dispatch | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | core-c7103c2….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | a | @ | vendor-b62d9c6….js:1
  | Promise.then (async) |   |  
  | u | @ | vendor-b62d9c6….js:1
  | a | @ | vendor-b62d9c6….js:1
  | Promise.then (async) |   |  
  | u | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | l | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | core-c7103c2….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | e.dispatch | @ | core-c7103c2….js:1
  | d | @ | core-c7103c2….js:1
  | sNlA | @ | core-c7103c2….js:1
  | m | @ | forsen?twitch5=0:1
  | 202 | @ | core-c7103c2….js:1
  | m | @ | forsen?twitch5=0:1
  | i | @ | forsen?twitch5=0:1
  | e | @ | forsen?twitch5=0:1
  | (anonymous) | @ | core-c7103c2….js:1

injected.js:29 [Report Only] Refused to create a worker from 'blob:https://www.twitch.tv/46c0bc96-e34f-4c81-a512-a5b51921c220' because it violates the following Content Security Policy directive: "worker-src 'none'".

Worker | @ | injected.js:29
-- | -- | --
  | v | @ | player-core-variant-…2eb7469728bd35.js:1
  | (anonymous) | @ | core-c7103c2….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | a | @ | vendor-b62d9c6….js:1
  | Promise.then (async) |   |  
  | u | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | l | @ | vendor-b62d9c6….js:1
  | A | @ | core-c7103c2….js:1
  | t.maybeLoadPlayer | @ | core-c7103c2….js:1
  | t.componentDidMount | @ | core-c7103c2….js:1
  | Ws | @ | vendor-b62d9c6….js:1
  | t.unstable_runWithPriority | @ | vendor-b62d9c6….js:1
  | po | @ | vendor-b62d9c6….js:1
  | Hs | @ | vendor-b62d9c6….js:1
  | Ms | @ | vendor-b62d9c6….js:1
  | du | @ | vendor-b62d9c6….js:1
  | pu | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | Us | @ | vendor-b62d9c6….js:1
  | _u | @ | vendor-b62d9c6….js:1
  | render | @ | vendor-b62d9c6….js:1
  | e.mount | @ | core-c7103c2….js:1
  | n | @ | core-c7103c2….js:1
  | (anonymous) | @ | core-c7103c2….js:1
  | d | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | dispatch | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | core-c7103c2….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | a | @ | vendor-b62d9c6….js:1
  | Promise.then (async) |   |  
  | u | @ | vendor-b62d9c6….js:1
  | a | @ | vendor-b62d9c6….js:1
  | Promise.then (async) |   |  
  | u | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | l | @ | vendor-b62d9c6….js:1
  | (anonymous) | @ | core-c7103c2….js:1
  | (anonymous) | @ | vendor-b62d9c6….js:1
  | e.dispatch | @ | core-c7103c2….js:1
  | d | @ | core-c7103c2….js:1
  | sNlA | @ | core-c7103c2….js:1
  | m | @ | forsen?twitch5=0:1
  | 202 | @ | core-c7103c2….js:1
  | m | @ | forsen?twitch5=0:1
  | i | @ | forsen?twitch5=0:1
  | e | @ | forsen?twitch5=0:1
  | (anonymous) | @ | core-c7103c2….js:1

Then the worker errors:

wasmworker.min-aee4d9fe011de7128e7d.js:1 Fetch failed loading: GET "https://video-weaver.dfw02.hls.ttvnw.net/v1/playlist/Co4EBPtDfI58pOlUkwi3uXwPt5C9mYa1n0jW342AQZiP8AzHvIvT0mWQ-vfsMx_kV1fr2dboD_iOcPNyxddGFRFJa0fWPD1VOI_PZuqEL1z_jl5JjrIYX188Av6HA1KP8oohb0iuRY1tEkCt6aKqC7SNCe1yYd1UEXuPuQHDK4cEIa5iNTj7siCNV1uGSM9LtFY4nrVCWd_StvERzouIJUcXgiRLq_bD-pMcFEPxxoVk8jIpAetjIHLf7CHpxO8z9SQyR2VwidMX2jhYWrab82ag27UtXUpV5FlS1gAcqqWyjWluFxldkqfxbbC_kCGo4-XTFjxGrY-YtbD8OSryjE43ZtqaEC31vG6EvSAgjgK5_Te_V-X0nQ2kxMwk8rw0Vr-sf23wn9FlB_xTqTj3LxcWdzWouEA1USZQhziTdn385vwiLx5iDcGeHXZbZ46yMP8640M3P-j0P40ia62GIIN-3XLJBFkoSlBJBhWsUJ60gWWJubu-xe50sPqT3uxSa6tFXl1ohAMn-i2_CxgCNP1B6pPs6bL29x6wROzqBFnKqi0DXZuXqz1XI74KGx3tYP64VhbshBe6rZ1NXzGFPwqKSQBcvxJeCSgjEaSEIXIoQWIra8HOuOrz48uQugIjcv0a3uULvp6fpxciTOdJ35bawfNPEnpwLplRorI2eo1uweJTV5vqqbWcYH8QebY3IBIQlk3swzJmIa4XaJGeBvuWZhoM-HRGBcCAksqwkKH2.m3u8".

t.sendFetchRequest | @ | wasmworker.min-aee4d9f….js:1
-- | -- | --
  | sendFetchRequest | @ | wasmworker.min-aee4d9f….js:1
  | w | @ | wasmworker.min-aee4d9f….js:1
  | (anonymous) | @ | wasm-0066869e-1502:1
  | (anonymous) | @ | wasm-0066869e-1504:1
  | (anonymous) | @ | wasm-0066869e-541:1
  | (anonymous) | @ | wasm-0066869e-334:1
  | (anonymous) | @ | wasm-0066869e-874:1
  | (anonymous) | @ | wasm-0066869e-2662:1
  | (anonymous) | @ | wasm-0066869e-796:1
  | (anonymous) | @ | wasm-0066869e-580:1
  | (anonymous) | @ | wasm-0066869e-303:1
  | (anonymous) | @ | wasm-0066869e-1361:1
  | (anonymous) | @ | wasm-0066869e-1679:1
  | (anonymous) | @ | wasm-0066869e-991:1
  | (anonymous) | @ | wasm-0066869e-302:1
  | (anonymous) | @ | wasm-0066869e-613:1
  | (anonymous) | @ | wasm-0066869e-1374:1
  | (anonymous) | @ | wasm-0066869e-1948:1
  | (anonymous) | @ | wasm-0066869e-2523:1
  | (anonymous) | @ | wasm-0066869e-448:1
  | (anonymous) | @ | wasm-0066869e-1546:1
  | n.dynCall_viii | @ | wasmworker.min-aee4d9f….js:1 |
  | dynCall_viii_108 | @ | VM145:4 |
  | WebMediaPlayer$onClientSinkUpdate | @ | VM147:10 |
  | e.onClientMessage | @ | wasmworker.min-aee4d9f….js:1 |
  | e.dispatch | @ | wasmworker.min-aee4d9f….js:1 |
  | e.onmessage | @ | wasmworker.min-aee4d9f….js:1 |

Breaks Twitch in Firefox nightly

I tried out the latest release in the latest 64-bit Firefox nightly on Windows. The result is that streams never start. The player just stays black but the controls for it "work" in that the play/pause/volume UI act as expected, there's just no video or audio. In a new, empty profile with only this extension (and turning off some content/tracker blocking off to get rid of some log messages), my browser console has only the following when trying to view a stream:

Injected Twitch Ad Blocker. injected.js:1:9
failed to resolve properties promise <unavailable> twitch-player-ui-9992686ce9d56394e1e1.js:37:57307
Autoplay is only allowed when approved by the user, the site is activated by the user, or media is muted. mediaplayer.min.js:7:23287
Content Security Policy: Ignoring ‘x-frame-options’ because of ‘frame-ancestors’ directive.
<unavailable> apstag.js:2:12743
    p https://c.amazon-adsystem.com/aax2/apstag.js:2
    <anonymous> https://c.amazon-adsystem.com/aax2/apstag.js:2
    r https://c.amazon-adsystem.com/aax2/apstag.js:2
    <anonymous> https://c.amazon-adsystem.com/aax2/apstag.js:2
    r https://c.amazon-adsystem.com/aax2/apstag.js:2
    <anonymous> https://c.amazon-adsystem.com/aax2/apstag.js:2
    <anonymous> https://c.amazon-adsystem.com/aax2/apstag.js:2

The "unavailable" line and trace below it is an error, but I don't know why there isn't actually a message attached. Maybe it's supposed to be with the earlier line about the promise, but that line is marked as warning level. I have no idea if it's related, anyway. I tried a few different streams at random with the same result.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.