Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name market .pt
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description try to take over the world!
- // @author You
- // @match https://*.tribalwars.com.pt/*
- // @grant none
- // @grant GM_getValue
- // @grant GM_setValue
- // ==/UserScript==
- /* jshint -W097 */
- 'use strict';
- // Your code here...
- var maximumSellValue=220;
- var minumunSellAmount=1000;
- if($(location).attr('href').indexOf('screen=market&mode=exchange') != -1&&$('[id="market_merchant_available_count"]').text()*1<0){
- alert("You should have at least 9 merchants available to use this script.");
- }else{
- setInterval(function(){
- $('[class="btn evt-cancel-btn btn-confirm-no"]').click();
- $('[name="sell_wood"]').val(0);
- $('[name="sell_stone"]').val(0);
- $('[name="sell_iron"]').val(0);
- if ($(location).attr('href').indexOf('screen=market&mode=exchange') != -1) {
- var woodPrice=$('[id="premium_exchange_rate_wood"]').find('div').eq(0).text()*1;
- var stonePrice=$('[id="premium_exchange_rate_stone"]').find('div').eq(0).text()*1;
- var ironPrice=$('[id="premium_exchange_rate_iron"]').find('div').eq(0).text()*1;
- var myWood = $('[id="wood"]').text()*1;
- var myStone = $('[id="stone"]').text()*1;
- var myIron = $('[id="iron"]').text()*1;
- var stockWood=$('[id="premium_exchange_stock_wood"]').text()*1;
- var stockStone=$('[id="premium_exchange_stock_stone"]').text()*1;
- var stockIron=$('[id="premium_exchange_stock_iron"]').text()*1;
- var stockWoodCapacity=$('[id="premium_exchange_capacity_wood"]').text()*1;
- var stockStoneCapacity=$('[id="premium_exchange_capacity_stone"]').text()*1;
- var stockIronCapacity=$('[id="premium_exchange_capacity_iron"]').text()*1;
- var aux=shouldSell(woodPrice,myWood,stockWood,stockWoodCapacity);
- aux = aux/1000<$('[id="market_merchant_available_count"]').text()*1 ? aux : $('[id="market_merchant_available_count"]').text()*1000 - maximumSellValue-1;
- if(aux>0&&aux/1000<$('[id="market_merchant_available_count"]').text()*1){
- $('[name="sell_wood"]').val(aux);
- console.log("sold "+aux +"for "+woodPrice+" each.");
- setPointsEarned(Math.ceil(aux/woodPrice)-1);
- $('[class="btn float_right btn-premium-exchange-buy"]').click();
- setTimeout(function(){
- $('[class="btn evt-confirm-btn btn-confirm-yes"]').click();
- },1500);
- }else{
- aux=shouldSell(stonePrice,myStone,stockStone,stockStoneCapacity);
- aux = aux/1000<$('[id="market_merchant_available_count"]').text()*1 ? aux : $('[id="market_merchant_available_count"]').text()*1000 - maximumSellValue-1;
- if(aux>0&&aux/1000<$('[id="market_merchant_available_count"]').text()*1){
- $('[name="sell_stone"]').val(aux);
- console.log("sold "+aux +"for "+stonePrice+" each.");
- setPointsEarned(Math.ceil(aux/stonePrice)-1);
- $('[class="btn float_right btn-premium-exchange-buy"]').click();
- setTimeout(function(){
- $('[class="btn evt-confirm-btn btn-confirm-yes"]').click();
- },1500);
- }else{
- aux=shouldSell(ironPrice,myIron,stockIron,stockIronCapacity);
- aux = aux/1000<$('[id="market_merchant_available_count"]').text()*1 ? aux : $('[id="market_merchant_available_count"]').text()*1000 - maximumSellValue-1;
- if(aux>0&&aux/1000<$('[id="market_merchant_available_count"]').text()*1){
- $('[name="sell_iron"]').val(aux);
- console.log("sold "+aux +"for "+ironPrice+" each.");
- setPointsEarned(Math.ceil(aux/ironPrice)-1);
- $('[class="btn float_right btn-premium-exchange-buy"]').click();
- setTimeout(function(){
- $('[class="btn evt-confirm-btn btn-confirm-yes"]').click();
- },1500);
- }
- }
- }
- }
- },9000);
- }
- function shouldSell(price,my,stock, capacity){
- if(capacity-stock <4000||my<minumunSellAmount||price>maximumSellValue){
- return -1;
- }
- return Math.min(Math.floor(my/1000)*1000-1-price,Math.floor((capacity-stock)/1000)*1000-1-price);
- }
- //setInterval(function(){
- //if(maximumSellValue==170){
- // maximumSellValue=170;
- // console.log('changing maximum price to 140');
- //}else{
- // maximumSellValue=170;
- // console.log('changing maximum price to 170');
- //}
- //},3*60*60*1000);
- function setPointsEarned(points){
- var d = new Date();
- console.log(d+" ==== earned points ======> "+points);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement