ahk_codebox_quick_fix

Add 'EXPAND VIEW' to code box

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         ahk_codebox_quick_fix
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Add 'EXPAND VIEW' to code box
// @author       You
// @match        https://autohotkey.com/boards/viewtopic.php*
// @grant        none
// ==/UserScript==

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 += ' &middot; <a href="#" onclick="expandCode(this); return false;">EXPAND VIEW</a>';
        }
	}
}