-
-
Save zudsniper/e781a29f6b1c5bfe69918a3e59cca0b5 to your computer and use it in GitHub Desktop.
Make Gist editor automatically resize based on content using a TamperMonkey script
This file contains 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 characters
// ==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