The script is able to find all of the codeholder divs and iterate through them with a while loop. However, if I try to set any of the div properties such as style.maxHeight or innerHTML, the loop breaks after the property is set for the first div. My attempts at setting the div properties have been commented out.
Code: Select all
// ==UserScript==
// @name Debugging DevNetwork.net Expand Code Link Fix
// @namespace https://snydev.com/greasemonkey/
// @description Fixes a bug on devnetwork.net forum related to the Expand/Contract links
// @include http://forums.devnetwork.net/viewtopic.php*
// ==/UserScript==
var codeHolders = document.evaluate("//div[@class='codeholder']", document, null, XPathResult.ANY_TYPE, null);
var ch = codeHolders.iterateNext();
var i = 0;
while (ch) {
i++;
//ch.style.maxHeight = '600px';
//ch.style.cssText = 'max-height: 600px';
//ch.style.setProperty('max-height', '600px' , 'important');
//ch.innerHTML = '';
window.alert('Count: ' + i + "\n" +
'ch.style.cssText: ' + ch.style.cssText + "\n" +
'ch.style.maxHeight: ' + ch.style.maxHeight);
ch = codeHolders.iterateNext();
}Two code blocks are required to debug this, so here is a second dummy code block.
Code: Select all
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z