Last active
March 12, 2020 21:47
-
-
Save joesondow/6d7fd6e9f806341da68ddf61267667e6 to your computer and use it in GitHub Desktop.
GreaseMonkey script to clean up, resize, and move twitch chat popout window where and how I want it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Twitch Chat Window Fix | |
// @version 1 | |
// @description Put twitch chat where I want it, and use all the space for text better | |
// @author You | |
// @match https://www.twitch.tv/popout/joesondow/chat?popout= | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function addStylesheetRules(rules) { | |
var styleEl, styleSheet, prop, i, rule; | |
styleEl = document.createElement('style'); | |
// Append <style> element to <head> | |
document.head.appendChild(styleEl); | |
// Grab style element's sheet | |
styleSheet = styleEl.sheet; | |
for (i = 0; i < rules.length; i++) { | |
rule = rules[i]; | |
// Insert CSS Rule | |
styleSheet.insertRule(rule, styleSheet.cssRules.length); | |
} | |
} | |
var fixWindow = function() { | |
console.log("fixWindow"); | |
function find(c){ | |
return document.querySelector('.' + c) | |
} | |
function del(clazz){ | |
var element = find(clazz); | |
console.log(clazz + " class found " + element); | |
element.parentNode.removeChild(element); | |
} | |
function shrink(clazz, attr){ | |
find(clazz).style.setProperty(attr, 0, "important"); | |
} | |
// del("rooms-header"); | |
//del("tw-z-default"); | |
del("stream-chat-header"); | |
del("channel-leaderboard"); | |
shrink("chat-input","padding"); | |
shrink("chat-input__buttons-container","margin"); | |
addStylesheetRules([ | |
//'.channel-leaderboard { height: 0; padding: 0 5px; }', | |
//'.simplebar-content .chat-line__status span { font-size: 0; }', | |
//'.simplebar-content .chat-line__status { height: 0; padding: 0 5px; }', | |
//'.simplebar-content .chat-line__message { padding: 3px 5px; }' | |
]); | |
window.resizeTo(600,500); | |
window.moveTo(2100,0); | |
}; | |
var checkExist = setInterval(function() { | |
console.log('Checking for element to delete...'); | |
if (document.querySelector('.channel-leaderboard')) { | |
console.log('.channel-leaderboard exists'); | |
fixWindow(); | |
clearInterval(checkExist); | |
} | |
}, 1000); // check every 1000ms | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment