Skip to content

Instantly share code, notes, and snippets.

@Dramacydal
Last active January 8, 2021 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dramacydal/61265b551cd1683dbb09f91ee3cae27e to your computer and use it in GitHub Desktop.
Save Dramacydal/61265b551cd1683dbb09f91ee3cae27e to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name twitch suggested friends hide
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.twitch.tv/*
// @grant none
// @require http://code.jquery.com/jquery-3.4.1.min.js
// ==/UserScript==
function setIntervalWithContext(code, delay, context) {
return setInterval(function() {
code.call(context);
}, delay);
}
let needClick = true;
function startTimer(document) {
this.interval = setIntervalWithContext(function() {
if (needClick) {
$('[aria-label="Followed Channels"] [data-a-target="side-nav-show-more-button"]').click();
}
let channelsParent = $($('[aria-label="Followed Channels"]').children()[1]);
let channels = channelsParent.children();
if (needClick) {
let filtered = channels.filter(function(index) {
let textA = $('span', $(this)).text();
return textA !== 'Offline';
});
console.log("Online channels: " + filtered.length);
needClick = filtered.length === channels.length;
}
//console.log("Need click: " + (needClick ? 1 : 0));
channels.detach().sort(function(a, b) {
let textA = $('.side-nav-card__live-status span', $(a)).text();
let textB = $('.side-nav-card__live-status span', $(b)).text();
let valA = 0;
if (textA === 'Offline') {
valA = 0;
} else if (textA[textA.length - 1] == 'K') {
valA = parseFloat(textA.substr(0, textA.length - 1)) * 1000;
} else {
valA = parseInt(textA);
}
let valB = 0;
if (textB === 'Offline') {
valB = 0;
} else if (textB[textB.length - 1] == 'K') {
valB = parseFloat(textB.substr(0, textB.length - 1)) * 1000;
} else {
valB = parseInt(textB);
}
return valB - valA;
});
channelsParent.append(channels);
try
{
var links = document.querySelectorAll ("div.recommended-friends");
if (links.length > 0)
{
links[0].parentNode.removeChild(links[0]);
}
let wtf = $('.claimable-bonus__icon').closest('.tw-button');
if (wtf.length > 0) {
wtf.click();
}
}
catch (err)
{
}
}, 1000, this);
timers.push(this.interval);
}
function addTimers() {
while (timers.length) clearInterval(timers.pop());
var stopwatch = new startTimer(document);
}
var timers = [];
addTimers();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment