Skip to content

Instantly share code, notes, and snippets.

@vyznev
Last active May 25, 2016 18:04
Show Gist options
  • Save vyznev/9a3c5ddac714ac199166 to your computer and use it in GitHub Desktop.
Save vyznev/9a3c5ddac714ac199166 to your computer and use it in GitHub Desktop.
This user script makes all Stack Exchange Q&A sites use the generic beta site theme
// ==UserScript==
// @name Stack Exchange beta theme everywhere
// @namespace http://vyznev.net/
// @description Makes all Stack Exchange sites use the generic beta site theme
// @author Ilmari Karonen
// @version 0.5.2
// @license Public domain
// @homepageURL http://meta.stackexchange.com/a/275804
// @match *://*.stackexchange.com/*
// @match *://*.stackoverflow.com/*
// @match *://*.superuser.com/*
// @match *://*.serverfault.com/*
// @match *://*.stackapps.com/*
// @match *://*.mathoverflow.net/*
// @match *://*.askubuntu.com/*
// @exclude *://stackexchange.com/*
// @exclude *://chat.*
// @exclude *://blog.*
// @exclude *://area51.*
// @exclude *://careers.*
// @exclude *://openid.*
// @exclude *://data.*
// @run-at document-start
// @grant none
// ==/UserScript==
var skin = 'beta';
var meta = (/(^|\.)(meta|discuss)\./.test(location.hostname) ? 'meta' : '');
function observeElement ( element, callback ) {
if ( callback() ) return;
var observer = new MutationObserver( function () {
if ( callback() ) observer.disconnect();
} );
observer.observe( element, { childList: true, subtree: false } );
}
observeElement( document.documentElement, function () {
var head = document.head;
if (head) observeElement( head, function () {
var link = head.querySelector('link[rel=stylesheet][href*="/all.css"]');
if (link) link.href = '//cdn.sstatic.net/Sites/' + skin + meta + '/all.css';
return link;
} );
return head;
} );
var extraStyle = document.createElement('style');
extraStyle.textContent = '#custom-content { display: none }';
(document.head || document.documentElement).appendChild(extraStyle);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment