Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javascript:
- function demFlags(){
- var a = $("div[id*='flags_select_'] div[id*='_content'] tr:has(td) td:nth-child(1)");
- if (a.length <= 0){
- alert("Please open one of the flag change screens!");
- } else {
- var b = prompt("Which row should we use for flags? (e.g. '1' means 'resource production', and so on)");
- if (parseInt(b).toString() !== b) alert("Not a number! D:<");
- else {
- var rowNum = parseInt(b) - 1;
- var flagList = $("td:not(td:nth-child(1))", $("div[id*='flags_select_'] div[id*='_content'] tr:has(td)")[rowNum]);
- var flagCounts = [];
- var flagCount = 0;
- var bit = 0;
- flagList.each(function(){
- var count = $(this).text().trim();
- if (count === "") count = 0;
- else count = parseInt(count);
- flagCounts[bit] = count;
- flagCount += count;
- bit++;
- });
- var villageList = $("#techs_table tr[id*='village'] td[id*='flag']");
- villageList.each(function(){
- $("a[onclick*='event']", $(this)).click();
- });
- setTimeout(function(){ villageList.each(function(){
- villageID = $(this).html().match(/FlagsOverview.selectFlag\(event, (\d+)\)/g)[0].match(/(\d+)/)[0];
- while (flagCounts[bit-1] === 0) { bit--; if (bit <= 0) { alert("No more flags!"); return false; } }
- FlagsOverview.assignFlag(rowNum+1, bit, villageID);
- flagCounts[bit-1]--;
- flagCount--;
- }); alert("WE R BE FINISHED (hopefully - might need to wait for AJAX to load...)"); }, 1000);
- }
- }
- }
- void(demFlags());
Advertisement
Add Comment
Please, Sign In to add comment