[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.

当前为 2015-11-12 提交的版本,查看 最新版本

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