Automatic Trade Script.

Discussion in 'Rune Trading' started by Grumz, Aug 5, 2014.

  1. Grumz

    Grumz The King of Potatoes

    *********** WARNING RUNNING JS SCRIPTS MAY NOT BE SAFE ***********
    Run it only if you know what you are doing and if you trust the source.
    The script has been updated to create an interface with which you can filter runes by type, level, faction and rarity. Also you can select to add only runes of which you have more than 2 copies and to add only a maximum of 2 runes per type.
    By default all options are enabled. If you do a mistakes with the filters reload the page and run the script again.

    To use it you need to:
    1 - Create a new bookmark in your browser.
    2 - Paste the script (below) in the bookmark URL address bar
    3 - Navigate to a new empty trade.
    4 - Click on the new bookmark, the interface will appear.
    5 - Select Conditions.
    6 - Click on "Add Runes"
    7 - When the script has finished you can click on add trade.


    Code:
    javascript:function addCondition(rune,runeType){document.getElementById('statusDiv').innerHTML="Checking Rune: "+rune.name+"<br> Runes in the Offer: "+offersCount;var factionOk=false;if(!rune.factionName)factionOk=true;if(document.getElementById('ud').checked&&rune.factionName=='Underdepths')factionOk=true;if(document.getElementById('kf').checked&&rune.factionName=='K\'thir Forest')factionOk=true;if(document.getElementById('is').checked&&rune.factionName=='Ironfist Stronghold')factionOk=true;if(document.getElementById('sl').checked&&rune.factionName=='Sundered Lands')factionOk=true;if(document.getElementById('fs').checked&&rune.factionName=='Forglar Swamp')factionOk=true;if(document.getElementById('sp').checked&&rune.factionName=='Shattered Peaks')factionOk=true;if(document.getElementById('fw').checked&&rune.factionName=='Forsaken Wastes')factionOk=true;if(document.getElementById('st').checked&&rune.factionName=='Savage Tundra')factionOk=true;var runeTypeOK=false;if(document.getElementById('champions').checked&&runeType==0)runeTypeOK=true;if(document.getElementById('spells').checked&&runeType==1)runeTypeOK=true;if(document.getElementById('relics').checked&&runeType==2)runeTypeOK=true;if(document.getElementById('equipments').checked&&runeType==3)runeTypeOK=true;if(document.getElementById('tokens').checked&&runeType==4)runeTypeOK=true;var levelOK=false;var level=rune.level;if(!level)levelOK=true;if(document.getElementById('level1').checked&&level==1)levelOK=true;if(document.getElementById('level2').checked&&level==2)levelOK=true;if(document.getElementById('level2').checked&&level==3)levelOK=true;var rarityOK=false;if(!rune.rarity)rarityOK=true;if(document.getElementById('common').checked&&rune.rarity==0)rarityOK=true;if(document.getElementById('uncommon').checked&&rune.rarity==1)rarityOK=true;if(document.getElementById('rare').checked&&rune.rarity==2)rarityOK=true;if(document.getElementById('exotic').checked&&rune.rarity==3)rarityOK=true;if(document.getElementById('limited').checked&&rune.rarity==4)rarityOK=true;if(document.getElementById('legendary').checked&&rune.rarity==5)rarityOK=true;return(factionOk&&runeTypeOK&&levelOK&&rarityOK)}String.prototype.contains=function(it){return this.indexOf(it)!=-1};function addToOffering(type,id,inTheme){var prefixes=new Array('champion','spell','relic','equipment','token','token');var previewDiv=document.getElementById(prefixes[type]+'Preview'+id);var offeringDiv=document.getElementById('offering');offeringDiv.appendChild(previewDiv);var buttonTd=document.getElementById(prefixes[type]+'Button'+id);var imgId='remove_'+type+'_'+id;var out='';out+=' <a href="#" class="btn" onclick="return removeFromOffering('+type+', '+id+');">';out+='-';out+=' </a>';buttonTd.innerHTML=out;offering.add(type,id);document.getElementById('noOffering').style.display='none';return false}function addRuneDivOffer(runeType,rune){console.log("Rune: "+rune.name);if(offersCount<maxOffersCount){offersCount++;document.getElementById('listPreviews').innerHTML=rune.getPreview();addToOffer(runeType,rune.id,false)}}function addCheckBox(id,label){var checkbox=document.createElement("input");checkbox.type="checkbox";checkbox.name=label;checkbox.value=label;checkbox.id=id;checkbox.checked=true;var labelObj=document.createElement("label");labelObj.setAttribute("style","width:145px");var descDiv=document.createElement('div');descDiv.id='descDiv';var description=document.createTextNode(label);descDiv.appendChild(description);descDiv.style.textAlign='left';labelObj.appendChild(descDiv);labelObj.appendChild(checkbox);var tradeForm=document.getElementById('ats');tradeForm.appendChild(labelObj)}function addInterface(){var div=document.createElement('div');div.id='ats';var tradeForm=document.getElementById('tradeForm');if(tradeForm.firstChild)tradeForm.insertBefore(div,tradeForm.firstChild);else pa.appendChild(who);addCheckBox('ud','UD');addCheckBox('kf','KF');addCheckBox('is','IS');addCheckBox('sl','SL');addCheckBox('fs','FS');addCheckBox('sp','SP');addCheckBox('fw','FW');addCheckBox('st','ST');addCheckBox('champions','Champions');addCheckBox('spells','Spells');addCheckBox('relics','Relics');addCheckBox('equipments','Equip.');addCheckBox('tokens','Tokens');addCheckBox('level1','Level 1');addCheckBox('level2','Level 2');addCheckBox('level3','Level 3');addCheckBox('common','Commons');addCheckBox('uncommon','Uncomm');addCheckBox('rare','Rares');addCheckBox('limited','Limited');addCheckBox('exotic','Exotics');addCheckBox('legendary','Legendaries');addCheckBox('duplicates','Only Triplicates');addCheckBox('maxTwoRunes','2 Runes/type');var btn=document.createElement('input');btn.setAttribute('type','button');btn.setAttribute('value','Add Runes');btn.setAttribute('name','button3');btn.setAttribute('onclick','addRunes(0,0)');var btn=document.createElement('input');btn.setAttribute('type','button');btn.setAttribute('value','Add Runes');btn.setAttribute('name','button3');btn.setAttribute('onclick','addRunes(0,0)');var statusDiv=document.createElement('div');statusDiv.id='statusDiv';statusDiv.style.textAlign='center';statusDiv.setAttribute("style","margin-bottom:25px");div.appendChild(btn);div.appendChild(statusDiv)}function addRuneToOffer(runeType,rune,runeCount){console.log("|\t Type "+runeType+" \t|\t Count "+runeCount+" \t|\t ID "+rune.id+"   \t|\t Offer#  "+(offersCount+1)+"\t|");var request=getHttpRequestObject();request.onreadystatechange=function(){if(httpRequest.readyState===4){if(httpRequest.status===200){var xmldoc=request.responseXML;var runeAdded=0;switch(runeType){case 0:var runes=xmldoc.getElementsByTagName('champion');for(var i=0;i<runes.length;i++){var rune=new Champion(runes[i]);if(addCondition(rune,runeType)&&(runeAdded<2||!document.getElementById('maxTwoRunes').checked)){if((runeAdded==runes.length-2)&&document.getElementById('duplicates').checked)break;addRuneDivOffer(runeType,rune);runeAdded=runeAdded+1}}break;case 1:var runes=xmldoc.getElementsByTagName('spell');for(var i=0;i<runes.length;i++){var rune=new Spell(runes[i]);if(addCondition(rune,runeType)&&(runeAdded<2||!document.getElementById('maxTwoRunes').checked)){if((runeAdded==runes.length-2)&&document.getElementById('duplicates').checked)break;addRuneDivOffer(runeType,rune);runeAdded=runeAdded+1}}break;case 2:var runes=xmldoc.getElementsByTagName('relic');for(var i=0;i<runes.length;i++){var rune=new Relic(runes[i]);if(addCondition(rune,runeType)&&(runeAdded<2||!document.getElementById('maxTwoRunes').checked)){if((runeAdded==runes.length-2)&&document.getElementById('duplicates').checked)break;addRuneDivOffer(runeType,rune);runeAdded=runeAdded+1}}break;case 3:var runes=xmldoc.getElementsByTagName('equipment');for(var i=0;i<runes.length;i++){var rune=new Euqipment(runes[i]);if(addCondition(rune,runeType)&&(runeAdded<2||!document.getElementById('maxTwoRunes').checked)){if((runeAdded==runes.length-2)&&document.getElementById('duplicates').checked)break;addRuneDivOffer(runeType,rune);runeAdded=runeAdded+1}}break;case 4:var runes=xmldoc.getElementsByTagName('token');for(var i=0;i<runes.length;i++){var rune=new Token(runes[i]);if(addCondition(rune,runeType)&&(runeAdded<2||!document.getElementById('maxTwoRunes').checked)){if((runeAdded==runes.length-2)&&document.getElementById('duplicates').checked)break;addRuneDivOffer(runeType,rune);runeAdded=runeAdded+1}}break}addRunes(runeType,runeCount+1)}}};request.open('POST','/trader/loadpreview.do?t='+runeType+'&r='+rune.id,true);request.send(null)}function setDescription(){document.forms[0]['shortDescription'].value='Automatic trade Script by Grumz';document.forms[0]['longDescription'].value='Automatic trade Script by Grumz \n http://forums.poxnora.desertowlgames.com/index.php?threads/automatic-trade-script.6759/\nTotal Runes: '+offersCount}function addRunes(runeType,runeCount){if(runeType>4){setDescription();window.alert("I checked all runes, done. Runes Added: "+offersCount);return}if(runeType==0&&!document.getElementById('champions').checked){addRunes(1,0);return}if(runeType==1&&!document.getElementById('spells').checked){addRunes(2,0);return}if(runeType==2&&!document.getElementById('relics').checked){addRunes(3,0);return}if(runeType==3&&!document.getElementById('equipments').checked){addRunes(4,0);return}if(runeType==4&&!document.getElementById('tokens').checked){addRunes(5,0);return}if(offersCount<maxOffersCount){if(runeCount<runesLists[runeType].length){if(runesLists[runeType][runeCount].count<3&&document.getElementById('duplicates').checked){addRunes(runeType,runeCount+1)}else{addRuneToOffer(runeType,runesLists[runeType][runeCount],runeCount)}}else{console.log("Switching to next type of Runes, type: "+(runeType+1));addRunes((runeType+1),0)}}else{setDescription();window.alert("No more space, please create a new trade. Runes Added: "+offersCount)}}addInterface();var offersCount=0;var maxOffersCount=100;var runesLists=[listingsController.championCounts,listingsController.spellCounts,listingsController.relicCounts,listingsController.equipmentCounts,listingsController.tokenCounts];
    

    Capture.PNG
     
    Last edited: Aug 10, 2014
    Poxbrothers and PhdNiceGuy like this.
  2. HandOfTheKing

    HandOfTheKing Devotee of the Blood Owl

    How do we know this wont somehow steal our stuff
     
  3. Grumz

    Grumz The King of Potatoes

    The only way would be to read and understand the code or see it for yourself on another account with maybe just a couple of runes in it.
    It would be stupid for me to post here something that could get me banned :D
     
  4. Jib

    Jib Better-Known Member

    Skimming it real quick it looks safe, but it's a good thing to be weary of scripts like that.

    You get a gold star.
     
  5. Grumz

    Grumz The King of Potatoes

    Updated the first script to add an interface and more functionalities.
    See the first Post
     
    Last edited: Aug 10, 2014
    Jib and PhdNiceGuy like this.
  6. decondor

    decondor I need me some PIE!

    Well done! I used it as well, as poxbox I claim this 100% safe as I also fully understand the code naturally ;)

    PS if you ever want to do something for the site let me know! Your scripting is nice and clean!
     
    Grumz likes this.
  7. Grumz

    Grumz The King of Potatoes

    Thanks! Actually I kinda hate Web programming but I'll think about it :D
    Also if you want to incorporate or publicize it on poxbox somehow feel free to modify and use the code.

    Regards,
    FD
     
    Last edited: Aug 7, 2014
  8. Poxbrothers

    Poxbrothers Devotee of the Blood Owl

    Works like a charm! ;)


    Sincerely,

    Josh753
     
  9. Jib

    Jib Better-Known Member

    That new one is pretty cool.

    If it could autofill in poxbox that would be the greatest thing ever. Never noticed the dump trade thingie with the quote in the bid.

    WHERE WAS THIS ALL MY LIFE?
     
    Last edited: Aug 8, 2014
  10. Grumz

    Grumz The King of Potatoes

    :D I'm glad it is useful.

    Regards FD
     
  11. Grumz

    Grumz The King of Potatoes

    Bump,
    UPDATE:
    Added an interface to filter runes.
     
    HandOfTheKing likes this.

Share This Page