Skip to content

Instantly share code, notes, and snippets.

@livibetter
Last active September 25, 2017 15:25
Show Gist options
  • Save livibetter/e3a599a540db40ce2a3691bc74208dbc to your computer and use it in GitHub Desktop.
Save livibetter/e3a599a540db40ce2a3691bc74208dbc to your computer and use it in GitHub Desktop.
Twitch: No Vodcasts
// ==UserScript==
// @name No Vodcasts
// @namespace https://gist.github.com/livibetter/e3a599a540db40ce2a3691bc74208dbc
// @include https://www.twitch.tv/directory/*
// @version 1
// @grant none
// ==/UserScript==
function check_stream(stream)
{
if (stream.querySelector('span.pill.is-watch-party'))
{
stream.remove();
console.log('Vodcast stream removed');
}
}
function check_streams(mutations)
{
let streams = document.querySelectorAll('div.tower > div.qa-stream-preview.ember-view');
streams.forEach(check_stream);
}
function wait_tower(mutations)
{
let tower = document.querySelector('div.tower');
if (tower)
{
console.log('div.tower found, watching...');
tower_obs.disconnect();
tower_obs = null;
let obs = new MutationObserver(check_streams);
obs.observe(tower, {childList: true});
return;
}
}
function main()
{
console.log('main');
if (document.body)
{
console.log('wait for div.tower...');
tower_obs.observe(document.body, {childList: true, subtree: true});
}
}
var tower_obs = new MutationObserver(wait_tower);
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment