Last active
June 21, 2017 15:20
-
-
Save JayPanoz/456b3c65c8e56d1f09c93056fbaa67e8 to your computer and use it in GitHub Desktop.
Dauwhe’s magical mystery Reading System
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
/* Dauwhe’s magical mystery Reading System | |
A quick and dirty proto to implement https://twitter.com/dauwhe/status/877533923567390721 | |
This is the future of ebooks’ default stylesheet | |
#TrollingIsMyFuel | |
*/ | |
r(function() { | |
var style = document.createElement("style"); | |
style.id = "ImSorryDaveImAfraidICanDoThat"; | |
style.type = "text/css"; | |
// Sets to randomize dat shit | |
var fonts = ["Athelas, serif", "Charter, serif", "Georgia, serif", "'Iowan Old Style', serif", "Palatino, serif", "-apple-system, BlinkMacSystemFont, sans-serif", "Seravek, sans-serif", "'Times New Roman', serif", "'Comic Sans MS', sans-serif", "Verdana, sans-serif", "SimHei, STHeiti, serif"], | |
sizes = ["1em", "1.1em", "1.2em", "1.4em", "1.5em", "1.7em", "1.9em", "2em", "2.6em", "3.4em", "4.5em", "6.7em"], | |
lineHeights = ["0.75", "1", "1.2", "1.25", "1.38974738774", "1.5", "1.55780768374", "1.65", "1.75", "2.0000000001"], | |
backgrounds = ["#FFF", "#000", "#704214", "#00FFFF", "#00FF7F"], | |
colors = ["#FAFAFA", "#666", "#0000EE", "#551A8B", "#ff0000"], | |
displays = ["block", "inline", "inline-block", "list-item", "flex", "table"], | |
floats = ["none", "left", "right"], | |
margins = ["-20px", "0", "13.45px", "20em", "45%", "140vmin"], | |
paddings= ["0", "0.5px", "1em", "2%", "3vh", "5vmax"]; | |
var randomStyles = document.createTextNode(':root {background-color:' + backgrounds[Math.floor(Math.random() * backgrounds.length)] + '!important; color:' + colors[Math.floor(Math.random() * colors.length)] + '!important;} * { display:' + displays[Math.floor(Math.random() * displays.length)] + '; float:' + floats[Math.floor(Math.random() * colors.length)] + '; margin:' + margins[Math.floor(Math.random() * margins.length)] + '; padding:' + paddings[Math.floor(Math.random() * paddings.length)] + '; font-size:' + sizes[Math.floor(Math.random() * sizes.length)] + '; line-height:' + lineHeights[Math.floor(Math.random() * lineHeights.length)] + '; font-family:' + fonts[Math.floor(Math.random() * fonts.length)] + '!important; }'); | |
style.appendChild(randomStyles); | |
document.head.appendChild(style); | |
}); | |
function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment