-
-
Save maboloshi/dce7ec107dff766d3e43824942f48d1a to your computer and use it in GitHub Desktop.
Revisions
-
maboloshi revised this gist
Dec 25, 2021 . 1 changed file with 10 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,25 +37,25 @@ function initializeExpandCollapseAll() { pageHeadActions.appendChild(listItem); expandCollapseAllBtn.classList.add('gist-expand-collapse-all-btn', 'btn', 'btn-sm'); expandCollapseAllBtn.innerHTML = '折叠全部'; expandCollapseAllBtn.onclick = () => { if ('折叠全部' === expandCollapseAllBtn.innerHTML) { expandCollapseAllBtn.innerHTML = '展开全部'; for (let btn of buttons) { btn.innerHTML = '展开'; } for (let file of files) { const fileContainer = file.querySelector('.file-header').nextSibling.nextSibling; fileContainer.classList.add('collapsed'); } } else { expandCollapseAllBtn.innerHTML = '折叠全部'; for (let btn of buttons) { btn.innerHTML = '折叠'; } for (let file of files) { @@ -75,14 +75,14 @@ function initializeButtons() { const expandCollapseBtn = document.createElement('a'); expandCollapseBtn.classList.add('gist-expand-collapse-btn', 'btn', 'btn-sm'); expandCollapseBtn.innerHTML = '折叠'; actions.appendChild(expandCollapseBtn); expandCollapseBtn.onclick = function() { if ('折叠' === expandCollapseBtn.innerHTML) { expandCollapseBtn.innerHTML = '展开'; } else { expandCollapseBtn.innerHTML = '折叠'; } fileContainer.classList.toggle('collapsed'); -
Jaace renamed this gist
Feb 13, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Jason Boyle revised this gist
Mar 12, 2017 . 1 changed file with 43 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,18 +22,58 @@ window.addEventListener('load', () => { return; } initializeButtons(); initializeExpandCollapseAll(); }); function initializeExpandCollapseAll() { const pageHeadActions = document.querySelector('.pagehead-actions'); const listItem = document.createElement('li'); const expandCollapseAllBtn = document.createElement('a'); const files = document.querySelectorAll('.file'); const buttons = document.querySelectorAll('.gist-expand-collapse-btn'); listItem.appendChild(expandCollapseAllBtn); pageHeadActions.appendChild(listItem); expandCollapseAllBtn.classList.add('gist-expand-collapse-all-btn', 'btn', 'btn-sm'); expandCollapseAllBtn.innerHTML = 'Collapse All'; expandCollapseAllBtn.onclick = () => { if ('Collapse All' === expandCollapseAllBtn.innerHTML) { expandCollapseAllBtn.innerHTML = 'Expand All'; for (let btn of buttons) { btn.innerHTML = 'Expand'; } for (let file of files) { const fileContainer = file.querySelector('.file-header').nextSibling.nextSibling; fileContainer.classList.add('collapsed'); } } else { expandCollapseAllBtn.innerHTML = 'Collapse All'; for (let btn of buttons) { btn.innerHTML = 'Collapse'; } for (let file of files) { const fileContainer = file.querySelector('.file-header').nextSibling.nextSibling; fileContainer.classList.remove('collapsed'); } } }; } function initializeButtons() { const files = document.querySelectorAll('.file'); for (let file of files) { const actions = file.querySelector('.file-actions'); const fileContainer = file.querySelector('.file-header').nextSibling.nextSibling; const expandCollapseBtn = document.createElement('a'); expandCollapseBtn.classList.add('gist-expand-collapse-btn', 'btn', 'btn-sm'); expandCollapseBtn.innerHTML = 'Collapse'; actions.appendChild(expandCollapseBtn); -
Jason Boyle revised this gist
Mar 12, 2017 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,6 +18,10 @@ GM_addStyle( ); window.addEventListener('load', () => { if (document.body.classList.contains('page-gist-edit')) { return; } initializeBtn(); }); -
Jason Boyle revised this gist
Mar 12, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ // ==UserScript== // @name Github Gists: Expand / Collapse Files // @namespace https://gist.github.com/Jaace/7b70d2bb19af63e10b144ed7d867eae0 // @version 0.1 // @description Add a button to expand or collapse files in github gists // @author Jason Boyle -
Jason Boyle renamed this gist
Mar 12, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Jason Boyle created this gist
Mar 12, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ // Add a button to Collapse or Expand files in a Github Gist // // Install Tampermonkey and add this as a script // ==UserScript== // @name Github Gists: Expand / Collapse Files // @namespace @TODO // @version 0.1 // @description Add a button to expand or collapse files in github gists // @author Jason Boyle // @match https://gist.github.com/* // @grant GM_addStyle // ==/UserScript== GM_addStyle( '.gist-expand-collapse-btn { margin: 0 0 0 6px; } ' + '.collapsed { display: none; }' ); window.addEventListener('load', () => { initializeBtn(); }); function initializeBtn() { const files = document.querySelectorAll('.file'); for (let file of files) { const actions = file.querySelector('.file-actions'); const fileContainer = file.querySelector('.file-header').nextSibling.nextSibling; const expandCollapseBtn = document.createElement('a'); expandCollapseBtn.classList.add('gist-expand-collapse-btn', 'btn', 'btn-sm'); expandCollapseBtn.innerHTML = 'Collapse'; actions.appendChild(expandCollapseBtn); expandCollapseBtn.onclick = function() { if ('Collapse' === expandCollapseBtn.innerHTML) { expandCollapseBtn.innerHTML = 'Expand'; } else { expandCollapseBtn.innerHTML = 'Collapse'; } fileContainer.classList.toggle('collapsed'); }; } }