🏠 返回首頁 

Greasy Fork is available in English.

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