Last active
February 19, 2018 10:09
-
-
Save DeflatedPickle/63e7c1abcecf2470812543ab0d117660 to your computer and use it in GitHub Desktop.
A NodeJS script that switches CSS depending on the current OS (for Electron).
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Index</title> | |
<script rel="script" type="text/javascript" src="switcher.js"></script> | |
</head> | |
<body> | |
<h1>Title</h1> | |
</body> | |
</html> |
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
body { | |
background: darkgray; | |
} |
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
body { | |
background: white; | |
} |
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
const os = require("os"); | |
function loadCSS(path) { | |
if (!document.getElementById) { | |
document.write('<link rel="stylesheet" type="text/css" href=path>'); | |
} | |
} | |
switch (os.platform()) { | |
case "win32": | |
console.log("Windows"); | |
loadCSS("win32.css"); | |
break; | |
case "darwin": | |
console.log("OSX"); | |
loadCSS("osx.css"); | |
break; | |
case "linux": | |
console.log("Linux"); | |
loadCSS("linux.css"); | |
break; | |
default: | |
console.log("Other: %s", os.platform()); | |
} |
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
body { | |
background: lightgray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment