SHARE
TWEET

grab

a guest Sep 11th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         dhsds_mitschreiber_GRABEDIT
  3. // @namespace    http://tampermonkey.net/
  4. // @version      1.0
  5. // @description  schwarz auf weiss
  6. // @author       kukgdtug
  7. // @match        https://*.die-staemme.de/game.php*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.     'use strict';
  13.  
  14.     var url = $(location).attr("href");
  15.  
  16.     var betreff = $("#content_value > table > tbody > tr > td:nth-child(2) > table > tbody > tr > td > table:nth-child(2) > tbody > tr:nth-child(1) > th:nth-child(2) > span > span > span").html();
  17.  
  18.  
  19.     var messageblock = {};
  20.  
  21.     // Create WebSocket client.
  22.     const socket = new WebSocket('wss://37c1992.online-server.cloud/grabber/ws_post_report');
  23.  
  24.     socket.onerror = function(event) {
  25.         console.error("WebSocket error observed:", event);
  26.     };
  27.  
  28.  
  29.     socket.onopen = function(event) {
  30.         console.log("WebSocket is open now.");
  31.  
  32.         $(document).ready(function() {
  33.  
  34.             if(url.includes("screen=report") && url.includes("&view")){
  35.                 //check if battle report
  36.                 var temp_title = $("#content_value > table > tbody > tr > td:nth-child(2) > table > tbody > tr > td > table:nth-child(2) > tbody > tr:nth-child(3) > td > h3").html();
  37.  
  38.         if (temp_title == undefined){
  39.             temp_title = $("#content_value > table > tbody > tr > td:nth-child(2) > table > tbody > tr > td > table:nth-child(2) > tbody > tr:nth-child(5) > td > h3").html();
  40.         }
  41.  
  42.                 console.log(temp_title);
  43.                 if(temp_title != undefined && (temp_title.includes("gewonnen") || temp_title.includes("ausgekundschaftet"))){
  44.                     messageblock = parseReportDataFromHtml();
  45.                     socket.send(JSON.stringify(messageblock));
  46.                 }
  47.             }
  48.         });
  49.     };
  50.  
  51.  
  52. })();
  53.  
  54. function parseReportDataFromHtml(){
  55.     var data = {};
  56.     var temp;
  57.  
  58.     //bericht_id
  59.     temp = $(location).attr("href");
  60.     if (temp != undefined){
  61.         data.bericht_id = Number(temp.substring((temp.indexOf("view=")+5)));
  62.         console.log("bericht_id: " + data.bericht_id);
  63.     }else{
  64.         console.log("BERICHT ID NOT FOUND");
  65.     }
  66.  
  67.     //betreff
  68.     temp = $("#content_value > table > tbody > tr > td:nth-child(2) > table > tbody > tr > td > table:nth-child(2) > tbody > tr:nth-child(1) > th:nth-child(2) > span > span > span").html();
  69.     if (temp != undefined){
  70.         temp = temp.trimStart();
  71.         temp = temp.trimEnd();
  72.         data.betreff = temp;
  73.         console.log("betreff: " + data.betreff);
  74.     }else{
  75.         console.log("BETREFF NOT FOUND");
  76.     }
  77.  
  78.     //uhrzeit
  79.     temp = $("#content_value > table > tbody > tr > td:nth-child(2) > table > tbody > tr > td > table:nth-child(2) > tbody > tr:nth-child(2) > td:nth-child(2)").html();
  80.     if (temp != undefined){
  81.         temp = temp.trimStart().trimEnd().split(' '); //17.02.19 15:12:18
  82.         var temp_datum = temp[0].split(".");
  83.         temp = Date.parse("20"+temp_datum[2]+"-"+temp_datum[1]+"-"+temp_datum[0]+"T"+temp[1]); //"2011-10-10T14:48:00+01:00"
  84.         data.timestamp = temp + 3600000; //TODO +1h offset bc of timezone - probably wrong
  85.         console.log("timestamp: " + data.timestamp);
  86.     }else{
  87.         console.log("UHRZEIT NOT FOUND");
  88.     }
  89.  
  90.     //titel
  91.     temp = $("#content_value > table > tbody > tr > td:nth-child(2) > table > tbody > tr > td > table:nth-child(2) > tbody > tr:nth-child(3) > td > h3").html();
  92.     if (temp != undefined){
  93.         data.titel = temp;
  94.         console.log("titel: " + data.titel);
  95.     }else{
  96.         temp = $("#content_value > table > tbody > tr > td:nth-child(2) > table > tbody > tr > td > table:nth-child(2) > tbody > tr:nth-child(5) > td > h3").html();
  97.         if (temp != undefined){
  98.             data.titel = temp;
  99.             console.log("titel: " + data.titel);
  100.         }else{
  101.             console.log("TITEL NOT FOUND");
  102.         }
  103.     }
  104.  
  105.     //glueck
  106.     temp = $("#attack_luck > tbody > tr > td:nth-child(4) > b").html(); //positive
  107.     if (temp != undefined){
  108.         data.glueck = Number(temp.substring(0,temp.length-1));
  109.         console.log("glueck: " + data.glueck);
  110.     }
  111.     temp = $("#attack_luck > tbody > tr > td:nth-child(1) > b").html(); //negative
  112.     if (temp != undefined){
  113.         data.glueck = Number(temp.substring(0,temp.length-1));
  114.         console.log("glueck: " + data.glueck);
  115.     }
  116.  
  117.     //angreifer_name
  118.     temp = $("#attack_info_att > tbody > tr:nth-child(1) > th:nth-child(2) > a").html();
  119.     if (temp != undefined){
  120.         temp = temp.split();
  121.         data.angreifer_name = temp[0];
  122.         console.log("angreifer_name: " + data.angreifer_name);
  123.     }else{
  124.         console.log("angreifer_name NOT FOUND");
  125.     }
  126.  
  127.     //angreifer_id
  128.     temp = $("#attack_info_att > tbody > tr:nth-child(1) > th:nth-child(2) > a").prop("href");
  129.     if (temp != undefined){
  130.         temp = temp.split("=");
  131.         data.angreifer_id = Number(temp[3]);
  132.         console.log("angreifer_id: " + data.angreifer_id);
  133.     }else{
  134.         console.log("angreifer_id NOT FOUND");
  135.     }
  136.  
  137.     //angreifer_dorf_name
  138.     temp = $("#attack_info_att > tbody > tr:nth-child(2) > td:nth-child(2) > span > a:nth-child(1)").html();
  139.     if (temp != undefined){
  140.         temp = temp.split('(');
  141.         data.angreifer_dorf_name = temp[0];
  142.         console.log("angreifer_dorf_name: " + data.angreifer_dorf_name);
  143.     }else{
  144.         console.log("angreifer_dorf_name NOT FOUND");
  145.     }
  146.  
  147.     //angreifer_dorf_coord
  148.     temp = $("#attack_info_att > tbody > tr:nth-child(2) > td:nth-child(2) > span > a:nth-child(1)").html();
  149.     if (temp != undefined){
  150.         temp = temp.split('(');
  151.         temp = temp[1];
  152.         temp = temp.split(')');
  153.         data.angreifer_dorf_coord = temp[0];
  154.         console.log("angreifer_dorf_coord: " + data.angreifer_dorf_coord);
  155.     }else{
  156.         console.log("angreifer_dorf_coord NOT FOUND");
  157.     }
  158.  
  159.     //angreifer_dorf_id
  160.     temp = $("#attack_info_att > tbody > tr:nth-child(2) > td:nth-child(2) > span > a:nth-child(1)").prop("href");
  161.     if (temp != undefined){
  162.         temp = temp.split("=");
  163.         data.angreifer_dorf_id = Number(temp[3]);
  164.         console.log("angreifer_dorf_id: " + data.angreifer_dorf_id);
  165.     }else{
  166.         console.log("angreifer_dorf_id NOT FOUND");
  167.     }
  168.  
  169.     //angreifer_truppen_anzahl
  170.     temp = $("#attack_info_att_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-spear").html();
  171.     if (temp != undefined){
  172.         data.angreifer_truppen_anzahl = {};
  173.         data.angreifer_truppen_anzahl[0] = Number($("#attack_info_att_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-spear").html());
  174.         data.angreifer_truppen_anzahl[1] = Number($("#attack_info_att_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-sword").html());
  175.         data.angreifer_truppen_anzahl[2] = Number($("#attack_info_att_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-axe").html());
  176.         data.angreifer_truppen_anzahl[3] = Number($("#attack_info_att_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-spy").html());
  177.         data.angreifer_truppen_anzahl[4] = Number($("#attack_info_att_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-light").html());
  178.         data.angreifer_truppen_anzahl[5] = Number($("#attack_info_att_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-heavy").html());
  179.         data.angreifer_truppen_anzahl[6] = Number($("#attack_info_att_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-ram").html());
  180.         data.angreifer_truppen_anzahl[7] = Number($("#attack_info_att_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-catapult").html());
  181.         data.angreifer_truppen_anzahl[8] = Number($("#attack_info_att_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-snob").html());
  182.  
  183.         console.log("angreifer_truppen_anzahl: " + data.angreifer_truppen_anzahl);
  184.     }else{
  185.         console.log("angreifer_truppen_anzahl NOT FOUND");
  186.     }
  187.  
  188.     //angreifer_truppen_verluste
  189.     temp = $("#attack_info_att_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-spear").html();
  190.     if (temp != undefined){
  191.         data.angreifer_truppen_verluste = {};
  192.         data.angreifer_truppen_verluste[0] = Number($("#attack_info_att_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-spear").html());
  193.         data.angreifer_truppen_verluste[1] = Number($("#attack_info_att_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-sword").html());
  194.         data.angreifer_truppen_verluste[2] = Number($("#attack_info_att_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-axe").html());
  195.         data.angreifer_truppen_verluste[3] = Number($("#attack_info_att_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-spy").html());
  196.         data.angreifer_truppen_verluste[4] = Number($("#attack_info_att_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-light").html());
  197.         data.angreifer_truppen_verluste[5] = Number($("#attack_info_att_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-heavy").html());
  198.         data.angreifer_truppen_verluste[6] = Number($("#attack_info_att_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-ram").html());
  199.         data.angreifer_truppen_verluste[7] = Number($("#attack_info_att_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-catapult").html());
  200.         data.angreifer_truppen_verluste[8] = Number($("#attack_info_att_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-snob").html());
  201.  
  202.         console.log("angreifer_truppen_verluste: " + data.angreifer_truppen_verluste);
  203.     }else{
  204.         console.log("angreifer_truppen_verluste NOT FOUND");
  205.     }
  206.  
  207.  
  208.  
  209.     //verteidiger_name
  210.     temp = $("#attack_info_def > tbody > tr:nth-child(1) > th:nth-child(2) > a").html();
  211.     if (temp != undefined){
  212.         temp = temp.split();
  213.         data.verteidiger_name = temp[0];
  214.         console.log("verteidiger_name: " + data.verteidiger_name);
  215.     }else{
  216.         console.log("verteidiger_name NOT FOUND");
  217.     }
  218.  
  219.     //verteidiger_id
  220.     temp = $("#attack_info_def > tbody > tr:nth-child(1) > th:nth-child(2) > a").prop("href");
  221.     if (temp != undefined){
  222.         temp = temp.split("=");
  223.         data.verteidiger_id = Number(temp[3]);
  224.         console.log("verteidiger_id: " + data.verteidiger_id);
  225.     }else{
  226.         console.log("verteidiger_id NOT FOUND");
  227.     }
  228.  
  229.     temp = $("#attack_info_def > tbody > tr:nth-child(1) > th:nth-child(2)").html();
  230.     if (temp == "---"){
  231.         data.verteidiger_id = 0;
  232.         console.log("verteidiger_id: " + data.verteidiger_id);
  233.     }else{
  234.         console.log("verteidiger_id NOT FOUND");
  235.     }
  236.  
  237.     //verteidiger_dorf_name
  238.     temp = $("#attack_info_def > tbody > tr:nth-child(2) > td:nth-child(2) > span > a:nth-child(1)").html();
  239.     if (temp != undefined){
  240.         temp = temp.split('(');
  241.         data.verteidiger_dorf_name = temp[0];
  242.         console.log("verteidiger_dorf_name: " + data.verteidiger_dorf_name);
  243.  
  244.     }else{
  245.         console.log("verteidiger_dorf_name NOT FOUND");
  246.     }
  247.  
  248.     //verteidiger_dorf_coord
  249.     temp = $("#attack_info_def > tbody > tr:nth-child(2) > td:nth-child(2) > span > a:nth-child(1)").html();
  250.     if (temp != undefined){
  251.         temp = temp.split('(');
  252.         temp = temp[1];
  253.         temp = temp.split(')');
  254.         data.verteidiger_dorf_coord = temp[0];
  255.         console.log("verteidiger_dorf_coord: " + data.verteidiger_dorf_coord);
  256.  
  257.     }else{
  258.         console.log("verteidiger_dorf_coord NOT FOUND");
  259.     }
  260.  
  261.     //verteidiger_dorf_id
  262.     temp = $("#attack_info_def > tbody > tr:nth-child(2) > td:nth-child(2) > span > a:nth-child(1)").prop("href");
  263.     if (temp != undefined){
  264.         temp = temp.split("=");
  265.         data.verteidiger_dorf_id = Number(temp[3]);
  266.         console.log("verteidiger_dorf_id: " + data.verteidiger_dorf_id);
  267.     }else{
  268.         console.log("verteidiger_dorf_id NOT FOUND");
  269.     }
  270.  
  271.     //verteidiger_truppen_anzahl
  272.     temp = $("#attack_info_def_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-spear").html();
  273.     if (temp != undefined){
  274.         data.verteidiger_truppen_anzahl = {};
  275.         data.verteidiger_truppen_anzahl[0] = Number($("#attack_info_def_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-spear").html());
  276.         data.verteidiger_truppen_anzahl[1] = Number($("#attack_info_def_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-sword").html());
  277.         data.verteidiger_truppen_anzahl[2] = Number($("#attack_info_def_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-axe").html());
  278.         data.verteidiger_truppen_anzahl[3] = Number($("#attack_info_def_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-spy").html());
  279.         data.verteidiger_truppen_anzahl[4] = Number($("#attack_info_def_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-light").html());
  280.         data.verteidiger_truppen_anzahl[5] = Number($("#attack_info_def_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-heavy").html());
  281.         data.verteidiger_truppen_anzahl[6] = Number($("#attack_info_def_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-ram").html());
  282.         data.verteidiger_truppen_anzahl[7] = Number($("#attack_info_def_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-catapult").html());
  283.         data.verteidiger_truppen_anzahl[8] = Number($("#attack_info_def_units > tbody > tr:nth-child(2) > td.unit-item.unit-item-snob").html());
  284.  
  285.         console.log("verteidiger_truppen_anzahl: " + data.verteidiger_truppen_anzahl);
  286.     }else{
  287.         console.log("verteidiger_truppen_anzahl NOT FOUND");
  288.     }
  289.  
  290.     //verteidiger_truppen_verluste
  291.     temp = $("#attack_info_def_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-spear").html();
  292.     if (temp != undefined){
  293.         data.verteidiger_truppen_verluste = {};
  294.         data.verteidiger_truppen_verluste[0] = Number($("#attack_info_def_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-spear").html());
  295.         data.verteidiger_truppen_verluste[1] = Number($("#attack_info_def_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-sword").html());
  296.         data.verteidiger_truppen_verluste[2] = Number($("#attack_info_def_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-axe").html());
  297.         data.verteidiger_truppen_verluste[3] = Number($("#attack_info_def_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-spy").html());
  298.         data.verteidiger_truppen_verluste[4] = Number($("#attack_info_def_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-light").html());
  299.         data.verteidiger_truppen_verluste[5] = Number($("#attack_info_def_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-heavy").html());
  300.         data.verteidiger_truppen_verluste[6] = Number($("#attack_info_def_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-ram").html());
  301.         data.verteidiger_truppen_verluste[7] = Number($("#attack_info_def_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-catapult").html());
  302.         data.verteidiger_truppen_verluste[8] = Number($("#attack_info_def_units > tbody > tr:nth-child(3) > td.unit-item.unit-item-snob").html());
  303.  
  304.         console.log("verteidiger_truppen_verluste: " + data.verteidiger_truppen_verluste);
  305.     }else{
  306.         console.log("verteidiger_truppen_verluste NOT FOUND");
  307.     }
  308.  
  309.     //spionage
  310.     if($("#content_value > table > tbody > tr > td:nth-child(2) > table > tbody > tr > td > table:nth-child(2) > tbody > tr:nth-child(3) > td > h4").html() == "Spionage" ||
  311.       $("#content_value > table > tbody > tr > td:nth-child(2) > table > tbody > tr > td > table:nth-child(2) > tbody > tr:nth-child(5) > td > h4").html() == "Spionage"){
  312.  
  313.         //spionage_ress_erspaeht
  314.         temp = $("#attack_spy_resources > tbody > tr:nth-child(1) > td").html();
  315.         if (temp == "keine"){
  316.             data.spionage_ress_erspaeht = [0,0,0];
  317.             console.log("spionage_ress_erspaeht: " + data.spionage_ress_erspaeht);
  318.         }else if (temp != undefined){
  319.             data.spionage_ress_erspaeht = [0,0,0];
  320.             var temp_holz = $("#attack_spy_resources > tbody > tr:nth-child(1) > td > span:nth-child(1)").text();
  321.             if(temp_holz != undefined){
  322.                 temp_holz = temp_holz.replace(".", "");
  323.                 temp_holz = temp_holz.trimStart();
  324.             }else{
  325.                 temp_holz = 0;
  326.             }
  327.  
  328.             var temp_lehm = $("#attack_spy_resources > tbody > tr:nth-child(1) > td > span:nth-child(2)").text();
  329.             if(temp_lehm != undefined){
  330.                 temp_lehm = temp_lehm.replace(".", "");
  331.                 temp_lehm = temp_lehm.trimStart();
  332.             }
  333.  
  334.             var temp_eisen = $("#attack_spy_resources > tbody > tr:nth-child(1) > td > span:nth-child(3)").text();
  335.             if(temp_eisen != undefined){
  336.                 temp_eisen = temp_eisen.replace(".", "");
  337.                 temp_eisen = temp_eisen.trimStart();
  338.             }else{
  339.                 temp_eisen = 0;
  340.             }
  341.  
  342.  
  343.             data.spionage_ress_erspaeht = [Number(temp_holz),Number(temp_lehm),Number(temp_eisen)];
  344.             console.log("spionage_ress_erspaeht: " + data.spionage_ress_erspaeht);
  345.         }
  346.  
  347.         //spionage_gebauede
  348.         temp = $("#attack_spy_building_data").attr("value");
  349.         if (temp != undefined){
  350.             temp = JSON.parse(temp);
  351.             data.spionage_gebauede = temp;
  352.             console.log("spionage_gebauede: " + data.spionage_gebauede);
  353.         }
  354.  
  355.         //spionage_ausserhalb
  356.         temp = $("#attack_spy_away > tbody > tr:nth-child(1) > th").html();
  357.         if (temp == "Einheiten außerhalb:"){
  358.             data.spionage_ausserhalb = {};
  359.             data.spionage_ausserhalb[0] = Number($("#attack_spy_away > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td.unit-item.unit-item-spear").html());
  360.             data.spionage_ausserhalb[1] = Number($("#attack_spy_away > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td.unit-item.unit-item-sword").html());
  361.             data.spionage_ausserhalb[2] = Number($("#attack_spy_away > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td.unit-item.unit-item-axe").html());
  362.             data.spionage_ausserhalb[3] = Number($("#attack_spy_away > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td.unit-item.unit-item-spy").html());
  363.             data.spionage_ausserhalb[4] = Number($("#attack_spy_away > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td.unit-item.unit-item-light").html());
  364.             data.spionage_ausserhalb[5] = Number($("#attack_spy_away > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td.unit-item.unit-item-heavy").html());
  365.             data.spionage_ausserhalb[6] = Number($("#attack_spy_away > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td.unit-item.unit-item-ram").html());
  366.             data.spionage_ausserhalb[7] = Number($("#attack_spy_away > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td.unit-item.unit-item-catapult").html());
  367.             data.spionage_ausserhalb[8] = Number($("#attack_spy_away > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td.unit-item.unit-item-snob").html());
  368.  
  369.             console.log("spionage_ausserhalb: " + data.spionage_ausserhalb);
  370.         }
  371.  
  372.     }else{
  373.         console.log("SPIONAGE NOT FOUND");
  374.     }
  375.  
  376.     //beute
  377.     temp = $("#attack_results > tbody > tr:nth-child(1) > th").html();
  378.     if (temp == "Beute:"){
  379.  
  380.         //init
  381.         temp_holz = 0;
  382.         temp_lehm = 0;
  383.         temp_eisen = 0;
  384.  
  385.         //first
  386.         if($("#attack_results > tbody > tr > td:nth-child(2) > span:nth-child(1) > span.icon.header.wood").html() != undefined){
  387.             temp_holz = $("#attack_results > tbody > tr:nth-child(1) > td > span:nth-child(1)").text().replace(".", "").trimStart();
  388.         }else if($("#attack_results > tbody > tr > td:nth-child(2) > span:nth-child(1) > span.icon.header.stone").html() != undefined){
  389.             temp_lehm = $("#attack_results > tbody > tr:nth-child(1) > td > span:nth-child(1)").text().replace(".", "").trimStart();
  390.         }else if($("#attack_results > tbody > tr > td:nth-child(2) > span:nth-child(1) > span.icon.header.iron").html() != undefined){
  391.             temp_eisen = $("#attack_results > tbody > tr:nth-child(1) > td > span:nth-child(1)").text().replace(".", "").trimStart();
  392.         }
  393.  
  394.         //second
  395.         if($("#attack_results > tbody > tr > td:nth-child(2) > span:nth-child(2) > span.icon.header.wood").html() != undefined){
  396.             temp_holz = $("#attack_results > tbody > tr > td:nth-child(2) > span:nth-child(2)").text().replace(".", "").trimStart();
  397.         }else if($("#attack_results > tbody > tr > td:nth-child(2) > span:nth-child(2) > span.icon.header.stone").html() != undefined){
  398.             temp_lehm = $("#attack_results > tbody > tr > td:nth-child(2) > span:nth-child(2)").text().replace(".", "").trimStart();
  399.         }else if($("#attack_results > tbody > tr > td:nth-child(2) > span:nth-child(2) > span.icon.header.iron").html() != undefined){
  400.             temp_eisen = $("#attack_results > tbody > tr > td:nth-child(2) > span:nth-child(2)").text().replace(".", "").trimStart();
  401.         }
  402.  
  403.         //third
  404.         if($("#attack_results > tbody > tr > td:nth-child(2) > span:nth-child(3) > span.icon.header.wood").html() != undefined){
  405.             temp_holz = $("#attack_results > tbody > tr > td:nth-child(2) > span:nth-child(3)").text().replace(".", "").trimStart();
  406.         }else if($("#attack_results > tbody > tr > td:nth-child(2) > span:nth-child(3) > span.icon.header.stone").html() != undefined){
  407.             temp_lehm = $("#attack_results > tbody > tr > td:nth-child(2) > span:nth-child(3)").text().replace(".", "").trimStart();
  408.         }else if($("#attack_results > tbody > tr > td:nth-child(2) > span:nth-child(3) > span.icon.header.iron").html() != undefined){
  409.             temp_eisen = $("#attack_results > tbody > tr > td:nth-child(2) > span:nth-child(3)").text().replace(".", "").trimStart();
  410.         }
  411.  
  412.         data.beute = [Number(temp_holz),Number(temp_lehm),Number(temp_eisen)];
  413.         console.log("beute: " + data.beute);
  414.  
  415.         //beute_ausnutzung
  416.         temp = $("#attack_results > tbody > tr:nth-child(1) > td:nth-child(3)").text().split("/");
  417.         if (temp != undefined){
  418.             temp = (Number(temp[0])/Number(temp[1])).toFixed(2);
  419.             if (isNaN(temp)){
  420.                 temp = 0;
  421.             }
  422.             data.beute_ausnutzung = temp;
  423.             console.log("beute_ausnutzung: " + data.beute_ausnutzung);
  424.         }
  425.     }else{
  426.         console.log("BEUTE NOT FOUND");
  427.     }
  428.  
  429.     //zustimmung
  430.     temp = $("#attack_results > tbody > tr:nth-child(2) > th").html();
  431.     if (temp == "Zustimmung:"){
  432.         temp = $("#attack_results > tbody > tr:nth-child(2) > td").text();
  433.         data.zustimmung = temp;
  434.         console.log("zustimmung: " + data.zustimmung);
  435.     }else{
  436.         console.log("zustimmung NOT FOUND");
  437.     }
  438.  
  439.     //kata rammbock dmg dedection
  440.  
  441.  
  442.     //tr nr 1
  443.     temp = $("#attack_results > tbody > tr:nth-child(1) > th").html();
  444.     if (temp == "Schaden durch Rammböcke:"){
  445.         temp = $("#attack_results > tbody > tr:nth-child(1) > td").text();
  446.         data.schaden_rammbock = temp.trimStart().trimEnd();
  447.     }else if(temp == "Schaden durch Katapultbeschuss:"){
  448.         temp = $("#attack_results > tbody > tr:nth-child(1) > td").text();
  449.         data.schaden_katapult = temp.trimStart().trimEnd();
  450.     }
  451.  
  452.     //tr nr 2
  453.     temp = $("#attack_results > tbody > tr:nth-child(2) > th").html();
  454.     if (temp == "Schaden durch Rammböcke:"){
  455.         temp = $("#attack_results > tbody > tr:nth-child(2) > td").text();
  456.         data.schaden_rammbock = temp.trimStart().trimEnd();
  457.     }else if(temp == "Schaden durch Katapultbeschuss:"){
  458.         temp = $("#attack_results > tbody > tr:nth-child(2) > td").text();
  459.         data.schaden_katapult = temp.trimStart().trimEnd();
  460.     }
  461.  
  462.     //tr nr 3
  463.     temp = $("#attack_results > tbody > tr:nth-child(3) > th").html();
  464.     if (temp == "Schaden durch Rammböcke:"){
  465.         temp = $("#attack_results > tbody > tr:nth-child(3) > td").text();
  466.         data.schaden_rammbock = temp.trimStart().trimEnd();
  467.     }else if(temp == "Schaden durch Katapultbeschuss:"){
  468.         temp = $("#attack_results > tbody > tr:nth-child(3) > td").text();
  469.         data.schaden_katapult = temp.trimStart().trimEnd();
  470.     }
  471.  
  472.     if(data.schaden_katapult != undefined){
  473.         console.log("schaden_katapult: " + data.schaden_katapult);
  474.     }else{
  475.         console.log("schaden_katapult NOT FOUND");
  476.     }
  477.     if(data.schaden_rammbock != undefined){
  478.         console.log("schaden_rammbock: " + data.schaden_rammbock);
  479.     }else{
  480.         console.log("schaden_rammbock NOT FOUND");
  481.     }
  482.  
  483.  
  484.     //hinweis
  485.     temp = $("#attack_info > tbody > tr:nth-child(1) > th").html();
  486.     if (temp == "Hinweis:"){
  487.         temp = $("#attack_info > tbody > tr:nth-child(2) > td").text();
  488.         data.hinweis = temp.trimStart().trimEnd();
  489.         console.log("hinweis: " + data.hinweis);
  490.     }else{
  491.         console.log("hinweis NOT FOUND");
  492.     }
  493.  
  494.     return data;
  495.  
  496. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top