syntax-highlighting

Add syntax highlight to code blocks on the REAPER forum

安裝腳本?
作者推薦腳本

您可能也會喜歡 original-poster

安裝腳本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        syntax-highlighting
// @description Add syntax highlight to code blocks on the REAPER forum
// @namespace   https://cfillion.ca
// @version     1.0.3
// @author      cfillion
// @license     GPL-3.0-or-later
// @include     https://forum.cockos.com/showthread.php*
// @include     https://forum.cockos.com/showpost.php*
// @include     https://forum.cockos.com/editpost.php*
// @include     https://forum.cockos.com/newreply.php*
// @require     https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.3/highlight.min.js
// ==/UserScript==

// highlight.js v11 removed auto-merging of html (removes links) 

var theme = document.createElement('link');
theme.rel = 'stylesheet';
theme.href = 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.3/styles/sunburst.min.css';
document.body.appendChild(theme);

var style = document.createElement('style');
style.textContent = `
  pre.alt2 a:link, pre.alt2 a:visited { color: white; }
  pre.alt2 font { color: inherit; }
`;
document.body.appendChild(style);

hljs.configure({
  tabReplace: '\x20'.repeat(2),
  languages: ['lua', 'cpp'],
});

document.querySelectorAll('pre.alt2').forEach(hljs.highlightBlock);