// ==UserScript== // // @name AutoHotkey Scripts Comment Coloring // @author Philippe Lhoste aka. PhiLho, based on Titan's code // @namespace http://Phi.Lho.free.fr/ // @description Colorize inside PRE (CODE class) the comments of AHK scripts. // @version 1.00.000 // @include http://www.autohotkey.com/forum/viewtopic.php?* // // ==/UserScript== /* Copyright notice: For details, see the following file: http://Phi.Lho.free.fr/softwares/PhiLhoSoft/PhiLhoSoftLicence.txt This program is distributed under the zlib/libpng license. Copyright (c) 2006 Philippe Lhoste / PhiLhoSoft */ var container = "td", containerClass = "code"; // container and class name var b = document.getElementsByTagName("head"); b[0].innerHTML += '\n<style type="text/css">\n.MLC { background-color: #EEE; color: #888; }\n.SLC { color: #AAA; }\n</style>\n'; var e = document.getElementsByTagName(container); for (var i = 0; i < e.length; i++) // Loop on all PRE blocks if (e[i].className == containerClass) // That's the right class (we never know...) { var html = e[i].innerHTML; var prevLen = html.len; var commentDelimiter = ";"; var newCommentDelimiter = /^(?:\s| )*#CommentFlag(?:\s| )+(\S+)\s/mi.exec(html); if (newCommentDelimiter != null) commentDelimiter = newCommentDelimiter[1]; var regex = new RegExp("(\\s| |^)(" + commentDelimiter + ".*)$", "mg"); html = html.replace(regex, '$1<span class="SLC">$2</span>'); html = html.replace( /^((?:\s| )*\/\*(.|\r|\n)*?^(?:\s| )*\*\/)/mg, '<span class="MLC">$1</span>'); e[i].innerHTML = html; }I have this code in AutoHotkey_scripts_comment_coloring.user.js
To use it, just drag'n'drop this file in Mozilla (with GM installed, of course). GM identify it as script for it, and will ask if you want to install it. Accept, of course.
[EDIT] Better handling of