// ==UserScript== // @name Skrypt zbieractwo // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author Kichiyaki // @match *://*.plemiona.pl/game.php*&screen=place&mode=scavenge* // @grant none // @require https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.min.js // ==/UserScript== var _0x3ca6=['href','split','group','number','set','location','assign','toString','features','Premium','active','groups','load_group_menu','get','api','count_villages_in_group','group_id','addSeconds','isAfter','#break','innerHTML','distanceInWords','currentVillage','reload','#scavenge_screen','createElement','button','started','Zatrzymaj','Rozpocznij','addEventListener','appendChild','break','.free_send_button','length','log','click','kiszkowaty_scavenging_script_','TwCheese','ajax','https://cheesasaurus.github.io/twcheese/launch/ASS.js?','getItem','twcheese.userConfig','parse','props','ASS','troopsAssigner','targetDurationSeconds','config','breakEndsAt','stringify','querySelector','#village_switch_right','getAttribute'];(function(_0x4a32da,_0x492e8c){var _0x33a4b5=function(_0x274b04){while(--_0x274b04){_0x4a32da['push'](_0x4a32da['shift']());}};_0x33a4b5(++_0x492e8c);}(_0x3ca6,0x91));var _0x1a4b=function(_0x68f42,_0x5a0c6b){_0x68f42=_0x68f42-0x0;var _0x21964a=_0x3ca6[_0x68f42];return _0x21964a;};const DEFAULT_PREFIX=_0x1a4b('0x0');let config={'targetDurationSeconds':0x1c20,'currentVillage':0x1,'breakEndsAt':null,'started':![],'group':undefined};const wait=_0x252090=>new Promise(_0xad69ff=>setTimeout(_0xad69ff,_0x252090));const loadTwCheeseScript=()=>{return window[_0x1a4b('0x1')]&&TwCheese['tryUseTool']('ASS')||$[_0x1a4b('0x2')](_0x1a4b('0x3')+~~(new Date()/0x493e0),{'cache':0x1});};const loadTwCheeseDuration=()=>{const _0xbadb6b=localStorage[_0x1a4b('0x4')](_0x1a4b('0x5'));if(_0xbadb6b){const _0x3864a2=JSON[_0x1a4b('0x6')](_0xbadb6b);if(_0x3864a2[_0x1a4b('0x7')]&&_0x3864a2[_0x1a4b('0x7')][_0x1a4b('0x8')]&&_0x3864a2[_0x1a4b('0x7')][_0x1a4b('0x9')]){return _0x3864a2[_0x1a4b('0x7')][_0x1a4b('0x9')][_0x1a4b('0xa')];}}return 0x1c20;};const loadConfig=()=>{const _0x33b26d=localStorage[_0x1a4b('0x4')](DEFAULT_PREFIX+_0x1a4b('0xb'));if(_0x33b26d){config=JSON['parse'](_0x33b26d);config[_0x1a4b('0xa')]=loadTwCheeseDuration();if(config[_0x1a4b('0xc')]){config['breakEndsAt']=new Date(config[_0x1a4b('0xc')]);}}};const persistStore=()=>{const _0x1bde0c=JSON[_0x1a4b('0xd')](config);localStorage['setItem'](DEFAULT_PREFIX+_0x1a4b('0xb'),_0x1bde0c);};const changeVillage=()=>{config['currentVillage']++;persistStore();const _0x544e0e=document[_0x1a4b('0xe')](_0x1a4b('0xf'));if(_0x544e0e){const _0x2c37da=_0x544e0e[_0x1a4b('0x10')](_0x1a4b('0x11'))[_0x1a4b('0x12')]('?')[0x1];const _0x3c88d8=new URLSearchParams(_0x2c37da);if(typeof config[_0x1a4b('0x13')]===_0x1a4b('0x14')&&config['group']>=0x0){_0x3c88d8[_0x1a4b('0x15')]('group',config[_0x1a4b('0x13')]);}window[_0x1a4b('0x16')][_0x1a4b('0x17')]('game.php?'+_0x3c88d8[_0x1a4b('0x18')]());}else{window['location']['reload']();}};const countVillagesInGroup=async()=>{let _0x19b819=0x1;if(game_data[_0x1a4b('0x19')][_0x1a4b('0x1a')][_0x1a4b('0x1b')]){_0x19b819=await new Promise(_0x3539f5=>{TribalWars['get'](_0x1a4b('0x1c'),{'ajax':_0x1a4b('0x1d')},function(_0x3d5ca0){TribalWars[_0x1a4b('0x1e')](_0x1a4b('0x1f'),{'ajax':_0x1a4b('0x20'),'id':typeof config[_0x1a4b('0x13')]===_0x1a4b('0x14')?config[_0x1a4b('0x13')]:_0x3d5ca0[_0x1a4b('0x21')]},function(_0xf2c862){_0x3539f5(_0xf2c862);});});});}return _0x19b819;};const startBreak=()=>{const _0x3b1fdd=new Date();if(!config[_0x1a4b('0xc')]){config[_0x1a4b('0xc')]=dateFns[_0x1a4b('0x22')](_0x3b1fdd,config[_0x1a4b('0xa')]);persistStore();}setInterval(()=>{const _0x50f89c=new Date();if(dateFns[_0x1a4b('0x23')](config[_0x1a4b('0xc')],_0x50f89c)){document[_0x1a4b('0xe')](_0x1a4b('0x24'))[_0x1a4b('0x25')]=dateFns[_0x1a4b('0x26')](config[_0x1a4b('0xc')],_0x50f89c);}else{endBreak();}},0x3e8);};const endBreak=()=>{config[_0x1a4b('0xc')]=undefined;config[_0x1a4b('0x27')]=0x1;persistStore();window[_0x1a4b('0x16')][_0x1a4b('0x28')]();};const renderUI=()=>{const _0x1b077f=document[_0x1a4b('0xe')](_0x1a4b('0x29'));const _0x223c7c=document[_0x1a4b('0x2a')]('div');const _0x158aee=document[_0x1a4b('0x2a')](_0x1a4b('0x2b'));_0x158aee['innerHTML']=config[_0x1a4b('0x2c')]?_0x1a4b('0x2d'):_0x1a4b('0x2e');_0x158aee[_0x1a4b('0x2f')]('click',handleClick);_0x223c7c[_0x1a4b('0x30')](_0x158aee);const _0x4163e6=document['createElement']('h1');_0x4163e6['id']=_0x1a4b('0x31');_0x223c7c[_0x1a4b('0x30')](_0x4163e6);_0x1b077f['prepend'](_0x223c7c);};const handleClick=()=>{config[_0x1a4b('0xc')]=null;config['currentVillage']=0x1;config[_0x1a4b('0x2c')]=!config[_0x1a4b('0x2c')];persistStore();window['location'][_0x1a4b('0x28')]();};(async function(){loadConfig();await loadTwCheeseScript();renderUI();await wait(0x1f4);if(config[_0x1a4b('0x2c')]){const _0x216347=await countVillagesInGroup();if(config[_0x1a4b('0x27')]>_0x216347){startBreak();}else{const _0x93c6bd=document['querySelectorAll'](_0x1a4b('0x32'));if(_0x93c6bd['length']>0x0){for(let _0x5a796f=_0x93c6bd[_0x1a4b('0x33')]-0x1;_0x5a796f>=0x0;_0x5a796f--){const _0x2f8281=_0x93c6bd[_0x5a796f];console[_0x1a4b('0x34')](_0x5a796f);await wait(0x3e8);_0x2f8281[_0x1a4b('0x35')]();}changeVillage();}else{changeVillage();}}}}());