Skip to content

Instantly share code, notes, and snippets.

@birjj
Created October 5, 2018 12:14
Show Gist options
  • Save birjj/a03368a1b4db31ba035fe023131b1f09 to your computer and use it in GitHub Desktop.
Save birjj/a03368a1b4db31ba035fe023131b1f09 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name /r/EU4 styles
// @namespace https://github.com/birjolaxew/r-EU4-styles
// @version 1.0
// @description Add custom CSS style to /r/EU4
// @author birjolaxew
// @match https://www.reddit.com/r/eu4/*
// @run-at document-body
// @grant none
// ==/UserScript==
(function() {
'use strict';
console.log("Injecting /r/EU4 styles");
[...document.querySelectorAll("link[ref='applied_subreddit_stylesheet']")].forEach($link => $link.parentNode.removeChild($link));
const $link = document.createElement("link");
$link.setAttribute("rel", "stylesheet");
$link.setAttribute("type", "text/css");
$link.setAttribute("ref", "applied_subreddit_stylesheet");
$link.setAttribute("title", "applied_subreddit_stylesheet");
$link.href = "https://www.reddit.com/r/birjolaxewssubreddit/stylesheet";
document.head.appendChild($link);
const img = new Image("https://raw.githubusercontent.com/birjolaxew/r-EU4-styles/master/resources/shield_logo.png");
document.addEventListener("DOMContentLoaded", () => {
const $logo = document.getElementById("header-img");
$logo.src = "https://raw.githubusercontent.com/birjolaxew/r-EU4-styles/master/resources/shield_logo.png";
$logo.width = 114;
$logo.height = 114;
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment