Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by polish on 16.10.14.
- */
- var attackNames = ["clean", "noble_0", "noble_1", "noble_2"];
- var attackFrames = [];
- var newWindow;
- var cleanUnits = {
- "unit_input_spear": 0,
- "unit_input_sword": 0,
- "unit_input_axe": 200,
- "unit_input_archer": 0,
- "unit_input_spy": 0,
- "unit_input_light": 0,
- "unit_input_marcher": 0,
- "unit_input_heavy": 0,
- "unit_input_ram": 0,
- "unit_input_catapult": 0,
- "unit_input_knight": 0,
- "unit_input_snob": 1
- };
- var nobleUnits = {
- "unit_input_spear": 0,
- "unit_input_sword": 0,
- "unit_input_axe": 200,
- "unit_input_archer": 0,
- "unit_input_spy": 0,
- "unit_input_light": 0,
- "unit_input_marcher": 0,
- "unit_input_heavy": 0,
- "unit_input_ram": 0,
- "unit_input_catapult": 0,
- "unit_input_knight": 0,
- "unit_input_snob": 1
- };
- Element.prototype.remove = function () {
- this.parentElement.removeChild(this);
- };
- NodeList.prototype.remove = HTMLCollection.prototype.remove = function () {
- for (var i = 0, len = this.length; i < len; i++) {
- if (this[i] && this[i].parentElement) {
- this[i].parentElement.removeChild(this[i]);
- }
- }
- };
- function onFramesLoaded(frame) {
- }
- function hideFrame(frameName) {
- frameName.style.visibility = frameName.style.visibility == "hidden" ? "" : "hidden";
- }
- function confirmAttack(frameName) {
- var frameDoc = frameName.contentWindow.document;
- frameDoc.getElementById("target_attack").click();
- }
- function sendAttack(frameName) {
- console.log(new Date().getUTCMilliseconds());
- var frameDoc = frameName.contentWindow.document;
- frameDoc.getElementById("troop_confirm_go").click();
- }
- function setTroops(frameName) {
- var frameDoc = frameName.contentWindow.document;
- var units;
- if (frameName.id == "clean") {
- units = cleanUnits;
- } else {
- units = nobleUnits;
- }
- for (var m in units) {
- frameDoc.getElementById(m).value = units[m];
- }
- }
- function setAllTroops() {
- attackNames.map(function (frameName) {
- setTroops(getFrameForName(frameName));
- });
- }
- function confirmAllAttacks() {
- attackNames.map(function (frameName) {
- confirmAttack(getFrameForName(frameName));
- });
- }
- function sendAllAttacks() {
- if (new Date().getUTCMilliseconds() > 100 && new Date().getUTCMilliseconds() < 150) {
- attackNames.map(function (frameName) {
- sendAttack(getFrameForName(frameName));
- });
- }
- }
- function getFrameForName(frameName) {
- return document.getElementById(frameName);
- }
- function getURLParameter(name) {
- return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null
- }
- function run() {
- newWindow = window.open('about:blank', 'Synchro by Polish', 'width=800,height=730,scrollbars=yes');
- var doc = newWindow.document;
- doc.url = 'D';
- doc.open();
- doc.write('<html>');
- doc.write('<title> Synchro by Polish </title>');
- doc.write('<body>');
- var target = getURLParameter("target");
- var village = getURLParameter("village");
- attackNames.map(function (frameName) {
- doc.write("" +
- "<button onclick='setAllTroops(" + frameName + ");' class='setAllTroops_'>Set all troops</button>" +
- "<button onclick='confirmAllAttacks(" + frameName + ");' class='confirmAllAttacks_'>Confirm all attacks</button>" +
- "<button onclick='sendAllAttacks(" + frameName + ");' class='sendAllAttacks_'>Send all attacks</button>" +
- "<div> " +
- "<h1>" + frameName + "</h1>" +
- "<button onclick='hideFrame(" + frameName + ");' class='toggle_'" + frameName + ">Show/Hide</button>" +
- "<button onclick='setTroops(" + frameName + ");' class='setTroops_'" + frameName + ">Set troops</button>" +
- "<button onclick='confirmAttack(" + frameName + ");' class='confirmAttack_'" + frameName + ">Confirm</button>" +
- "<button onclick='sendAttack(" + frameName + ");' class='sendAttack_'" + frameName + ">Send attack</button>" +
- "" +
- "</div>")
- doc.write(
- '<iframe id=' + frameName + ' src="http://pl86.plemiona.pl/game.php?village=' + village + '&screen=place&target=' + target + '" width="100%" height="25%">' +
- '</iframe>'
- );
- });
- doc.write('</body>');
- doc.write('</html>');
- doc.close();
- attackNames.map(function (item) {
- hideFrame(doc.getElementById(item));
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement