您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds syntax highlighting to the Unity Documentation. Forked from hyblocker.
当前为
- // ==UserScript==
- // @name Unity Docs Syntax Hightligher Fork
- // @namespace Violentmonkey Scripts
- // @version 1.2
- // @author Maoyeedy
- // @license MIT
- // @description Adds syntax highlighting to the Unity Documentation. Forked from hyblocker.
- //
- // @match https://docs.unity3d.com/Manual/*
- // @match https://docs.unity3d.com/ScriptReference/*
- // @match https://docs.unity3d.com/*/Manual/*
- // @match https://docs.unity3d.com/*/ScriptReference/*
- //
- // @grant GM_getResourceText
- // @grant GM_addStyle
- //
- // @require https://cdn.jsdelivr.net/npm/prismjs@1.29.0/prism.js
- // @require https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-c.min.js
- // @require https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-clike.min.js
- // @require https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-csharp.min.js
- // @require https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-hlsl.min.js
- // @resource PRISM_THEME_LIGHT https://cdn.jsdelivr.net/gh/PrismJS/prism-themes/themes/prism-one-light.css
- // @resource PRISM_THEME_DARK https://cdn.jsdelivr.net/gh/PrismJS/prism-themes/themes/prism-duotone-dark.css
- //
- // Recommended Light Themes
- // https://cdn.jsdelivr.net/npm/prismjs/themes/prism.min.css
- // https://cdn.jsdelivr.net/gh/PrismJS/prism-themes/themes/prism-one-light.css
- //
- // Recommended Dark Themes
- // https://cdn.jsdelivr.net/gh/PrismJS/prism-themes/themes/prism-xonokai.css
- // https://cdn.jsdelivr.net/gh/PrismJS/prism-themes/themes/prism-duotone-dark.css
- //
- // Extra Themes
- // https://github.com/PrismJS/prism-themes
- //
- // ==/UserScript==
- (function() {
- 'use strict';
- GM_addStyle(GM_getResourceText("PRISM_THEME_LIGHT"));
- //GM_addStyle(GM_getResourceText("PRISM_THEME_DARK"));
- // Inject custom CSS
- const customCSS = `
- code {
- font-family: 'Jetbrains Mono', monospace !important;
- font-size: 0.875em !important;
- }
- pre[class*=language-]{
- border-radius:.5em;
- }
- `;
- const styleElement = document.createElement('style');
- styleElement.type = 'text/css';
- styleElement.appendChild(document.createTextNode(customCSS));
- document.head.appendChild(styleElement);
- }());
- const CSHARP = 0;
- const HLSL = 1;
- var waitForGlobal = function(key, callback) {
- if (window[key]) {
- callback();
- } else {
- setTimeout(function() {
- waitForGlobal(key, callback);
- }, 100);
- }
- };
- function waitForLangLoad(lang, callback) {
- if (Prism.util.getLanguage(lang) != null) {
- callback();
- } else {
- setTimeout(function() {
- waitForLangLoad(lang, callback);
- }, 100);
- }
- }
- function detectCodeLanguage(elem) {
- if (elem.classList.contains('codeExampleCS')) {
- return CSHARP;
- }
- if (elem.innerHTML.match(/CGPROGRAM|ENDCG|CGINCLUDE|#pragma|SubShader \"/g) != null) {
- return HLSL;
- }
- return CSHARP;
- }
- waitForGlobal("Prism", () => {
- waitForLangLoad("csharp", () => {
- waitForLangLoad("hlsl", () => {
- document.querySelectorAll('.content-wrap pre').forEach((el) => {
- el.innerHTML = el.innerHTML.replace(/\<br\>/g, '\n');
- if (detectCodeLanguage(el) == CSHARP) {
- el.classList.add("language-csharp");
- } else {
- el.classList.add("language-hlsl");
- }
- if (el.firstChild.nodeName != 'CODE') {
- el.innerHTML = `<code>${el.innerHTML}</code>`;
- }
- });
- });
- });
- });