// ==UserScript== // @name ahk_codebox_quick_fix // @namespace http://tampermonkey.net/ // @version 0.1 // @description Add 'EXPAND VIEW' to code box // @author You // @match https://autohotkey.com/boards/viewtopic.php* // @grant none // @downloadURL none // ==/UserScript== window.onload = function() { expand_code_init(); } window.expandCode = function expandCode(e) { var c = e.parentNode.parentNode.getElementsByTagName('code')[0]; if (c.style.maxHeight == 'none') { c.style.maxHeight = '200px'; e.innerHTML = 'EXPAND VIEW'; } else { c.style.maxHeight = 'none'; e.innerHTML = 'COLLAPSE VIEW'; } } function expand_code_init() { var boxes = document.getElementsByTagName('code'); for (var i = 0; i < boxes.length; i++) { if (boxes[i].scrollHeight > boxes[i].offsetHeight + 1) { boxes[i].parentNode.previousSibling.innerHTML += ' · EXPAND VIEW'; } } }