Last active
November 12, 2017 06:01
-
-
Save redspider/5b1c5489e8e681f46f318feebb28c9a0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function phnInjectMultiStyleHeader() { | |
if (document.getElementById('phn-multi-style-header')) { | |
return; | |
} | |
const HEAD = document.getElementsByTagName('head')[0]; | |
const STYLE = HEAD.appendChild(document.createElement('style')); | |
STYLE.setAttribute('id', 'phn-multi-stye-header'); | |
STYLE.innerHTML = "" + | |
"body.phn-white-theme," + | |
".phn-white-theme blockquote cite," + | |
".phn-white-theme blockquote small," + | |
".phn-white-theme .main-navigation a," + | |
".phn-white-theme .menu-toggle," + | |
".phn-white-theme .dropdown-toggle," + | |
".phn-white-theme .social-navigation a," + | |
".phn-white-theme .post-navigation a," + | |
".phn-white-theme .pagination a:hover," + | |
".phn-white-theme .pagination a:focus," + | |
".phn-white-theme .widget-title a," + | |
".phn-white-theme .site-branding .site-title a," + | |
".phn-white-theme .entry-title a," + | |
".phn-white-theme .page-links > .page-links-title," + | |
".phn-white-theme .comment-author," + | |
".phn-white-theme .comment-reply-title small a:hover," + | |
".phn-white-theme .comment-reply-title small a:focus {" + | |
"color: black;" + | |
"}" + | |
".phn-white-theme .site {" + | |
"background-color: white;" + | |
"}" + | |
"body.phn-white-theme.custom-background {" + | |
"background-color: white;" + | |
"}" + | |
".phn-white-theme blockquote," + | |
".phn-white-theme .post-password-form label," + | |
".phn-white-theme a:hover, a:focus, a:active," + | |
".phn-white-theme .post-navigation .meta-nav," + | |
".phn-white-theme .image-navigation," + | |
".phn-white-theme .comment-navigation," + | |
".phn-white-theme .widget_recent_entries" + | |
".phn-white-theme .post-date," + | |
".phn-white-theme .widget_rss" + | |
".phn-white-theme .rss-date," + | |
".phn-white-theme .widget_rss cite," + | |
".phn-white-theme .site-description," + | |
".phn-white-theme .author-bio," + | |
".phn-white-theme .entry-footer," + | |
".phn-white-theme .entry-footer a," + | |
".phn-white-theme .sticky-post," + | |
".phn-white-theme .taxonomy-description," + | |
".phn-white-theme .entry-caption," + | |
".phn-white-theme .comment-metadata," + | |
".phn-white-theme .pingback .edit-link," + | |
".phn-white-theme .comment-metadata a," + | |
".phn-white-theme .pingback .comment-edit-link," + | |
".phn-white-theme .comment-form label," + | |
".phn-white-theme .comment-notes," + | |
".phn-white-theme .comment-awaiting-moderation," + | |
".phn-white-theme .logged-in-as," + | |
".phn-white-theme .form-allowed-tags," + | |
".phn-white-theme .site-info," + | |
".phn-white-theme .site-info a," + | |
".phn-white-theme .wp-caption .wp-caption-text," + | |
".phn-white-theme .gallery-caption," + | |
".phn-white-theme .widecolumn label," + | |
".phn-white-theme .widecolumn .mu_register label {" + | |
"color: #404040;" + | |
"}" + | |
"body:not(.custom-background-image):before { display: none }" + | |
"#phn-theme-toggle {" + | |
"position: absolute;" + | |
"top: 0px;" + | |
"right: 0px;" + | |
"cursor: pointer;" + | |
"width: 30px;" + | |
"height: 30px;" + | |
"text-align: center;" + | |
"line-height: 30px;" + | |
"background-color: #333;" + | |
"color: #111;" + | |
"font-size: 18px;" + | |
"font-weight: bold;" + | |
"user-select: none;" + | |
"}" + | |
"#phn-theme-toggle:hover {" + | |
"background-color: white;" + | |
"color: black;" + | |
"}" + | |
".phn-white-theme #phn-theme-toggle {" + | |
"background-color: #ddd;" + | |
"color: white;" + | |
"}" + | |
".phn-white-theme #phn-theme-toggle:hover {" + | |
"background-color: black;" + | |
"color: white;" + | |
"}"; | |
} | |
function phnSetWhiteTheme() { | |
var BODY = document.getElementsByTagName('body')[0]; | |
BODY.className = BODY.className + ' phn-white-theme'; | |
if (window.localStorage) { | |
window.localStorage.setItem('phn-theme', 'white'); | |
} | |
} | |
function phnUnsetWhiteTheme() { | |
var BODY = document.getElementsByTagName('body')[0]; | |
BODY.className = BODY.className.replace(' phn-white-theme', ''); | |
if (window.localStorage) { | |
window.localStorage.removeItem('phn-theme'); | |
} | |
} | |
function phnToggleTheme() { | |
if (document.getElementsByTagName('body')[0].className.indexOf('phn-white-theme') >= 0) { | |
phnUnsetWhiteTheme(); | |
} else { | |
phnSetWhiteTheme(); | |
} | |
} | |
function phnInjectTheme() { | |
phnInjectMultiStyleHeader(); | |
if (document.getElementById('phn-theme-toggle')) { | |
return; | |
} | |
const BODY = document.getElementsByTagName('body')[0]; | |
const TOGGLE = BODY.appendChild(document.createElement('a')); | |
TOGGLE.setAttribute('id', 'phn-theme-toggle') | |
TOGGLE.innerHTML = 'A'; | |
document.getElementById('phn-theme-toggle').addEventListener('click', function (e) { | |
e.preventDefault(); | |
phnToggleTheme(); | |
}); | |
} | |
function phnOnLoad() { | |
phnInjectTheme(); | |
if (window.localStorage) { | |
if (window.localStorage.getItem('phn-theme') === 'white') { | |
phnSetWhiteTheme(); | |
} | |
} | |
} | |
phnOnLoad(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment