// ==UserScript== // @name MythWeavers 4e Powers Height 0.3 // @namespace 4EPowersHeight // @description Modifies the Height and adds color to the 4E powers box on Myth Weavers // @include http://www.myth-weavers.com/sheetview.php* // ==/UserScript== // Wrapper to avoid using global variables and functions, and slight delay timer for loading window.setTimeout(function(){ //Temporary Functions: Ignores nonelement nodes to get previous sibling function _getPreviousSibling(n){ x = n.previousSibling; while(x.nodeType != 1){ x = x.previousSibling; } return x; } //Temporary Function: Moves a power block (move) before a target element (before) function _movePowerBlock(move,before){ var create, movea, moveb; movea = document.getElementsByName('d4p' + move + 'desc')[0].parentNode.parentNode; moveb = _getPreviousSibling(movea); create = moveb.parentNode.removeChild(moveb); before.parentNode.insertBefore(create,before); create = movea.parentNode.removeChild(movea); before.parentNode.insertBefore(create,before); } //Check for D&D 4E Sheet first if(document.getElementsByTagName('link')[0].href.match('/dnd4/')){ var i, ci, color, ref, nodesarray; //Adjust the 28/30 Power boxes for(i=1;i<=30;i++){ if(i<=28){ if(i < 10) ci = 0 + '' + i;//0 buffer else ci = '' + i; color = document.getElementsByName('Power' + ci)[0].value.substr(-1,1); ref = document.getElementsByName('d4p' + ci + 'desc')[0]; ref.style['height'] = '6.10em'; } else{ color = document.getElementsByName('Lang0' + (i-25))[0].value.substr(-1,1); ref = document.getElementsByName('text' + (i-24))[0]; ref.style.fontSize = '10px'; ref.style['height'] = '6.10em'; } if(color == 'W') ref.style['background'] = "#CCE4CC";//If title ends with W, make at Will color else if(color == 'E') ref.style['background'] = "#E6CCD3";//If title ends with E, make Encounter color else if(color == 'D') ref.style['background'] = "#D9D9D9";//If title ends with D, make Daily color } //Now to start playing around with the pages and columns. //Moves Power Blocks 11-14 before Power Block 15 ref = _getPreviousSibling(document.getElementsByName('d4p15desc')[0].parentNode.parentNode); for(i=11;i<=14;i++){ _movePowerBlock(i,ref); } //Create a new page. Lets use containera, to repeat the 'reuse id' trend of the sheet writers ref = document.getElementById('containerc'); create = document.createElement('div'); ref.parentNode.insertBefore(create,ref); create.innerHTML = '
'; //Move the rightmost column of page 2 to this new page /*Note: I do not like using a weak assumptive reference like I did with the childNodes[5] here; if someone knows a better way to refer quickly to the rightcol of page2 that's nonassumptive, please contact me*/ ref = document.getElementById('containerb').childNodes[5]; document.getElementById('containerd').appendChild(ref); //Now to create a 'right' column to put powers in to on page 2 create = document.createElement('div'); document.getElementById('containerb').appendChild(create); create.innerHTML = '