// ==UserScript== // @name OldAges - Gruppe - Gegenstandsauswahl // @namespace oldages.de // @include http*://*oldages.*/wod/spiel/hero/items.php* // ==/UserScript== // Sprache definieren var lang = 'de'; var allInputs = document.getElementsByTagName('input'); for (var j = 0; j < allInputs.length; j++) { var thisButton = allInputs[j]; if(thisButton.getAttribute('name')=='checknone'){ var newButton = document.createElement('input'); newButton.setAttribute('class', 'button'); newButton.setAttribute('type', 'button'); if (lang == 'de') { newButton.setAttribute('value', 'Aufsplitten (VK/WK)'); } newButton.setAttribute('id', 'switchItems'+j); newButton.setAttribute('name', 'switchItems'+j); newButton.addEventListener('click', switchItem, true); var newP = document.createElement('p'); newP.appendChild(newButton); thisButton.parentNode.insertBefore(newP, thisButton.nextSibling); } } function switchItem(ev) { var found = false; var allSelects = document.getElementsByTagName('select'); for (var i = 0; i < allSelects.length; i++) { thisSelect = allSelects[i]; if(thisSelect.name.indexOf('EquipItem')!=-1 && thisSelect.getElementsByTagName('option').length > 3 && (thisSelect.options[thisSelect.selectedIndex].text == "Lager" || thisSelect.options[thisSelect.selectedIndex].text == "Truhe" || thisSelect.options[thisSelect.selectedIndex].text == "Vorratskammer" || thisSelect.options[thisSelect.selectedIndex].text == "Waffenkammer") ) { var aNodes = thisSelect.parentNode.parentNode.getElementsByTagName('a'); var aNode = null; if (aNodes != null) { aNode = aNodes[0]; var Ausdruck = /[\w\W]*\(([0-9]*)\/([0-9]*)\)/; var ergebnis = Ausdruck.exec(aNode.parentNode.innerHTML); if ( ergebnis != null ) { // alert(ergebnis[1] + ", " + ergebnis[2]); for( var j = 0; j < thisSelect.options.length; j++) { if ( thisSelect.options[j].text == "Vorratskammer") { thisSelect.selectedIndex = j; } } } else { for( var j = 0; j < thisSelect.options.length; j++) { if ( thisSelect.options[j].text == "Waffenkammer") { thisSelect.selectedIndex = j; } } } } } } return false; }