ToggleGist

Toggle files in GitHub Gist

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        ToggleGist
// @author      Kuba Niewiarowski
// @description Toggle files in GitHub Gist
// @namespace   [email protected]
// @icon        https://github.com/favicon.ico
// @encoding    utf-8
// @include     /^https?:\/\/gist.github.com\/[\w-]+\/.*/
// @require     https://code.jquery.com/jquery-2.1.3.min.js
// @require     https://update.greatest.deepsurf.us/scripts/28721/1108163/mutations.js
// @version     1.1
// ==/UserScript==

jQuery(function($) {
	function addBtn(){
		$('.file-box').each(function() {
			$('<a>', {
				class: 'Button--secondary Button--small Button git-toggle-file',
				href:  '#',
				text:  'Toggle'
			}).click((e) => {
				e.preventDefault();
				$wrapper = $(e.target).parents('.file').find('.blob-wrapper, .blob').first();
				$wrapper.prop('hidden', !$wrapper.prop('hidden'));
			}).appendTo($(this).find('.file-actions .Button').parent());
		});
	}

	document.addEventListener("ghmo:container", addBtn);

	addBtn();

});