Skip to content

Latest commit

 

History

History
143 lines (103 loc) · 4.53 KB

README.md

File metadata and controls

143 lines (103 loc) · 4.53 KB

Block Twitch Content

A Firefox Extension that removes unwanted content from the Twitch chat using various identifiers, phrases or simply a display name. Can also remove sub notifications, highlighted comments, service messages and block common types of spam quickly using default settings.

You can easily create rules by opening the pop-up in the address bar while viewing Twitch.

The list is stored locally and remains private.

Settings Bar

You can mouse-over a setting to see what it does, detailed explanations below.

Hide Bot Spam

Content containing the words below will be removed from chat if the Hide Bots setting is active

StreamElements
Streamlabs
SoundAlerts
Moobot
Nightbot
Fossabot
DeepBot
WizeBot
PhantomBot
Botisimo
TwitchBot

Hide Command Spam

Content containing the words below will be removed from chat if the Hide Commands setting is active

!join
!gamble
!following
!followage
!links
!points
!hype
!uptime
!commands
!watchtime
!socials
!donate
!schedule
!vote
!specs
!sens
!party
!song
!playing
!game
!music
!patch
!event

View Removed Message History

Click the settings cog to open the removed message history in a new tab, If you have more than one stream open then each streamer gets its own tab.

Download List

You can download the list of content rules any time by clicking the download button in the pop-up window


How does it work

The extension works by injecting a Mixin to check messages as they arrive.

This is achieved by using a very durable Regex to find the location of the messageProcessor in vendor.js.

CONFIG.REGEX.FRAGMENT: /([A-Za-z])\.messageProcessor\.processMessage\(([A-Za-z])\.data\)/

Once the messageProcessor has been found, it gets replaced with a Mixin that can securely communicate with the extension.

export function createFragmentListener(matches) {
  return `new Promise((resolve) => {
    const val = Math.floor(Math.random() * 100000000);
    const handler = (e2) => {
      if (e2.data.response !== undefined && e2.data.completed && e2.data.random === val) {
        resolve(e2.data.response);
        window.removeEventListener('message', handler);
      }
    };
    window.addEventListener('message', handler);
    window.postMessage({ 
      random: val, 
      type: 'fp', 
      text: ${matches[2]}.data 
    });
  }, 'https://www.twitch.tv').then(response => {
    if(response === 'w'){ 
      ${matches[1]}.messageProcessor.processMessage(${matches[2]}.data)
    }
  });`;
}

Using a Promise this way creates a synchronous channel with the Extension through the Content Script.

This makes it possible to update the Hidden Chat Content Rules in real time instead of needing a page refresh.

Settings

Additional settings and examples can be found in the options menu.

Debug Mode

In debug mode, the extension will start displaying messages in the console.

This information can be useful for creating rules or finding bugs.

Self Healing

The Mixin makes use of the Matches from the Regex to self-heal when Twitch updates.

$1.messageProcessor.processMessage($2.data);