Last active
June 20, 2018 09:10
-
-
Save Yanrishatum/d6b461f0486c0b9068929be97ca9cac5 to your computer and use it in GitHub Desktop.
Sigh.
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 Actually fixed reddit UI | |
// @namespace http://yanrishatum.ru/ | |
// @version 0.2 | |
// @description For fucks sake, it's PC, we don't need that much negative space and nags. | |
// @author Yanrishatum | |
// @match *://reddit.com/* | |
// @match *://*.reddit.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var style = document.createElement("style"); | |
document.head.appendChild(style); | |
style = style.sheet; | |
var base = document.querySelector("#SHORTCUT_FOCUSABLE_DIV>div>div>div:nth-child(3)>div>div>div:nth-child(2)>div:nth-child(3)"); | |
if (!base) base = document.querySelector("#SHORTCUT_FOCUSABLE_DIV>div>div>div:nth-child(3)>div>div>div>div:nth-child(2)>div:nth-child(2)"); | |
var sidebar = base.children[1].firstElementChild; | |
// Disable nagging header | |
style.insertRule("#header { position: absolute; }"); | |
// Right bar nag adjust | |
style.insertRule("." + sidebar.children[sidebar.children.length-1].classList[1] + ">div:nth-child(1) { top: 0; }"); | |
// NEGATIVE SPAAAAAAAAAAAAAAAACEEEEEEE | |
style.insertRule("." + base.classList[1] + " { padding: 0; margin: 0; max-width: initial; }"); | |
style.insertRule("." + base.children[1].classList[1] + " { margin-left: 0; }"); | |
style.insertRule( | |
"." + sidebar.children[0].classList[1] + ", " + | |
"." + sidebar.children[0].classList[1] + ">div, " + | |
"." + sidebar.children[1].classList[1] + ", " + | |
"." + sidebar.children[1].classList[1] + ">div" + | |
" { border-radius: 0; border: none; box-shadow: none; }"); | |
style.insertRule("." + sidebar.children[1].classList[1] + " { margin-top: 0; }"); | |
// Dynamic shit | |
try | |
{ | |
for (var css of document.styleSheets) | |
{ | |
for (var rule of css.cssRules) | |
{ | |
if (rule instanceof CSSMediaRule) | |
{ | |
// Cards | |
if (rule.cssText.indexOf("648px") != -1) | |
{ | |
style.insertRule(rule.cssRules[0].selectorText + " { width: 100%; }"); | |
style.insertRule(rule.cssRules[0].selectorText + " div.scrollerItem { margin-bottom: 0; border-radius: 0; border-width: 1px 0px 0px 0px; }"); | |
} | |
else if (rule.cssText.indexOf("calc(((100% + 0px) - 984px) / 2)") != -1) | |
{ | |
style.insertRule(rule.cssRules[0].selectorText + " { left: 24px; }"); | |
} | |
else if (rule.cssText.indexOf("864px") != -1) | |
{ | |
style.insertRule(rule.cssRules[0].selectorText + " { width: 100%; }"); | |
style.insertRule(rule.cssRules[0].selectorText + ">div { max-width: initial; border-radius: 0; }"); | |
} | |
} | |
} | |
} | |
} | |
catch (e) | |
{ | |
// Failed to read bla bla bla | |
} | |
// Ads | |
// If only there was :has... | |
style.insertRule("div[data-slot] { display: none; }"); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment