Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
javacript: web page night mode
var nightCss = 'html,body,div,span,applet,object,'
+ 'h1,h2,h3,h4,h5,h6,p,blockquote,'
+ 'pre,abbr,acronym,address,big,cite,'
+ 'code,del,dfn,em,font,img,ins,kbd,'
+ 'q,s,samp,small,strike,strong,sub,'
+ 'sup,tt,var,b,u,i,center,dl,dt,dd,'
+ 'ol,ul,li,fieldset,form,label,'
+ 'legend,table,caption,tbody,tfoot,thead,th,td'
+ '{background:#333333 !important;'
+ 'color:#A0A0A0 !important;'
+ 'border-color:#A0A0A0 !important;} input,button,textarea,select,option,optgroup'
+ '{background-color:#444444 !important;'
+ 'color:#CCCCCC !important;'
+ 'border-color:#A0A0A0 !important;} a,a *{color:#93BCEC !important;'
+ 'background-color:#333333 !important;} a:active,a:hover,a:active *,a:hover'
+ '*{color:#1F72D0 !important;'
+ 'background-color:#C0C0C0 !important;} img[src],'
+ 'input[type=image] {opacity:.5}'
+ 'img[src]:hover, input[type=image]:hover {opacity:1}';
var nightNodeName = 'jike-night';
function setNightMode() {
var nightModeStyle = null;
if (document.getElementById(nightNodeName)) return;
nightModeStyle = document.createElement('style');
nightModeStyle.id = nightNodeName;
nightModeStyle.innerHTML = nightCss;
document.body.appendChild(nightModeStyle);
}
function setDayMode() {
var nightModeStyle = document.getElementById(nightNodeName);
if (nightModeStyle) {
document.body.removeChild(nightModeStyle);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.