[docs.unity3d & local] Unity Black - a dark theme with JS/C# syntax highlighting

A beautiful dark theme with syntax highlighting (4 color schemes, JS & C#) that improves visual code samples and lowers screen glare.

  1. // ==UserScript==
  2. // @name [docs.unity3d & local] Unity Black - a dark theme with JS/C# syntax highlighting
  3. // @namespace https://greasyfork.org/en/users/10118-drhouse
  4. // @version 1.1
  5. // @description A beautiful dark theme with syntax highlighting (4 color schemes, JS & C#) that improves visual code samples and lowers screen glare.
  6. // @include http://docs.unity3d.com/*
  7. // @include https://docs.unity3d.com/*
  8. // @include file://*Editor/Data/Documentation/*
  9. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  10. // @require http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/highlight.min.js
  11. // @resource bold https://raw.githubusercontent.com/daylerees/colour-schemes/master/highlightjs/bold.css
  12. // @resource grayscale https://raw.githubusercontent.com/idleberg/base16-highlight.js/master/base16-grayscale.dark.css
  13. // @resource ocean https://raw.githubusercontent.com/idleberg/base16-highlight.js/master/base16-ocean.dark.css
  14. // @resource tomorrow https://raw.githubusercontent.com/idleberg/base16-highlight.js/master/base16-tomorrow.dark.css
  15. // @grant GM_getValue
  16. // @grant GM_setValue
  17. // @grant GM_deleteValue
  18. // @grant GM_addStyle
  19. // @grant GM_getResourceText
  20. // @author drhouse
  21. // @icon http://docs.unity3d.com/StaticFiles/images/favicons/favicon.ico
  22. // ==/UserScript==
  23.  
  24. this.$ = this.jQuery = jQuery.noConflict(true);
  25.  
  26. $(document).ready(function() {
  27. function bold(){
  28. GM_addStyle(GM_getResourceText("bold"));
  29. $('pre').each(function(i, block) {
  30. hljs.highlightBlock(block);
  31. });
  32. $('code').each(function(i, block) {
  33. hljs.highlightBlock(block);
  34. });
  35. }
  36. function github(){
  37. GM_addStyle(GM_getResourceText("github"));
  38. $('pre').each(function(i, block) {
  39. hljs.highlightBlock(block);
  40. });
  41. $('code').each(function(i, block) {
  42. hljs.highlightBlock(block);
  43. });
  44. }
  45.  
  46. function grayscale(){
  47. GM_addStyle(GM_getResourceText("grayscale"));
  48. $('pre').each(function(i, block) {
  49. hljs.highlightBlock(block);
  50. });
  51. $('code').each(function(i, block) {
  52. hljs.highlightBlock(block);
  53. });
  54. }
  55.  
  56. function ocean(){
  57. GM_addStyle(GM_getResourceText("ocean"));
  58. $('pre').each(function(i, block) {
  59. hljs.highlightBlock(block);
  60. });
  61. $('code').each(function(i, block) {
  62. hljs.highlightBlock(block);
  63. });
  64. }
  65.  
  66. function tomorrow(){
  67. GM_addStyle(GM_getResourceText("tomorrow"));
  68. $('pre').each(function(i, block) {
  69. hljs.highlightBlock(block);
  70. });
  71. $('code').each(function(i, block) {
  72. hljs.highlightBlock(block);
  73. });
  74. }
  75.  
  76. //init style
  77. //bold();
  78. //github();
  79. //grayscale();
  80. ocean();
  81. //tomorrow();
  82.  
  83. //style selector
  84. $("<div id='rock1'></div>").appendTo('pre.codeExampleCS');
  85. $("<div id='rock'></div>").appendTo('pre');
  86. $('#rock').html('<a id="bold">bold</a> | <a id="grayscale">grayscale</a> | <a id="ocean">ocean</a> | <a id="tomorrow">tomorrow</a> ')
  87. .css('position', 'absolute')
  88. .css('top', '0px')
  89. .css('right', '0px')
  90. .css('float', 'right');
  91.  
  92. $('#rock1').html('<a id="bold1">bold</a> | <a id="grayscale1">grayscale</a> | <a id="ocean1">ocean</a> | <a id="tomorrow1">tomorrow</a> ')
  93. .css('position', 'absolute')
  94. .css('top', '0px')
  95. .css('right', '0px')
  96. .css('float', 'right');
  97.  
  98.  
  99. //add bg image logo
  100. $('pre').css('font-size', '0.8em').css('font-family', 'Consolas')
  101. .css('position', 'relative')
  102. .css('background-image','url("http://i.imgur.com/keF6WXn.png") ')
  103. .css('background-image','width:10px')
  104. .css('background-position','top right')
  105. .css('background-repeat','no-repeat')
  106. .css('padding','1px');
  107.  
  108. $('code').css('position', 'relative')
  109. .css('position', 'relative')
  110. .css('background-image','url("http://i.imgur.com/keF6WXn.png") ')
  111. .css('background-image','width:10px')
  112. .css('background-position','top right')
  113. .css('background-repeat','no-repeat')
  114. .css('padding','1px');
  115.  
  116.  
  117. var styleName;
  118. $("pre").on("click", function(e) {
  119. $("#bold").click(function(e) {
  120. e.preventDefault();
  121. bold();
  122. styleName = 'bold';
  123. GM_setValue("unitystyle", styleName);
  124. });
  125. $("#grayscale").click(function(e) {
  126. e.preventDefault();
  127. grayscale();
  128. styleName = 'grayscale';
  129. GM_setValue("unitystyle", styleName);
  130. });
  131. $('#ocean').on('click', function (e) {
  132. e.preventDefault();
  133. ocean();
  134. styleName = 'ocean';
  135. GM_setValue("unitystyle", styleName);
  136. });
  137. $('#tomorrow').on('click', function (e) {
  138. e.preventDefault();
  139. tomorrow();
  140. styleName = 'tomorrow';
  141. GM_setValue("unitystyle", styleName);
  142. });
  143. });
  144.  
  145. $("pre.codeExampleCS").on("click", function(e) {
  146. $("#bold1").click(function(e) {
  147. e.preventDefault();
  148. bold();
  149. styleName = 'bold';
  150. GM_setValue("unitystyle", styleName);
  151. });
  152. $("#grayscale1").click(function(e) {
  153. e.preventDefault();
  154. grayscale();
  155. styleName = 'grayscale';
  156. console.log('cs gscale');
  157. GM_setValue("unitystyle", styleName);
  158. });
  159. $('#ocean1').on('click', function (e) {
  160. e.preventDefault();
  161. ocean();
  162. styleName = 'ocean';
  163. GM_setValue("unitystyle", styleName);
  164. });
  165. $('#tomorrow1').on('click', function (e) {
  166. e.preventDefault();
  167. tomorrow();
  168. styleName = 'tomorrow';
  169. GM_setValue("unitystyle", styleName);
  170. });
  171. });
  172.  
  173. var c = GM_getValue("unitystyle");
  174. console.log('get '+c);
  175. if (c == "bold"){
  176. $("#bold").click();
  177. $("#bold").click();
  178. }
  179. if (c == "grayscale"){
  180. $("#grayscale").click();
  181. $("#grayscale").click();
  182. }
  183. if (c == "ocean"){
  184. $("#ocean").click();
  185. $("#ocean").click();
  186. }
  187. if (c == "tomorrow"){
  188. $("#tomorrow").click();
  189. $("#tomorrow").click();
  190. }
  191.  
  192.  
  193. //css style
  194. $('html').css('background-color', '#1A1B1C');
  195. $('body').css('color', '#fff');
  196. $('a').css('color', '#fff');
  197. $('h1').css('color', '#fff');
  198. $('h2').css('color', '#fff');
  199. $('.subsection').css('color', '#ccc');
  200. $('table').css('background', '#222');
  201. $('th').css('background', '#222c37');
  202. $('div.toolbar').css('background', '#1A1B1C');
  203. $('h1 h2 p span a').css('background-color', '#fff !important');
  204. $('td').css('border-style', 'ridge')
  205. .css('border-width', '2px !important')
  206. .css('border-color', '#fff !important')
  207. .css('color', '#fff !important')
  208. .css('background-color', '#44474D !important');
  209. $('td.desc').css('border-width', '2px !important')
  210. .css('border-color', '#fff !important')
  211. .css('color', '#CACCD0 !important')
  212. .css('background-color', '#414449 !important');
  213. $('table.list tr:hover').css('outline', '#009393 2px solid !important');
  214. $('table.list tr:nth-child(odd)').css('background-color', '#222');
  215. $('table.list tr:nth-child(even)').css('background-color', '#222');
  216. $('.filler').css('background-color', '#222c37');
  217. $('.mCSB_draggerRail').css('background-color', '#000!important');
  218. $('.mCSB_dragger_bar').css('background-color', '#333');
  219. $('div.sidebar-wrap').css('background-color', '#1A1B1C')
  220. .css('width', '339px')
  221. .css('position', 'fixed')
  222. .css('border-right', '#000 0px dashed');
  223. $('div.arrow').css('background', '#27292C url("http://docs.unity3d.com/StaticFiles/images/sprites.png") 0 0 no-repeat')
  224. .css('border', '#9ca9be 1px solid');
  225. $('.nextprev').css('background', '#222c37')
  226. .css('padding', '0px');
  227. $('body > div.header-wrapper > div.toolbar > div > div.script-lang').css('color','#222c37');
  228. $('body > div.header-wrapper > div.toolbar > div > div > div.lang-list > ul > li > a').css('color','black');
  229. //*/
  230.  
  231. });