apranik
New Member
- Reaction score
- 2
- Author
- tcamps
- Contributors
- apranik
- Quickbar Entry
-
javascript:
var WCS = {
troops: [
{axe: 40, ram: 4, spy: 1}, // lvl 1
{axe: 50, ram: 7, spy: 1}, // lvl 2
{axe: 50, ram: 10, spy: 1}, // lvl 3
{axe: 80, ram: 16, spy: 1}, // lvl 4
{axe: 120, ram: 20, spy: 1}, // lvl 5
{axe: 160, ram: 25, spy: 1}, // lvl 6
{axe: 400, ram: 50, spy: 1} // lvl 7+
],
urlCount: 15, // How many tabs to open
newTabWait: 400, // Milliseconds between tabs
ramGreens: true, // Ram walls even if there were no losses
};
(() => {
if (window.location.href.indexOf("am_farm") < 0) {
alert('Run this on the Loot Assistant page!');
}
console.log('Extracting village info');
let urls = [];
$('#plunder_list')
.find('tr')
.filter((i, el) => $(el).attr('id'))
.each((i, el) => {
var wallLevel = $(el).find('td:nth-of-type(7)').text();
var iconUrl = $(el).find('td:nth-of-type(2) img').attr('src');
if (wallLevel < 1 || (!WCS.ramGreens && iconUrl.indexOf('green.png') >= 0)) {
return;
}
var id = $(el).attr('id').match(/(\d+)/)[1];
console.log('Found village ' + id);
var cv = /village=(\w+)/.exec(window.location.href)[1];
var rp = `/game.php?village=${cv}&screen=place&target=${id}`;
var troops = wallLevel <= WCS.troops.length ? WCS.troops[wallLevel - 1] : WCS.troops[WCS.troops.length - 1]
var tpParams = Object.keys(troops).map(u => `${u}=${troops[u]}`).join('&')
urls.push(`${rp}&${tpParams}`);
});
console.log('Made URLs: ', urls)
urls = urls.slice(0, WCS.urlCount);
urls.forEach((url, i) => setTimeout(() => window.open(url, '_blank'), i * WCS.newTabWait));
})();
void(0);
- Public?
- Public
This is the same as https://forum.tribalwars.net/index.php?threads/clear-barbarian-walls.280874/ with small modifications, but I wanted to make sure it's still legal.
The modifications are:
1. The old script runs everything twice (I think the original author might have missed that in the code after he fixed something). So I removed it to just run once.
2. I added a little bit of configuration to add the unit counts to the url that gets opened. Basically, it was opening /game.php?village=<village>&screen=place&target=<target>, now it opens /game.php?village=<village>&screen=place&target=<target>&spy=X&rams=Y&axe=Z based on the configs.
3. The previous script only cleared walls if the report had a loss, this allows configuration to also clear walls on greens if you want.
The script is pretty small, so it can be put directly into the quickbar.
The modifications are:
1. The old script runs everything twice (I think the original author might have missed that in the code after he fixed something). So I removed it to just run once.
2. I added a little bit of configuration to add the unit counts to the url that gets opened. Basically, it was opening /game.php?village=<village>&screen=place&target=<target>, now it opens /game.php?village=<village>&screen=place&target=<target>&spy=X&rams=Y&axe=Z based on the configs.
3. The previous script only cleared walls if the report had a loss, this allows configuration to also clear walls on greens if you want.
The script is pretty small, so it can be put directly into the quickbar.
Upvote
0