|
1 | 1 | // ==UserScript==
|
2 | 2 | // @name GitHub Code Folding
|
3 |
| -// @version 1.1.2 |
| 3 | +// @version 1.1.3 |
4 | 4 | // @description A userscript that adds code folding to GitHub files
|
5 | 5 | // @license MIT
|
6 | 6 | // @author Rob Garrison
|
|
12 | 12 | // @grant GM_addStyle
|
13 | 13 | // @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js?updated=20180103
|
14 | 14 | // @require https://greasyfork.org/scripts/28721-mutations/code/mutations.js?version=882023
|
| 15 | +// @require https://greasyfork.org/scripts/398877-utils-js/code/utilsjs.js?version=895926 |
15 | 16 | // @icon https://github.githubassets.com/pinned-octocat.svg
|
16 | 17 | // @updateURL https://raw.githubusercontent.com/Mottie/Github-userscripts/master/github-code-folding.user.js
|
17 | 18 | // @downloadURL https://raw.githubusercontent.com/Mottie/Github-userscripts/master/github-code-folding.user.js
|
18 | 19 | // @supportURL https://github.com/Mottie/GitHub-userscripts/issues
|
19 | 20 | // ==/UserScript==
|
20 |
| -/* global GM */ |
| 21 | +/* global $ $$ on */ |
21 | 22 | /**
|
22 | 23 | * This userscript has been heavily modified from the "github-code-folding"
|
23 | 24 | * Chrome extension Copyright 2016 by Noam Lustiger; under an MIT license
|
|
141 | 142 | }
|
142 | 143 |
|
143 | 144 | function addBindings() {
|
144 |
| - document.addEventListener("click", event => { |
| 145 | + on(document, "click", event => { |
145 | 146 | let index, elm, isCollapsed;
|
146 | 147 | const el = event.target;
|
147 | 148 | const codeBlock = el.closest(".highlight");
|
|
238 | 239 | }
|
239 | 240 | }
|
240 | 241 |
|
241 |
| - function $(selector, el) { |
242 |
| - return (el || document).querySelector(selector); |
243 |
| - } |
244 |
| - |
245 |
| - function $$(selector, el) { |
246 |
| - return Array.from((el || document).querySelectorAll(selector)); |
247 |
| - } |
248 |
| - |
249 | 242 | function removeEls(selector, el) {
|
250 | 243 | let els = $$(selector, el);
|
251 | 244 | let index = els.length;
|
|
268 | 261 | }
|
269 | 262 | }
|
270 | 263 |
|
271 |
| - document.addEventListener("ghmo:container", addCodeFolding); |
| 264 | + on(document, "ghmo:container", addCodeFolding); |
272 | 265 | addCodeFolding();
|
273 | 266 | addBindings();
|
274 | 267 |
|
|
0 commit comments