Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zudsniper/e781a29f6b1c5bfe69918a3e59cca0b5 to your computer and use it in GitHub Desktop.
Save zudsniper/e781a29f6b1c5bfe69918a3e59cca0b5 to your computer and use it in GitHub Desktop.
Make Gist editor automatically resize based on content using a TamperMonkey script
// ==UserScript==
// @name gist-editor-resize-userscript
// @namespace https://gist.github.com/
// @version 0.2
// @description Automatically resize the gist editor for easier editing.
// @match http*://gist.github.com/*
// @copyright 2013+ Joel Day - blog.dayjo.org (updated by @zudsniper - gh.zod.tf)
// ==/UserScript==
var textareas = document.querySelectorAll('textarea.file_contents');
var span = document.createElement('div');
span.style.visibility = "hidden";
document.body.appendChild(span);
$('textarea.file-contents').keyup(function(){
span.style.width = this.offsetWidth + 'px';
span.style.fontSize = this.style.fontSize;
span.innerText = this.value;
this.style.height = span.offsetHeight + 'px';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment