您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Highlight codeblocks with Highlight.js
// ==UserScript== // @name Ylilauta code highlighter // @namespace Violentmonkey Scripts // @match *://ylilauta.org/* // @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js // @grant none // @version 0.2 // @locale en // @description Highlight codeblocks with Highlight.js // ==/UserScript== const loadCSS = () => { const css = document.createElement('link') css.rel = 'stylesheet' css.href = 'https://gitcdn.xyz/repo/isagalaev/highlight.js/cf4b46e5b7acfe2626a07914e1d0d4ef269aed4a/src/styles/darcula.css' document.head.insertBefore(css, document.head.lastChild) } const transform = () => { Array.from(document.querySelectorAll('pre[class="pre"]')) .map((pre) => hljs.highlightBlock(pre)) } loadCSS() transform() const targetDiv = document.querySelector('div.answers') const config = { childList: true } const observer = new MutationObserver( (mutationsList) => { if (Array.from(mutationsList).filter( (mutation) => mutation.type === 'childList').length > 0) { transform() } } ) observer.observe(targetDiv, config)