Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Giełda Premium 118
- // @namespace Tampermonkey ? Home
- // @version 0.1
- // @description try to take over the world!
- // @author xxx
- // @match [url]https://pl118.plemiona.pl/*[/url]
- // @grant none
- // ==/UserScript==
- var mode = "sell"; // sell or buy when red (lowest price) "sell" or "buy"
- var interval = 1000; // interval in ms
- var waitForMerchant = 60000; // in ms
- //////////////////////////////////////////////////////////////
- // Coded by: Couiz
- //////////////////////////////////////////////////////////////
- var $button = $("input.btn-premium-exchange-buy"),
- $confirmButton = $(".btn-confirm-yes");
- switch(mode) {
- case "sell":
- sell();
- break;
- case "buy":
- //buy();
- error();
- break;
- default:
- error();
- }
- function error() {
- console.warn("Wrong mode selected.");
- }
- function sell() {
- var merchants = PremiumExchange.data.merchants;
- var resources = {
- wood: {
- stock: PremiumExchange.data.stock.wood,
- capacity: PremiumExchange.data.capacity.wood,
- own: game_data.village.wood
- },
- stone: {
- stock: PremiumExchange.data.stock.stone,
- capacity: PremiumExchange.data.capacity.stone,
- own: game_data.village.stone
- },
- iron: {
- stock: PremiumExchange.data.stock.iron,
- capacity: PremiumExchange.data.capacity.iron,
- own: game_data.village.iron
- }
- };
- if (merchants === 0) {
- console.log("Waiting for merchants " + waitForMerchant + " ms");
- setTimeout(sell, waitForMerchant);
- return;
- }
- for (res in resources) {
- if (resources[res].stock < resources[res].capacity) {
- var value = resources[res].capacity - resources[res].stock;
- if (value > resources[res].own - 1000) {
- continue;
- }
- sellResource(res, value);
- setTimeout(sell, 4000);
- return;
- }
- }
- console.log('<3 Couiz');
- setTimeout(sell, interval);
- }
- function searchPopup()
- {
- var $popUp = $(".confirmation-box"),
- $fader = $("#fader:visible");
- if ($popUp.length > 0 && $fader.length > 0) {
- return true;
- }
- return false;
- }
- function sellResource(_res, _value) {
- $("input[name='sell_" + _res + "']").val(_value);
- setTimeout(function(){
- $button.click();
- var a = setInterval(function() {
- if (searchPopup()) {
- $confirmButton = $($confirmButton.selector);
- $confirmButton.click();
- console.log('Sold ' + _value + ' ' + _res);
- clearInterval(a);
- }
- }, 250);
- }, 250);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement