|
1 | 1 | // ==UserScript==
|
2 | 2 | // @name GitHub Collapse In Comment
|
3 |
| -// @version 1.0.12 |
| 3 | +// @version 1.0.13 |
4 | 4 | // @description A userscript that adds a header that can toggle long code and quote blocks in comments
|
5 | 5 | // @license MIT
|
6 | 6 | // @author Rob Garrison
|
|
12 | 12 | // @grant GM_getValue
|
13 | 13 | // @grant GM_setValue
|
14 | 14 | // @grant GM_registerMenuCommand
|
15 |
| -// @require https://greasyfork.org/scripts/28721-mutations/code/mutations.js?version=198500 |
16 |
| -// @icon https://github.com/fluidicon.png |
| 15 | +// @require https://greasyfork.org/scripts/28721-mutations/code/mutations.js?version=234970 |
| 16 | +// @icon https://assets-cdn.github.com/pinned-octocat.svg |
17 | 17 | // @updateURL https://raw.githubusercontent.com/Mottie/GitHub-userscripts/master/github-collapse-in-comment.user.js
|
18 | 18 | // @downloadURL https://raw.githubusercontent.com/Mottie/GitHub-userscripts/master/github-collapse-in-comment.user.js
|
19 | 19 | // ==/UserScript==
|
|
29 | 29 | // hide code/quotes longer than this number of lines
|
30 | 30 | let minLines = GM_getValue("gcic-max-lines", 10),
|
31 | 31 | startCollapsed = GM_getValue("gcic-start-collapsed", true);
|
| 32 | + // extract syntax type from class name |
| 33 | + const regex = /highlight(?:-[^\s]+)+/; |
32 | 34 |
|
33 | 35 | // syntax highlight class name lookup table
|
34 | 36 | const syntaxClass = {
|
|
85 | 87 | highlight-source-fortran-modern
|
86 | 88 | highlight-text-tex
|
87 | 89 | */
|
88 |
| - let n = (name || "").replace( |
89 |
| - /(highlight[-\s]|(source-)|(text-)|(html-)|(markdown-)|(-modern))/g, "" |
90 |
| - ); |
91 |
| - n = (syntaxClass[n] || n).toUpperCase().trim(); |
| 90 | + let n = (name || "").match(regex); |
| 91 | + if (n && n[0]) { |
| 92 | + n = n[0].replace( |
| 93 | + /(highlight[-\s]|(source-)|(text-)|(html-)|(markdown-)|(-modern))/g, "" |
| 94 | + ); |
| 95 | + n = (syntaxClass[n] || n).toUpperCase().trim(); |
| 96 | + } |
92 | 97 | return `${n || "Block"} (${lines} lines)`;
|
93 | 98 | }
|
94 | 99 |
|
|
0 commit comments