Gist Edit Resize

Gist enhancements with collapsible files and larger editor area

27.02.2023 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        Gist Edit Resize
// @namespace   cvladan.com
// @match       *://gist.github.com/*
// @run-at      document-start
// @inject-into content
// @grant       none
// @version     1.0
// @license MIT
// @author      -
// @description Gist enhancements with collapsible files and larger editor area
// ==/UserScript==

var css = `

  .CodeMirror {
    height: auto !important;
  }

  .file.show-code:has(.CodeMirror.CodeMirror-focused) {
    outline: 3px solid gray;
  }

`

// Inject CSS in document head
//
function injectStyle(css) {
	var doc = document;
  var script = document.createElement('style');
  script.textContent = css;

  var where = doc.getElementsByTagName ('head')[0] || doc.body || doc.documentElement;
  where.appendChild(script);
}

injectStyle(css)


// Toggle buttons to every file
// Plain JavaScript rewrite of https://greasyfork.org/en/scripts/31700-togglegist
//
document.addEventListener('DOMContentLoaded', function() {
  const fileBoxes = document.querySelectorAll('.file-box');

  fileBoxes.forEach(function(fileBox) {
    const btn = document.createElement('a');
    btn.classList.add('btn', 'btn-sm', 'git-toggle-file');
    btn.href = '#';
    btn.textContent = 'Toggle';

    btn.addEventListener('click', function(e) {
      e.preventDefault();
      const wrapper = e.target.closest('.file').querySelector('.blob-wrapper, .blob');
      wrapper.hidden = !wrapper.hidden;
    })

    fileBox.querySelector('.file-actions .btn').parentElement.appendChild(btn);
  })
});