Advertisement
Guest User

presente do edu para a ana

a guest
Aug 16th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.04 KB | None | 0 0
  1.  
  2. Javascript:
  3. /* Poached from Fluffy88
  4. http://www.fluffy88.com/TW/op_gen.js
  5. http://www.crosstrigger.com/tw/op_gen.js
  6.  
  7. anonymous 30/08/2011 : fixed for 7.4
  8. jason farmer 30/08/2011 : fudged to fit uk..
  9. Nick Toby - May 2, 2013 : fudged the previous fudging? This was generating a bannable fake script. -edit: I am a dumbass. Of course, I was testing it on the wrong market so it wasn't disabled.
  10. Nick Toby - July 6, 2013: added a new output section that reduces tags (limit of 1000 tags per forum post) by making use of claim tags and context menus. Moved old output into "legacy" section
  11. Nick Toby - August 16, 2013: changed twstats links to co.uk instead of .com (wasn't putting graphs in)
  12. Nick Toby - March 23, 2014: changed twstats links to work for all markets
  13.  
  14. uk hosted version is at : http://team.tribalwars.co.uk/scripts/opGen.js
  15. */
  16.  
  17. /*
  18. Javascript: $.getScript('http://team.tribalwars.co.uk/scripts/opGen.js');void (0);
  19. */
  20.  
  21. var translation = [];
  22. if (game_data.market == "pt") {
  23. translation = ["Aldeias", "Tribo", "Pontos", "Inimigos Derrotados"];
  24. } else {
  25. translation = ["Villages", "Tribe", "Points", "Opponents defeated"];
  26. }
  27.  
  28. /*==== twstats link ====*/
  29. var statsDomain;
  30. if (game_data.market == 'uk') {
  31. statsDomain = 'twstats.co.uk';
  32. } else if (game_data.market == 'en') {
  33. statsDomain = 'twstats.com';
  34. } else {
  35. statsDomain = game_data.market + '.twstats.com';
  36. }
  37.  
  38. var table = document.getElementsByTagName("table");
  39. for (x = 0; x < table.length; x++) {
  40. if (table[x].id == "villages_list") {
  41. var secondarytablevalue = x;
  42. break;
  43. }
  44. }
  45. var table = document.getElementsByTagName("table")[secondarytablevalue];
  46.  
  47. if (table.tBodies[0].rows.length > 100 && table.tBodies[0].rows.length < 102) { /*This checks to see if its over 100 rows (if it is, then it means that annoying button is there, which you need to get rid of*/
  48. var str = table.tBodies[0].rows[100].getElementsByTagName("td")[0].getElementsByTagName("a")[0].getAttribute("onclick").replace("return false", "");
  49. var patt1 = /\d+/g;
  50. var x = (str.match(patt1));
  51. Player.getAllVillages(this, '/game.php?village=' + x[0] + '&screen=info_player&ajax=fetch_villages&player_id=' + x[1]);
  52. table.tBodies[0].deleteRow(100);
  53. //$.getScript("http://ftp.innogames.net/~tracey/scripts/opGen.js");
  54. $.getScript("https://media.innogamescdn.com/com_DS_UK/Scripts/opGen.js");
  55. void (0);
  56. end();
  57. }
  58. setTimeout(fnExecuteScript(), 1000);
  59.  
  60. function fnExecuteScript() {
  61. try {
  62.  
  63. var strScriptName = "Op Planner";
  64. var strVersion = "V7.3";
  65.  
  66. if (!document.URL.match(/screen\=info_player/i)) {
  67. throw ('This script must be run from\nPlayer Profile Screen!');
  68. }
  69.  
  70. function fnGenerateSequentialFakeScript(villas, trainSize) {
  71. var scriptSource = "";
  72. scriptSource += "javascript:";
  73. scriptSource += "var config={victim:'miscellaneous',trainSize:" + trainSize + ",units:{spy:1,ram:1},cookieID:'fake'};";
  74. scriptSource += "var targets='" + villas.join(" ") + "';";
  75. scriptSource += "if(targets.replace(/^\\s\\s*/,'').replace(/\\s\\s*$/,'')===''){throw('There are no Targets');}";
  76. scriptSource += "var coords=targets.split(' ');";
  77. scriptSource += "function escapeStr(text){var specials=['/','.',',','~','`','@','#','%','-','_','*','+','?','|','$','=',':','!','^','<','>','(',')','[',']','{','}','\\\\'];var sRE=new RegExp('(\\\\'+specials.join('|\\\\')+')','g');return text.replace(sRE,'\\\\$1');}";
  78. scriptSource += "function zeroPad(number,length){var n=number.toString();while(n.length<length){n='0'+n;}return n;}";
  79. scriptSource += "function fnWriteCookie(index){var cookie_date=new Date(2099,11,11);document.cookie=vWorld+'$'+config.victim+'$'+config.cookieID+'='+(index+1)+';expires='+cookie_date.toGMTString();}";
  80. scriptSource += "function fnAssignUnits(index,isManualReset){";
  81. scriptSource += "if((index<0)||(index>=coords.length)){index=0;if(document.fakeSequence==1){alert('cycle restarted');}}";
  82. scriptSource += "document.getElementById('fake_combo').selectedIndex=index;";
  83. scriptSource += "var villa=coords[index].split('|');";
  84. scriptSource += "if(!isManualReset&&(document.fakeSequence<config.trainSize)){document.fakeSequence++;}else{document.fakeSequence=(isManualReset?2:1);fnWriteCookie(isManualReset?index-1:index);}";
  85. scriptSource += "var eleForm=document.getElementById('units_form');";
  86. scriptSource += "eleForm.x.value=villa[0];";
  87. scriptSource += "eleForm.y.value=villa[1];";
  88. scriptSource += "var count;";
  89. scriptSource += "for(var unit in config.units){";
  90. scriptSource += "if(config.units.hasOwnProperty(unit)){";
  91. scriptSource += "if(typeof(eleForm[unit])!='undefined'){";
  92. scriptSource += "count=parseInt(eleForm[unit].nextSibling.nextSibling.innerHTML.match(/\\d+/),10);";
  93. scriptSource += "eleForm[unit].value=Math.min(config.units[unit],count);}}}}";
  94. scriptSource += "try{";
  95. scriptSource += "if(typeof(document.fakeSequence)=='undefined'){document.fakeSequence=1;}";
  96. scriptSource += "var scrape,vScreen=(scrape=document.URL.match(/\\&screen=(\\w+)/i))?scrape[1]:null;";
  97. scriptSource += "var vWorld=(scrape=document.URL.match(/\\/\\/(\\w+)\\./i))?scrape[1]:null;";
  98. scriptSource += "var village=document.getElementsByTagName('title')[0].innerHTML.match(/\\(\\d+\\|\\d+\\)/);";
  99. scriptSource += "if(vScreen=='place'){";
  100. scriptSource += "var index=0;";
  101. scriptSource += "var twCookie=document.cookie.match('[^|;]\s?'+escapeStr(vWorld+'$'+config.victim+'$'+config.cookieID+'=')+'([^;]*)[;|$]');";
  102. scriptSource += "if(twCookie){index=parseInt(twCookie[1],10);}";
  103. scriptSource += "if(!document.getElementById('fake_combo')){";
  104. scriptSource += "var eleInputs=document.getElementsByTagName('input');";
  105. scriptSource += "if(eleInputs){for(var ii=0;ii<eleInputs.length;ii++){";
  106. scriptSource += "if(eleInputs[ii].name=='support'){";
  107. scriptSource += "var optionList='';";
  108. scriptSource += "for(var jj=0;jj<coords.length;jj++){optionList+='<option>'+zeroPad(jj+1,4)+':'+coords[jj]+'</option>';}";
  109. scriptSource += "eleInputs[ii].parentNode.parentNode.innerHTML+='<TD rowspan=\"2\"><div id=\"fakes\"><table class=\"main\">";
  110. scriptSource += "<tr><td id=\"fake_content_value\"><span style=\"font-weight:bold\">Current Target:</span>";
  111. scriptSource += "<select id=\"fake_combo\" name=\"fake_combo\" size=\"1\" onchange=\"fnAssignUnits(this.selectedIndex,true);\">'+optionList+'</select>";
  112. scriptSource += "<span style=\"font-weight:100;font-style:italic;text-decoration:none;font-size:x-small;\">";
  113. scriptSource += "<a href=\"http://www.crosstrigger.com\" target=\"_blank\"> by dalesmckay</a></span></td></tr></table></div></TD>';break;}}}}";
  114. scriptSource += "fnAssignUnits(index,false);}else{throw('Run from the Rally point');}void(0);}catch(objErr){alert(objErr);}";
  115.  
  116. return scriptSource;
  117. }
  118.  
  119. function fnGetText(ele) {
  120. return (typeof (ele.innerText) == "undefined" ? ele.textContent : ele.innerText);
  121. }
  122.  
  123. function zeroPad(number, length) {
  124. var n = number.toString();
  125. while (n.length < length) {
  126. n = '0' + n;
  127. }
  128. return n;
  129. }
  130.  
  131. function fnExtractContinent(str) {
  132. var coords = str.split("|");
  133. var xx = zeroPad(coords[0], 3);
  134. var yy = zeroPad(coords[1], 3);
  135.  
  136. return yy[0] + xx[0];
  137. }
  138.  
  139. function fnGenerateOp() {
  140. var output = "";
  141. var legacyOutput = "";
  142. var coords = [];
  143. var villageTable = $("th:contains('" + translation[0] + "')").parent().parent();
  144. var playerTable = villageTable.parent().parent();
  145.  
  146. var k = [];
  147. for (var x = 0; x < 100; x++) {
  148. k[zeroPad(x, 2)] = [];
  149. }
  150.  
  151. var server = document.URL.match(/\/\/([a-z0-9]{1,5})\./i)[1];
  152. var thePlayer = playerTable.find("th:first").text();
  153. var playerId = document.URL.match(/id\=(\d+)/i)[1];
  154. var theTribeTd = playerTable.find("td:contains('" + translation[1] + ":')").next("td");
  155.  
  156. var tribeId = 0;
  157. var theTribe = theTribeTd.html().match(/.*>(.*)<\/a>/i);
  158. if (theTribe) {
  159. theTribe = theTribe[1];
  160. tribeId = parseInt(theTribeTd.html().match(/id\=(\d+)/i)[1], 10);
  161. }
  162.  
  163. var thePoints = playerTable.find("td:contains('" + translation[2] + ":')").next("td").text();
  164. var OD = playerTable.find("td:contains('" + translation[3] + ":')").next("td").text();
  165.  
  166.  
  167. for (i = 0; i < table.tBodies[0].rows.length; i++) {
  168. var currentName = ""; //as[i - 1].innerHTML;
  169. var cod = fnGetText(table.tBodies[0].rows[i].cells[1]);
  170. var pint = fnGetText(table.tBodies[0].rows[i].cells[2]);
  171. coords[i - 1] = cod;
  172. k[fnExtractContinent(cod)].push([cod, pint, currentName]);
  173. }
  174.  
  175. var index = 1;
  176. for (var idx = 0; idx < k.length; idx++) {
  177. var curK = zeroPad(idx, 2);
  178. if (k[curK][0]) {
  179. legacyOutput += "[b]K" + curK + " - " + k[curK].length + " " + translation[0] + ";[/b]\n";
  180. output += "[b]K" + curK + " - " + k[curK].length + " " + translation[0] + ";[/b]\n";
  181.  
  182. for (var kdx = 0; kdx < k[curK].length; kdx++) {
  183. var legacyVillageLine = "[b][color=red]" + zeroPad(index, 4) + "[/color][/b]";
  184.  
  185. legacyVillageLine += " - [coord]" + k[curK][kdx][0] + "[/coord] - " + k[curK][kdx][1] + " ==> ";
  186. villageLine = "[claim]" + k[curK][kdx][0] + "[/claim] - " + k[curK][kdx][1] + " pts";
  187.  
  188. legacyOutput += legacyVillageLine + '\n';
  189. output += villageLine + '\n';
  190. index++;
  191. }
  192.  
  193. legacyOutput += "\n";
  194. output += "\n";
  195. }
  196. }
  197.  
  198. var docSource = "";
  199.  
  200. /*==== new format section ====*/
  201.  
  202. docSource += "<h3>Detailed info:</h3>\n";
  203. docSource += "<textarea cols='80' rows='9' onFocus='this.select()'>\n";
  204. docSource += "Use the village context menus to manage claims.\n";
  205. docSource += "------------------------------------------------------------------------------------------------------\n\n";
  206. docSource += "[color=#ff0000][i][b]Landing Time:[/b][/i][/color]\n";
  207. docSource += "\n\n";
  208. docSource += "[color=#ff0eff][i][b]Goal/Mission:[/b][/i][/color]\n";
  209. docSource += "\n\n";
  210. docSource += "[color=#4b004b][i][b]Notes:[/b][/i][/color]\n";
  211. docSource += "\n\n";
  212. docSource += "[color=#00a500][i][b]Miscellaneous:[/b][/i][/color]\n";
  213. var urlPrefix = "";
  214. if (window.location.host.match(/us/g)) {
  215. urlPrefix = ".us";
  216. }
  217. else if (game_data.market == "ba") {
  218. urlPrefix = ".ba";
  219. }
  220. else {
  221. urlPrefix = "";
  222. }
  223.  
  224. docSource += "[img]http://www." + statsDomain + "/image.php?type=playerssgraph&graph=points&id=" + playerId + "&s=" + server + "[/img]\n";
  225. docSource += "[img]http://www." + statsDomain + "/image.php?type=playerssgraph&graph=villages&id=" + playerId + "&s=" + server + "[/img]\n\n";
  226. docSource += "Name: [player]" + thePlayer + "[/player]\n";
  227. docSource += "Points: " + thePoints + "\n";
  228. docSource += "OD: " + OD + "\n";
  229. docSource += "Tribe: " + ((tribeId > 0) ? ("[ally]" + theTribe + "[/ally]") : "[color=silver]None[/color]") + "\n";
  230. docSource += "[url=http://www." + statsDomain + "/" + server + "/index.php?page=player&fi=1&id=" + playerId + "]TWStats[/url]\n";
  231.  
  232. if (tribeId > 0) {
  233. docSource += "[url=http://www." + statsDomain + "/" + server + "/index.php?page=map&tribe_0_id=" + tribeId + "&tribe_0_colour=ff00ff&player_0_id=" + playerId + "&player_0_colour=00aeff&zoom=100&centrex=500&centrey=500&nocache=1&fill=000000&grid=1]Map[/url]\n";
  234. }
  235.  
  236. docSource += "\n\n";
  237. docSource += output;
  238. docSource += "</textarea><br/>\n";
  239.  
  240. /*==== old format section ====*/
  241.  
  242. docSource += "<h3>Detailed info (Legacy):</h3>\n";
  243. docSource += "<textarea cols='80' rows='9' onFocus='this.select()'>\n";
  244. docSource += "Claim the village(s) you are going to noble by posting the red bolded number next to the village(s).\n";
  245. docSource += "------------------------------------------------------------------------------------------------------\n\n";
  246. docSource += "[color=#ff0000][i][b]Landing Time:[/b][/i][/color]\n";
  247. docSource += "\n\n";
  248. docSource += "[color=#ff0eff][i][b]Goal/Mission:[/b][/i][/color]\n";
  249. docSource += "\n\n";
  250. docSource += "[color=#4b004b][i][b]Notes:[/b][/i][/color]\n";
  251. docSource += "\n\n";
  252. docSource += "[color=#00a500][i][b]Miscellaneous:[/b][/i][/color]\n";
  253.  
  254. docSource += "[img]http://www." + statsDomain + "/image.php?type=playerssgraph&graph=points&id=" + playerId + "&s=" + server + "[/img]\n";
  255. docSource += "[img]http://www." + statsDomain + "/image.php?type=playerssgraph&graph=villages&id=" + playerId + "&s=" + server + "[/img]\n\n";
  256. docSource += "Name: [player]" + thePlayer + "[/player]\n";
  257. docSource += "Points: " + thePoints + "\n";
  258. docSource += "OD: " + OD + "\n";
  259. docSource += "Tribe: " + ((tribeId > 0) ? ("[ally]" + theTribe + "[/ally]") : "[color=silver]None[/color]") + "\n";
  260. docSource += "[url=http://www." + statsDomain + "/" + server + "/index.php?page=player&fi=1&id=" + playerId + "]TWStats[/url]\n";
  261.  
  262. if (tribeId > 0) {
  263. docSource += "[url=http://www." + statsDomain + "/" + server + "/index.php?page=map&tribe_0_id=" + tribeId + "&tribe_0_colour=ff00ff&player_0_id=" + playerId + "&player_0_colour=00aeff&zoom=100&centrex=500&centrey=500&nocache=1&fill=000000&grid=1]Map[/url]\n";
  264. }
  265.  
  266. docSource += "\n\n";
  267. docSource += legacyOutput;
  268. docSource += "</textarea><br/>\n";
  269.  
  270. /*==== fake script section ====*/
  271.  
  272. if (game_data.market != 'uk') {
  273. docSource += "<h3>Random fake script for all villages:</h3>\n";
  274. docSource += "<textarea cols='80' rows='9' onFocus='this.select()'>\n";
  275. docSource += "javascript:var coords = '" + coords.join(" ") + "';";
  276. docSource += "function fnFillRallyPoint(){var coord=coords.split(' ');var coordSplit=coord[Math.floor(Math.random()*coord.length)].split('|');document.forms[0].x.value=coordSplit[0];document.forms[0].y.value=coordSplit[1];var scouts=parseInt(document.forms[0].spy.nextSibling.nextSibling.innerHTML.match(/\\d+/),10);if(scouts>0){document.forms[0].spy.value=1;}var rams=parseInt(document.forms[0].ram.nextSibling.nextSibling.innerHTML.match(/\\d+/),10);if(rams>0){document.forms[0].ram.value=1;}else{var cats=parseInt(document.forms[0].catapult.nextSibling.nextSibling.innerHTML.match(/\\d+/),10);if(cats>0){document.forms[0].catapult.value=1;}}}fnFillRallyPoint();";
  277. docSource += "</textarea><br/>\n";
  278.  
  279. docSource += "<h3>Sequential fake script for all villages:</h3>\n";
  280. docSource += "<textarea cols='80' rows='9' onFocus='this.select()'>\n";
  281. docSource += fnGenerateSequentialFakeScript(coords, 1);
  282. docSource += "</textarea><br/>\n";
  283.  
  284. docSource += "<h3>Sequential fake train script for all villages:</h3>\n";
  285. docSource += "<textarea cols='80' rows='9' onFocus='this.select()'>\n";
  286. docSource += fnGenerateSequentialFakeScript(coords, 5);
  287. docSource += "</textarea><br/>\n";
  288. }
  289.  
  290. var outputWin = window.open();
  291. outputWin.document.open('text/html', 'replace');
  292. outputWin.document.write(docSource);
  293. outputWin.document.close();
  294. }
  295.  
  296. fnGenerateOp();
  297. void (0);
  298. } catch (objError) {
  299. var dbgMsg = "Error: " + String(objError.message || objError);
  300. /*
  301. fnDebugMessage(dbgMsg);
  302. */
  303. alert(dbgMsg);
  304. }
  305. }
  306.  
  307.  
  308. /*fnExecuteScript();*/
  309. script.js
  310. Sign In
  311. Displaying script.js.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement