Skip to content

Commit 23ec467

Browse files
committed
Code-folding: cleanup
1 parent 7faff0a commit 23ec467

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

github-code-folding.user.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name GitHub Code Folding
3-
// @version 1.1.2
3+
// @version 1.1.3
44
// @description A userscript that adds code folding to GitHub files
55
// @license MIT
66
// @author Rob Garrison
@@ -12,12 +12,13 @@
1212
// @grant GM_addStyle
1313
// @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js?updated=20180103
1414
// @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
1516
// @icon https://github.githubassets.com/pinned-octocat.svg
1617
// @updateURL https://raw.githubusercontent.com/Mottie/Github-userscripts/master/github-code-folding.user.js
1718
// @downloadURL https://raw.githubusercontent.com/Mottie/Github-userscripts/master/github-code-folding.user.js
1819
// @supportURL https://github.com/Mottie/GitHub-userscripts/issues
1920
// ==/UserScript==
20-
/* global GM */
21+
/* global $ $$ on */
2122
/**
2223
* This userscript has been heavily modified from the "github-code-folding"
2324
* Chrome extension Copyright 2016 by Noam Lustiger; under an MIT license
@@ -141,7 +142,7 @@
141142
}
142143

143144
function addBindings() {
144-
document.addEventListener("click", event => {
145+
on(document, "click", event => {
145146
let index, elm, isCollapsed;
146147
const el = event.target;
147148
const codeBlock = el.closest(".highlight");
@@ -238,14 +239,6 @@
238239
}
239240
}
240241

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-
249242
function removeEls(selector, el) {
250243
let els = $$(selector, el);
251244
let index = els.length;
@@ -268,7 +261,7 @@
268261
}
269262
}
270263

271-
document.addEventListener("ghmo:container", addCodeFolding);
264+
on(document, "ghmo:container", addCodeFolding);
272265
addCodeFolding();
273266
addBindings();
274267

0 commit comments

Comments
 (0)