Skip to content

Instantly share code, notes, and snippets.

@joesondow
Created February 26, 2021 01:18
Show Gist options
  • Save joesondow/8d1e4ca5eef9dfc86d34b2aa90a38024 to your computer and use it in GitHub Desktop.
Save joesondow/8d1e4ca5eef9dfc86d34b2aa90a38024 to your computer and use it in GitHub Desktop.
GreaseMonkey script to sort the streamer thumbnail images by least to most popular on https://www.twitch.tv/directory/following/live
// ==UserScript==
// @name Twitch Following Live Unpopular First
// @version 1
// @grant none
// @match https://www.twitch.tv/directory/following/live
// ==/UserScript==
(function() {
'use strict';
var findTower = function() {
return document.querySelector('.tw-tower');
};
var reorder = function() {
var tower, boxes, i, box;
console.log("reorder");
tower = findTower();
boxes = document.querySelectorAll('.tw-tower > div');
for (i = boxes.length - 1; i >= 0; i--) {
box = boxes[i];
tower.appendChild(box);
}
};
var checkExist = setInterval(function() {
console.log('Checking for element to exist...');
if (findTower()) {
console.log('tower exists');
reorder();
clearInterval(checkExist); // Done. Stop trying.
}
}, 1000); // check every 1000 milliseconds until found
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment