Taggescript - med små forrandringer.

Status
Stengt for ytterligere svar.

Hophoolio

Guest
Forrige oppdatering forrandret hvordan datoene blir skrevet i kommando siden for et enkelt angrep. Derfor vil ikke det forrige fungerende scriptet kunne tagge med ca "sent"-tid. Her er et som værtfall vil fungere ut august:
Kode:
javascript:  hops = document.getElementById('edit').parentNode.parentNode.parentNode.getElementsByTagName('td');  hop = hops[11].innerText;  hop = hop.slice(0, -4);  hop = hop.replace("jan.","january");  hop = hop.replace("feb.","february");  hop = hop.replace("mar.","march");  hop = hop.replace("mai","may");  hop = hop.replace("jun.","june");  hop = hop.replace("jul.","july");  hop = hop.replace("okt.","october");  hop = hop.replace("aug.","october");  hop = hop.replace("des.","december");  hops[11].innerText = hop;var doc=document;    if(window.frames.length>0)doc=window.main.document;    url = doc.URL;    function myErrorSuppressor() {      return true;  }  window.onerror = myErrorSuppressor;    function labelAttack() {      if (typeof (theFormat) == 'undefined') theFormat = '{unit} - {origin} - {player} - ID: {atkid} - Sent: {sent}';      arrUnitNames = ['Scout', 'LC', 'HC', 'Axe', 'Sword', 'Ram', '***Noble***'];      arrReplace = ['unit', 'coords', 'player', 'distance', 'sent', 'duration', 'arrival', 'origin', 'destination', 'destinationxy', 'atkid'];      arrHead = ['Unit', 'Sent', 'Duration', 'Name To'];      arrValues = arrReplace;        function fnReg(txtString) {          return new RegExp("\{" + txtString + "\}", "ig");      }      arrReplace = arrReplace.map(fnReg);        function fnGetConfig() {          var oRequest = new XMLHttpRequest();          var sURL = "http://" + window.location.hostname + "/interface.php?func=get_config";          oRequest.open("GET", sURL, 0);          oRequest.send(null);          if (oRequest.status == 200) return oRequest.responseXML;          alert("Error executing XMLHttpRequest call to get Config!");      }      var xmldocument = fnGetConfig();      theUnitSpeed = xmldocument.getElementsByTagName('unit_speed')[0].childNodes[0].nodeValue;      theWorldSpeed = xmldocument.getElementsByTagName('speed')[0].childNodes[0].nodeValue;        function myGetCoords(theString) {          return /(.*?)\s\(((\d+)\|(\d+))\)\sK(\d+)/i.exec(theString);      }        function myZeroPad(theString) {          theInt = parseInt(theString, 10);          return (theInt > 9 ? theInt : '0' + theInt);      }        function myGetElementsByTagName(theObj, theString) {          return theObj.getElementsByTagName(theString);      }        function myGetInner(theObj) {          return theObj.innerHTML;      }        function myGetInnerofFirstLink(theObj) {          return myGetInner(myGetElementsByTagName(theObj, 'a')[0]);      }        function myInsRow() {          return theTable.insertRow(intRow++);      }        function fnAttackID() {          var a = document.URL.match(/\d+/g);          return document.URL.match(/\d+/g)[a.length - 1];      }        function myInsCell(theInt) {          return newRow.insertCell(theInt);      }        function mySetInner(theObj, theString) {          theObj.innerHTML = theString;          return theObj;      }        function myInsTH(theString) {          newCell = newRow.appendChild(document.createElement('th'));          return mySetInner(newCell, theString);      }        function myTime(theInt) {          return myZeroPad(theInt / Const3600) + ':' + myZeroPad(theInt % (Const3600) / Const60) + ':' + myZeroPad(theInt % Const60);      }        function fnInt(txtInt) {          return parseInt(txtInt, 10);      }        function fnDate(txtDate) {          arrMs = txtDate.match(/:(\d{3})$/i);          if (arrMs) txtDate = txtDate.replace(/:(\d{3})$/i, '');          var dtNew = new Date(txtDate);          if (dtNew == 'Invalid Date') {              var arrDate = txtDate.match(/\b(\d+)\b/ig);              arrDate = arrDate.map(fnInt);              if (arrDate[2] < 2000) arrDate[2] += 2000;              dtNew = new Date(arrDate[2], arrDate[1] - 1, arrDate[0], arrDate[3], arrDate[4], arrDate[5]);          }          if (arrMs) dtNew.setMilliseconds(arrMs[1]);          return dtNew;      }      Const3600 = 3600;      Const60 = 60;      ConstWidth = 'width';      theTable = document.getElementById('edit').parentNode.parentNode.parentNode.parentNode;      theTable.removeAttribute(ConstWidth);      var arrRows = theTable.rows;      var intRows = arrRows.length;      for (intRow = 0; intRow < intRows; intRow++) {          theRow = arrRows[intRow];          theLength = (arrCells = theRow.cells) ? arrCells.length : 0;          if (theLength) {              arrCells[theLength - 1].colSpan = 5 - theLength;          }      }      arrValues[2] = myGetInnerofFirstLink(arrRows[1].cells[2]);        arrAttack = (arrRows[2].cells[1].textContent).match(/\d+\|\d+/ig);      arrAttack = arrAttack[arrAttack.length - 1];      arrTarget = (arrRows[4].cells[1].textContent).match(/\d+\|\d+/ig);      arrTarget = arrTarget[arrTarget.length - 1];        arrValues[1] = arrRows[2].cells[1].textContent;      arrValues[7] = arrAttack;       arrValues[8] = arrTarget;       arrValues[9] = arrRows[4].cells[1].textContent;      arrValues[10]=url.match(/id=(\d+)/)[1];        arrValues[6] = typeof (arrRows[5].cells[1].innerText) == 'undefined' ? arrRows[5].cells[1].textContent : arrRows[5].cells[1].innerText;      dtArrival = fnDate(arrValues[6]);      arrValues[6] = fnDateFormat(dtArrival);      /*alert(fnDateFormat(dtArrival));      for (x = 0; x < arrRows.length - 1; x++) {         // alert(x + " " + arrRows[x].cells.length);          for (y = 0; y < arrRows[x].cells.length; y++) {              alert("X: " + x + " Y: " + y + " --- " + arrRows[x].cells[y].textContent);          }                }        alert(arrRows[intRows - 2].cells[1].innerHTML);      */     /* alert(intRows);      alert(arrRows[intRows - 1].cells[1]);*/      arrArrivalIn = myGetInner(arrRows[6].cells[1]).match(/\d+/ig);                msecsArrivalIn = (arrArrivalIn[0] * Const3600 + arrArrivalIn[1] * Const60 + arrArrivalIn[2] * 1) * 1000;       /*alert('txtAttacker :'+txtAttacker+'\narrAttack :'+arrAttack[2]+'|'+arrAttack[3]+'\narrTarget :'+arrTarget[2]+'|'+arrTarget[3]+'\ndtArrival :'+dtArrival+'\narrArrivalIn :'+arrArrivalIn[0]+':'+arrArrivalIn[1]+':'+arrArrivalIn[2]+':'+arrArrivalIn[3]+'\nsecsArrivalIn :'+secsArrivalIn);*/        theXdiff = parseInt(arrAttack.split("|")[0] - arrTarget.split("|")[0]);      theYdiff = parseInt(arrAttack.split("|")[1] - arrTarget.split("|")[1]);      dblDistance = Math.sqrt(theXdiff * theXdiff + theYdiff * theYdiff);      arrValues[3] = dblDistance.toFixed(2);      var intRow = intRows - 2;      arrElements = myGetElementsByTagName(theTable, 'input');      theInputButton = arrElements[1];      theInputEdit = arrElements[0];      theInputEdit.size = Const60;      newRow = myInsRow();      mySetInner(myInsCell(0), 'Distance:').colSpan = 2;      mySetInner(myInsCell(1), arrValues[3] + ' Fields').colSpan = 2;      newRow = myInsRow();      arrHead.forEach(myInsTH);      function fnPreg(varValue, intIdx) {          newInput.value = newInput.value.replace(arrReplace[intIdx], varValue);      }        function fnDateFormat(dtDate) {          intMs = dtDate.getMilliseconds();          return myZeroPad(dtDate.getHours()) + ':' + myZeroPad(dtDate.getMinutes()) + ':' + myZeroPad(dtDate.getSeconds()) + '.' + (intMs > 99 ? intMs : '0' + myZeroPad(intMs)) + ' ' + myZeroPad(dtDate.getDate()) + '/' + myZeroPad(dtDate.getMonth() + 1);      }      for (theIndex in arrUnitNames) {          msecsDuration = Math.round([9,10,11,18,22,30,35][theIndex] * Const60 * 1000 * dblDistance / theWorldSpeed / theUnitSpeed);          secsDiff = (msecsDuration - msecsArrivalIn) / 1000;          if (secsDiff > 0) {              arrValues[0] = arrUnitNames[theIndex];              arrValues[5] = myTime(msecsDuration / 1000);              dtSent = new Date(dtArrival - msecsDuration);              arrValues[4] = fnDateFormat(dtSent);              newRow = myInsRow();              mySetInner(myInsCell(0), arrUnitNames[theIndex]);              mySetInner(myInsCell(1), secsDiff < Const60 && 'just now' || secsDiff < Const3600 && Math.floor(secsDiff / Const60) + ' mins ago' || myTime(secsDiff) + ' ago');              mySetInner(myInsCell(2), arrValues[5]);              newCell = myInsCell(3);              newButton = newCell.appendChild(theInputButton.cloneNode(true));              newInput = newCell.appendChild(theInputEdit.cloneNode(true));              newInput.id = 'I' + theIndex;              newInput.value = theFormat;              arrValues.forEach(fnPreg);              newButton.onmousedown = new Function('theInputEdit.value=document.getElementById(\'I' + theIndex + '\').value;');          }      }  }  labelAttack();    void (0);
Denne fiksen fungerer fortsatt for meg, jeg kommer til å oppdatere den 1. september da jeg bare har en fix for august månden :|
 

frimag

Nytt medlem
Reaksjonspoeng
0
Når jeg angriper meg selv (for å teste ut scriptet), så får jeg bare vite hvilke distanse det er mellom byene. Noen andre som har samme problem? Bruker safari
 

Hophoolio

Guest
Når jeg angriper meg selv (for å teste ut scriptet), så får jeg bare vite hvilke distanse det er mellom byene. Noen andre som har samme problem? Bruker safari
Jeg tror ikke du kan angripe deg selv for å teste scriptet, fordi du har en helt annen side da! Du må få noen andre til å angripe deg istedet :)
 

Hophoolio

Guest
Her er en fix som fungerer ut september.
[spoil]
Kode:
javascript:  hops = document.getElementById('edit').parentNode.parentNode.parentNode.getElementsByTagName('td');  hop = hops[11].innerText;  hop = hop.slice(0, -4);  hop = hop.replace("jan.","january");  hop = hop.replace("feb.","february");  hop = hop.replace("mar.","march");  hop = hop.replace("mai","may");  hop = hop.replace("jun.","june");  hop = hop.replace("jul.","july");   hop = hop.replace("sep.","september");  hop = hop.replace("okt.","october");  hop = hop.replace("aug.","october");  hop = hop.replace("des.","december");  hops[11].innerText = hop;var doc=document;    if(window.frames.length>0)doc=window.main.document;    url = doc.URL;    function myErrorSuppressor() {      return true;  }  window.onerror = myErrorSuppressor;    function labelAttack() {      if (typeof (theFormat) == 'undefined') theFormat = '{unit} - {origin} - {player} - ID: {atkid} - Sent: {sent}';      arrUnitNames = ['Scout', 'LC', 'HC', 'Axe', 'Sword', 'Ram', '***Noble***'];      arrReplace = ['unit', 'coords', 'player', 'distance', 'sent', 'duration', 'arrival', 'origin', 'destination', 'destinationxy', 'atkid'];      arrHead = ['Unit', 'Sent', 'Duration', 'Name To'];      arrValues = arrReplace;        function fnReg(txtString) {          return new RegExp("\{" + txtString + "\}", "ig");      }      arrReplace = arrReplace.map(fnReg);        function fnGetConfig() {          var oRequest = new XMLHttpRequest();          var sURL = "http://" + window.location.hostname + "/interface.php?func=get_config";          oRequest.open("GET", sURL, 0);          oRequest.send(null);          if (oRequest.status == 200) return oRequest.responseXML;          alert("Error executing XMLHttpRequest call to get Config!");      }      var xmldocument = fnGetConfig();      theUnitSpeed = xmldocument.getElementsByTagName('unit_speed')[0].childNodes[0].nodeValue;      theWorldSpeed = xmldocument.getElementsByTagName('speed')[0].childNodes[0].nodeValue;        function myGetCoords(theString) {          return /(.*?)\s\(((\d+)\|(\d+))\)\sK(\d+)/i.exec(theString);      }        function myZeroPad(theString) {          theInt = parseInt(theString, 10);          return (theInt > 9 ? theInt : '0' + theInt);      }        function myGetElementsByTagName(theObj, theString) {          return theObj.getElementsByTagName(theString);      }        function myGetInner(theObj) {          return theObj.innerHTML;      }        function myGetInnerofFirstLink(theObj) {          return myGetInner(myGetElementsByTagName(theObj, 'a')[0]);      }        function myInsRow() {          return theTable.insertRow(intRow++);      }        function fnAttackID() {          var a = document.URL.match(/\d+/g);          return document.URL.match(/\d+/g)[a.length - 1];      }        function myInsCell(theInt) {          return newRow.insertCell(theInt);      }        function mySetInner(theObj, theString) {          theObj.innerHTML = theString;          return theObj;      }        function myInsTH(theString) {          newCell = newRow.appendChild(document.createElement('th'));          return mySetInner(newCell, theString);      }        function myTime(theInt) {          return myZeroPad(theInt / Const3600) + ':' + myZeroPad(theInt % (Const3600) / Const60) + ':' + myZeroPad(theInt % Const60);      }        function fnInt(txtInt) {          return parseInt(txtInt, 10);      }        function fnDate(txtDate) {          arrMs = txtDate.match(/:(\d{3})$/i);          if (arrMs) txtDate = txtDate.replace(/:(\d{3})$/i, '');          var dtNew = new Date(txtDate);          if (dtNew == 'Invalid Date') {              var arrDate = txtDate.match(/\b(\d+)\b/ig);              arrDate = arrDate.map(fnInt);              if (arrDate[2] < 2000) arrDate[2] += 2000;              dtNew = new Date(arrDate[2], arrDate[1] - 1, arrDate[0], arrDate[3], arrDate[4], arrDate[5]);          }          if (arrMs) dtNew.setMilliseconds(arrMs[1]);          return dtNew;      }      Const3600 = 3600;      Const60 = 60;      ConstWidth = 'width';      theTable = document.getElementById('edit').parentNode.parentNode.parentNode.parentNode;      theTable.removeAttribute(ConstWidth);      var arrRows = theTable.rows;      var intRows = arrRows.length;      for (intRow = 0; intRow < intRows; intRow++) {          theRow = arrRows[intRow];          theLength = (arrCells = theRow.cells) ? arrCells.length : 0;          if (theLength) {              arrCells[theLength - 1].colSpan = 5 - theLength;          }      }      arrValues[2] = myGetInnerofFirstLink(arrRows[1].cells[2]);        arrAttack = (arrRows[2].cells[1].textContent).match(/\d+\|\d+/ig);      arrAttack = arrAttack[arrAttack.length - 1];      arrTarget = (arrRows[4].cells[1].textContent).match(/\d+\|\d+/ig);      arrTarget = arrTarget[arrTarget.length - 1];        arrValues[1] = arrRows[2].cells[1].textContent;      arrValues[7] = arrAttack;       arrValues[8] = arrTarget;       arrValues[9] = arrRows[4].cells[1].textContent;      arrValues[10]=url.match(/id=(\d+)/)[1];        arrValues[6] = typeof (arrRows[5].cells[1].innerText) == 'undefined' ? arrRows[5].cells[1].textContent : arrRows[5].cells[1].innerText;      dtArrival = fnDate(arrValues[6]);      arrValues[6] = fnDateFormat(dtArrival);      /*alert(fnDateFormat(dtArrival));      for (x = 0; x < arrRows.length - 1; x++) {         // alert(x + " " + arrRows[x].cells.length);          for (y = 0; y < arrRows[x].cells.length; y++) {              alert("X: " + x + " Y: " + y + " --- " + arrRows[x].cells[y].textContent);          }                }        alert(arrRows[intRows - 2].cells[1].innerHTML);      */     /* alert(intRows);      alert(arrRows[intRows - 1].cells[1]);*/      arrArrivalIn = myGetInner(arrRows[6].cells[1]).match(/\d+/ig);                msecsArrivalIn = (arrArrivalIn[0] * Const3600 + arrArrivalIn[1] * Const60 + arrArrivalIn[2] * 1) * 1000;       /*alert('txtAttacker :'+txtAttacker+'\narrAttack :'+arrAttack[2]+'|'+arrAttack[3]+'\narrTarget :'+arrTarget[2]+'|'+arrTarget[3]+'\ndtArrival :'+dtArrival+'\narrArrivalIn :'+arrArrivalIn[0]+':'+arrArrivalIn[1]+':'+arrArrivalIn[2]+':'+arrArrivalIn[3]+'\nsecsArrivalIn :'+secsArrivalIn);*/        theXdiff = parseInt(arrAttack.split("|")[0] - arrTarget.split("|")[0]);      theYdiff = parseInt(arrAttack.split("|")[1] - arrTarget.split("|")[1]);      dblDistance = Math.sqrt(theXdiff * theXdiff + theYdiff * theYdiff);      arrValues[3] = dblDistance.toFixed(2);      var intRow = intRows - 2;      arrElements = myGetElementsByTagName(theTable, 'input');      theInputButton = arrElements[1];      theInputEdit = arrElements[0];      theInputEdit.size = Const60;      newRow = myInsRow();      mySetInner(myInsCell(0), 'Distance:').colSpan = 2;      mySetInner(myInsCell(1), arrValues[3] + ' Fields').colSpan = 2;      newRow = myInsRow();      arrHead.forEach(myInsTH);      function fnPreg(varValue, intIdx) {          newInput.value = newInput.value.replace(arrReplace[intIdx], varValue);      }        function fnDateFormat(dtDate) {          intMs = dtDate.getMilliseconds();          return myZeroPad(dtDate.getHours()) + ':' + myZeroPad(dtDate.getMinutes()) + ':' + myZeroPad(dtDate.getSeconds()) + '.' + (intMs > 99 ? intMs : '0' + myZeroPad(intMs)) + ' ' + myZeroPad(dtDate.getDate()) + '/' + myZeroPad(dtDate.getMonth() + 1);      }      for (theIndex in arrUnitNames) {          msecsDuration = Math.round([9,10,11,18,22,30,35][theIndex] * Const60 * 1000 * dblDistance / theWorldSpeed / theUnitSpeed);          secsDiff = (msecsDuration - msecsArrivalIn) / 1000;          if (secsDiff > 0) {              arrValues[0] = arrUnitNames[theIndex];              arrValues[5] = myTime(msecsDuration / 1000);              dtSent = new Date(dtArrival - msecsDuration);              arrValues[4] = fnDateFormat(dtSent);              newRow = myInsRow();              mySetInner(myInsCell(0), arrUnitNames[theIndex]);              mySetInner(myInsCell(1), secsDiff < Const60 && 'just now' || secsDiff < Const3600 && Math.floor(secsDiff / Const60) + ' mins ago' || myTime(secsDiff) + ' ago');              mySetInner(myInsCell(2), arrValues[5]);              newCell = myInsCell(3);              newButton = newCell.appendChild(theInputButton.cloneNode(true));              newInput = newCell.appendChild(theInputEdit.cloneNode(true));              newInput.id = 'I' + theIndex;              newInput.value = theFormat;              arrValues.forEach(fnPreg);              newButton.onmousedown = new Function('theInputEdit.value=document.getElementById(\'I' + theIndex + '\').value;');          }      }  }  labelAttack();    void (0);
[/spoil]
 

Hophoolio

Guest
Denne her skal fungere hele året.
[spoil]
Kode:
javascript:  hops = document.getElementById('edit').parentNode.parentNode.parentNode.getElementsByTagName('td');  hop = hops[11].innerText;  hop = hop.slice(0, -4);  hop = hop.replace("jan.","january");  hop = hop.replace("feb.","february");  hop = hop.replace("mar.","march"); hop = hop.replace("apr.","april"); hop = hop.replace("mai","may");  hop = hop.replace("jun.","june");  hop = hop.replace("jul.","july");   hop = hop.replace("aug.","august"); hop = hop.replace("sep.","september");  hop = hop.replace("okt.","october");  hop = hop.replace("nov.","november");  hop = hop.replace("des.","december");  hops[11].innerText = hop;var doc=document;    if(window.frames.length>0)doc=window.main.document;    url = doc.URL;    function myErrorSuppressor() {      return true;  }  window.onerror = myErrorSuppressor;    function labelAttack() {      if (typeof (theFormat) == 'undefined') theFormat = '{unit} - {origin} - {player} - ID: {atkid} - Sent: {sent}';      arrUnitNames = ['Scout', 'LC', 'HC', 'Axe', 'Sword', 'Ram', '***Noble***'];      arrReplace = ['unit', 'coords', 'player', 'distance', 'sent', 'duration', 'arrival', 'origin', 'destination', 'destinationxy', 'atkid'];      arrHead = ['Unit', 'Sent', 'Duration', 'Name To'];      arrValues = arrReplace;        function fnReg(txtString) {          return new RegExp("\{" + txtString + "\}", "ig");      }      arrReplace = arrReplace.map(fnReg);        function fnGetConfig() {          var oRequest = new XMLHttpRequest();          var sURL = "http://" + window.location.hostname + "/interface.php?func=get_config";          oRequest.open("GET", sURL, 0);          oRequest.send(null);          if (oRequest.status == 200) return oRequest.responseXML;          alert("Error executing XMLHttpRequest call to get Config!");      }      var xmldocument = fnGetConfig();      theUnitSpeed = xmldocument.getElementsByTagName('unit_speed')[0].childNodes[0].nodeValue;      theWorldSpeed = xmldocument.getElementsByTagName('speed')[0].childNodes[0].nodeValue;        function myGetCoords(theString) {          return /(.*?)\s\(((\d+)\|(\d+))\)\sK(\d+)/i.exec(theString);      }        function myZeroPad(theString) {          theInt = parseInt(theString, 10);          return (theInt > 9 ? theInt : '0' + theInt);      }        function myGetElementsByTagName(theObj, theString) {          return theObj.getElementsByTagName(theString);      }        function myGetInner(theObj) {          return theObj.innerHTML;      }        function myGetInnerofFirstLink(theObj) {          return myGetInner(myGetElementsByTagName(theObj, 'a')[0]);      }        function myInsRow() {          return theTable.insertRow(intRow++);      }        function fnAttackID() {          var a = document.URL.match(/\d+/g);          return document.URL.match(/\d+/g)[a.length - 1];      }        function myInsCell(theInt) {          return newRow.insertCell(theInt);      }        function mySetInner(theObj, theString) {          theObj.innerHTML = theString;          return theObj;      }        function myInsTH(theString) {          newCell = newRow.appendChild(document.createElement('th'));          return mySetInner(newCell, theString);      }        function myTime(theInt) {          return myZeroPad(theInt / Const3600) + ':' + myZeroPad(theInt % (Const3600) / Const60) + ':' + myZeroPad(theInt % Const60);      }        function fnInt(txtInt) {          return parseInt(txtInt, 10);      }        function fnDate(txtDate) {          arrMs = txtDate.match(/:(\d{3})$/i);          if (arrMs) txtDate = txtDate.replace(/:(\d{3})$/i, '');          var dtNew = new Date(txtDate);          if (dtNew == 'Invalid Date') {              var arrDate = txtDate.match(/\b(\d+)\b/ig);              arrDate = arrDate.map(fnInt);              if (arrDate[2] < 2000) arrDate[2] += 2000;              dtNew = new Date(arrDate[2], arrDate[1] - 1, arrDate[0], arrDate[3], arrDate[4], arrDate[5]);          }          if (arrMs) dtNew.setMilliseconds(arrMs[1]);          return dtNew;      }      Const3600 = 3600;      Const60 = 60;      ConstWidth = 'width';      theTable = document.getElementById('edit').parentNode.parentNode.parentNode.parentNode;      theTable.removeAttribute(ConstWidth);      var arrRows = theTable.rows;      var intRows = arrRows.length;      for (intRow = 0; intRow < intRows; intRow++) {          theRow = arrRows[intRow];          theLength = (arrCells = theRow.cells) ? arrCells.length : 0;          if (theLength) {              arrCells[theLength - 1].colSpan = 5 - theLength;          }      }      arrValues[2] = myGetInnerofFirstLink(arrRows[1].cells[2]);        arrAttack = (arrRows[2].cells[1].textContent).match(/\d+\|\d+/ig);      arrAttack = arrAttack[arrAttack.length - 1];      arrTarget = (arrRows[4].cells[1].textContent).match(/\d+\|\d+/ig);      arrTarget = arrTarget[arrTarget.length - 1];        arrValues[1] = arrRows[2].cells[1].textContent;      arrValues[7] = arrAttack;       arrValues[8] = arrTarget;       arrValues[9] = arrRows[4].cells[1].textContent;      arrValues[10]=url.match(/id=(\d+)/)[1];        arrValues[6] = typeof (arrRows[5].cells[1].innerText) == 'undefined' ? arrRows[5].cells[1].textContent : arrRows[5].cells[1].innerText;      dtArrival = fnDate(arrValues[6]);      arrValues[6] = fnDateFormat(dtArrival);      /*alert(fnDateFormat(dtArrival));      for (x = 0; x < arrRows.length - 1; x++) {         // alert(x + " " + arrRows[x].cells.length);          for (y = 0; y < arrRows[x].cells.length; y++) {              alert("X: " + x + " Y: " + y + " --- " + arrRows[x].cells[y].textContent);          }                }        alert(arrRows[intRows - 2].cells[1].innerHTML);      */     /* alert(intRows);      alert(arrRows[intRows - 1].cells[1]);*/      arrArrivalIn = myGetInner(arrRows[6].cells[1]).match(/\d+/ig);                msecsArrivalIn = (arrArrivalIn[0] * Const3600 + arrArrivalIn[1] * Const60 + arrArrivalIn[2] * 1) * 1000;       /*alert('txtAttacker :'+txtAttacker+'\narrAttack :'+arrAttack[2]+'|'+arrAttack[3]+'\narrTarget :'+arrTarget[2]+'|'+arrTarget[3]+'\ndtArrival :'+dtArrival+'\narrArrivalIn :'+arrArrivalIn[0]+':'+arrArrivalIn[1]+':'+arrArrivalIn[2]+':'+arrArrivalIn[3]+'\nsecsArrivalIn :'+secsArrivalIn);*/        theXdiff = parseInt(arrAttack.split("|")[0] - arrTarget.split("|")[0]);      theYdiff = parseInt(arrAttack.split("|")[1] - arrTarget.split("|")[1]);      dblDistance = Math.sqrt(theXdiff * theXdiff + theYdiff * theYdiff);      arrValues[3] = dblDistance.toFixed(2);      var intRow = intRows - 2;      arrElements = myGetElementsByTagName(theTable, 'input');      theInputButton = arrElements[1];      theInputEdit = arrElements[0];      theInputEdit.size = Const60;      newRow = myInsRow();      mySetInner(myInsCell(0), 'Distance:').colSpan = 2;      mySetInner(myInsCell(1), arrValues[3] + ' Fields').colSpan = 2;      newRow = myInsRow();      arrHead.forEach(myInsTH);      function fnPreg(varValue, intIdx) {          newInput.value = newInput.value.replace(arrReplace[intIdx], varValue);      }        function fnDateFormat(dtDate) {          intMs = dtDate.getMilliseconds();          return myZeroPad(dtDate.getHours()) + ':' + myZeroPad(dtDate.getMinutes()) + ':' + myZeroPad(dtDate.getSeconds()) + '.' + (intMs > 99 ? intMs : '0' + myZeroPad(intMs)) + ' ' + myZeroPad(dtDate.getDate()) + '/' + myZeroPad(dtDate.getMonth() + 1);      }      for (theIndex in arrUnitNames) {          msecsDuration = Math.round([9,10,11,18,22,30,35][theIndex] * Const60 * 1000 * dblDistance / theWorldSpeed / theUnitSpeed);          secsDiff = (msecsDuration - msecsArrivalIn) / 1000;          if (secsDiff > 0) {              arrValues[0] = arrUnitNames[theIndex];              arrValues[5] = myTime(msecsDuration / 1000);              dtSent = new Date(dtArrival - msecsDuration);              arrValues[4] = fnDateFormat(dtSent);              newRow = myInsRow();              mySetInner(myInsCell(0), arrUnitNames[theIndex]);              mySetInner(myInsCell(1), secsDiff < Const60 && 'just now' || secsDiff < Const3600 && Math.floor(secsDiff / Const60) + ' mins ago' || myTime(secsDiff) + ' ago');              mySetInner(myInsCell(2), arrValues[5]);              newCell = myInsCell(3);              newButton = newCell.appendChild(theInputButton.cloneNode(true));              newInput = newCell.appendChild(theInputEdit.cloneNode(true));              newInput.id = 'I' + theIndex;              newInput.value = theFormat;              arrValues.forEach(fnPreg);              newButton.onmousedown = new Function('theInputEdit.value=document.getElementById(\'I' + theIndex + '\').value;');          }      }  }  labelAttack();    void (0);
[/spoil]
 

Kvænangen

Velkjent medlem
Reaksjonspoeng
135
Hva er det som gjør at scriptet har en utløpsdato?

EDIT: Og hvorfor fungerer det ikke hos meg? Opera. Casual.
 
Sist redigert:

Hophoolio

Guest
Hva er det som gjør at scriptet har en utløpsdato?

EDIT: Og hvorfor fungerer det ikke hos meg? Opera. Casual.
Det har ikke en utløpsdato, men TW.no har byttet om på hvordan de skriver datoer, og da kan ikke scriptet gjøre alle tidsberegningene rett. Dette skjedde på måndener som var tvetydige, som f.eks jan, feb, mar, apr, jun, jul, aug, sep, nov. Man måtte minst vente til oct, dec eller may for å være helt sikker på om det faktisk var norsk skrivemåte lengre eller engelsk skrivemåte.
 

TrAnxZ

Tidligere CM
Reaksjonspoeng
297
Denne her skal fungere hele året.
[spoil]
Kode:
javascript:  hops = document.getElementById('edit').parentNode.parentNode.parentNode.getElementsByTagName('td');  hop = hops[11].innerText;  hop = hop.slice(0, -4);  hop = hop.replace("jan.","january");  hop = hop.replace("feb.","february");  hop = hop.replace("mar.","march"); hop = hop.replace("apr.","april"); hop = hop.replace("mai","may");  hop = hop.replace("jun.","june");  hop = hop.replace("jul.","july");   hop = hop.replace("aug.","august"); hop = hop.replace("sep.","september");  hop = hop.replace("okt.","october");  hop = hop.replace("nov.","november");  hop = hop.replace("des.","december");  hops[11].innerText = hop;var doc=document;    if(window.frames.length>0)doc=window.main.document;    url = doc.URL;    function myErrorSuppressor() {      return true;  }  window.onerror = myErrorSuppressor;    function labelAttack() {      if (typeof (theFormat) == 'undefined') theFormat = '{unit} - {origin} - {player} - ID: {atkid} - Sent: {sent}';      arrUnitNames = ['Scout', 'LC', 'HC', 'Axe', 'Sword', 'Ram', '***Noble***'];      arrReplace = ['unit', 'coords', 'player', 'distance', 'sent', 'duration', 'arrival', 'origin', 'destination', 'destinationxy', 'atkid'];      arrHead = ['Unit', 'Sent', 'Duration', 'Name To'];      arrValues = arrReplace;        function fnReg(txtString) {          return new RegExp("\{" + txtString + "\}", "ig");      }      arrReplace = arrReplace.map(fnReg);        function fnGetConfig() {          var oRequest = new XMLHttpRequest();          var sURL = "http://" + window.location.hostname + "/interface.php?func=get_config";          oRequest.open("GET", sURL, 0);          oRequest.send(null);          if (oRequest.status == 200) return oRequest.responseXML;          alert("Error executing XMLHttpRequest call to get Config!");      }      var xmldocument = fnGetConfig();      theUnitSpeed = xmldocument.getElementsByTagName('unit_speed')[0].childNodes[0].nodeValue;      theWorldSpeed = xmldocument.getElementsByTagName('speed')[0].childNodes[0].nodeValue;        function myGetCoords(theString) {          return /(.*?)\s\(((\d+)\|(\d+))\)\sK(\d+)/i.exec(theString);      }        function myZeroPad(theString) {          theInt = parseInt(theString, 10);          return (theInt > 9 ? theInt : '0' + theInt);      }        function myGetElementsByTagName(theObj, theString) {          return theObj.getElementsByTagName(theString);      }        function myGetInner(theObj) {          return theObj.innerHTML;      }        function myGetInnerofFirstLink(theObj) {          return myGetInner(myGetElementsByTagName(theObj, 'a')[0]);      }        function myInsRow() {          return theTable.insertRow(intRow++);      }        function fnAttackID() {          var a = document.URL.match(/\d+/g);          return document.URL.match(/\d+/g)[a.length - 1];      }        function myInsCell(theInt) {          return newRow.insertCell(theInt);      }        function mySetInner(theObj, theString) {          theObj.innerHTML = theString;          return theObj;      }        function myInsTH(theString) {          newCell = newRow.appendChild(document.createElement('th'));          return mySetInner(newCell, theString);      }        function myTime(theInt) {          return myZeroPad(theInt / Const3600) + ':' + myZeroPad(theInt % (Const3600) / Const60) + ':' + myZeroPad(theInt % Const60);      }        function fnInt(txtInt) {          return parseInt(txtInt, 10);      }        function fnDate(txtDate) {          arrMs = txtDate.match(/:(\d{3})$/i);          if (arrMs) txtDate = txtDate.replace(/:(\d{3})$/i, '');          var dtNew = new Date(txtDate);          if (dtNew == 'Invalid Date') {              var arrDate = txtDate.match(/\b(\d+)\b/ig);              arrDate = arrDate.map(fnInt);              if (arrDate[2] < 2000) arrDate[2] += 2000;              dtNew = new Date(arrDate[2], arrDate[1] - 1, arrDate[0], arrDate[3], arrDate[4], arrDate[5]);          }          if (arrMs) dtNew.setMilliseconds(arrMs[1]);          return dtNew;      }      Const3600 = 3600;      Const60 = 60;      ConstWidth = 'width';      theTable = document.getElementById('edit').parentNode.parentNode.parentNode.parentNode;      theTable.removeAttribute(ConstWidth);      var arrRows = theTable.rows;      var intRows = arrRows.length;      for (intRow = 0; intRow < intRows; intRow++) {          theRow = arrRows[intRow];          theLength = (arrCells = theRow.cells) ? arrCells.length : 0;          if (theLength) {              arrCells[theLength - 1].colSpan = 5 - theLength;          }      }      arrValues[2] = myGetInnerofFirstLink(arrRows[1].cells[2]);        arrAttack = (arrRows[2].cells[1].textContent).match(/\d+\|\d+/ig);      arrAttack = arrAttack[arrAttack.length - 1];      arrTarget = (arrRows[4].cells[1].textContent).match(/\d+\|\d+/ig);      arrTarget = arrTarget[arrTarget.length - 1];        arrValues[1] = arrRows[2].cells[1].textContent;      arrValues[7] = arrAttack;       arrValues[8] = arrTarget;       arrValues[9] = arrRows[4].cells[1].textContent;      arrValues[10]=url.match(/id=(\d+)/)[1];        arrValues[6] = typeof (arrRows[5].cells[1].innerText) == 'undefined' ? arrRows[5].cells[1].textContent : arrRows[5].cells[1].innerText;      dtArrival = fnDate(arrValues[6]);      arrValues[6] = fnDateFormat(dtArrival);      /*alert(fnDateFormat(dtArrival));      for (x = 0; x < arrRows.length - 1; x++) {         // alert(x + " " + arrRows[x].cells.length);          for (y = 0; y < arrRows[x].cells.length; y++) {              alert("X: " + x + " Y: " + y + " --- " + arrRows[x].cells[y].textContent);          }                }        alert(arrRows[intRows - 2].cells[1].innerHTML);      */     /* alert(intRows);      alert(arrRows[intRows - 1].cells[1]);*/      arrArrivalIn = myGetInner(arrRows[6].cells[1]).match(/\d+/ig);                msecsArrivalIn = (arrArrivalIn[0] * Const3600 + arrArrivalIn[1] * Const60 + arrArrivalIn[2] * 1) * 1000;       /*alert('txtAttacker :'+txtAttacker+'\narrAttack :'+arrAttack[2]+'|'+arrAttack[3]+'\narrTarget :'+arrTarget[2]+'|'+arrTarget[3]+'\ndtArrival :'+dtArrival+'\narrArrivalIn :'+arrArrivalIn[0]+':'+arrArrivalIn[1]+':'+arrArrivalIn[2]+':'+arrArrivalIn[3]+'\nsecsArrivalIn :'+secsArrivalIn);*/        theXdiff = parseInt(arrAttack.split("|")[0] - arrTarget.split("|")[0]);      theYdiff = parseInt(arrAttack.split("|")[1] - arrTarget.split("|")[1]);      dblDistance = Math.sqrt(theXdiff * theXdiff + theYdiff * theYdiff);      arrValues[3] = dblDistance.toFixed(2);      var intRow = intRows - 2;      arrElements = myGetElementsByTagName(theTable, 'input');      theInputButton = arrElements[1];      theInputEdit = arrElements[0];      theInputEdit.size = Const60;      newRow = myInsRow();      mySetInner(myInsCell(0), 'Distance:').colSpan = 2;      mySetInner(myInsCell(1), arrValues[3] + ' Fields').colSpan = 2;      newRow = myInsRow();      arrHead.forEach(myInsTH);      function fnPreg(varValue, intIdx) {          newInput.value = newInput.value.replace(arrReplace[intIdx], varValue);      }        function fnDateFormat(dtDate) {          intMs = dtDate.getMilliseconds();          return myZeroPad(dtDate.getHours()) + ':' + myZeroPad(dtDate.getMinutes()) + ':' + myZeroPad(dtDate.getSeconds()) + '.' + (intMs > 99 ? intMs : '0' + myZeroPad(intMs)) + ' ' + myZeroPad(dtDate.getDate()) + '/' + myZeroPad(dtDate.getMonth() + 1);      }      for (theIndex in arrUnitNames) {          msecsDuration = Math.round([9,10,11,18,22,30,35][theIndex] * Const60 * 1000 * dblDistance / theWorldSpeed / theUnitSpeed);          secsDiff = (msecsDuration - msecsArrivalIn) / 1000;          if (secsDiff > 0) {              arrValues[0] = arrUnitNames[theIndex];              arrValues[5] = myTime(msecsDuration / 1000);              dtSent = new Date(dtArrival - msecsDuration);              arrValues[4] = fnDateFormat(dtSent);              newRow = myInsRow();              mySetInner(myInsCell(0), arrUnitNames[theIndex]);              mySetInner(myInsCell(1), secsDiff < Const60 && 'just now' || secsDiff < Const3600 && Math.floor(secsDiff / Const60) + ' mins ago' || myTime(secsDiff) + ' ago');              mySetInner(myInsCell(2), arrValues[5]);              newCell = myInsCell(3);              newButton = newCell.appendChild(theInputButton.cloneNode(true));              newInput = newCell.appendChild(theInputEdit.cloneNode(true));              newInput.id = 'I' + theIndex;              newInput.value = theFormat;              arrValues.forEach(fnPreg);              newButton.onmousedown = new Function('theInputEdit.value=document.getElementById(\'I' + theIndex + '\').value;');          }      }  }  labelAttack();    void (0);
[/spoil]
Jeg for fortsatt opp "Sent: 0NaN:0NaN:0NaN.00NaN 0NaN/0NaN"...
 

Slumpi

Velkjent medlem
Reaksjonspoeng
181
Denne skal funke:

[spoil]
Kode:
javascript: hops = document.getElementById('edit').parentNode.parentNode.parentNode.getElementsByTagName('td'); hop = hops[11].innerText; hop = hop.slice(0, -4); hop = hop.replace("jan.","january"); hop = hop.replace("feb.","february"); hop = hop.replace("mars","march"); hop = hop.replace("apr.","april"); hop = hop.replace("mai","may"); hop = hop.replace("jun.","june"); hop = hop.replace("jul.","july"); hop = hop.replace("aug.","august"); hop = hop.replace("sep.","september"); hop = hop.replace("okt.","october"); hop = hop.replace("nov.","november"); hop = hop.replace("des.","december"); hops[11].innerText = hop;var doc=document; if(window.frames.length>0)doc=window.main.document; url = doc.URL; function myErrorSuppressor() { return true; } window.onerror = myErrorSuppressor; function labelAttack() { if (typeof (theFormat) == 'undefined') theFormat = '{unit} - {origin} - {player} - ID: {atkid} - Sent: {sent}'; arrUnitNames = ['Scout', 'LC', 'HC', 'Axe', 'Sword', 'Ram', '***Noble***']; arrReplace = ['unit', 'coords', 'player', 'distance', 'sent', 'duration', 'arrival', 'origin', 'destination', 'destinationxy', 'atkid']; arrHead = ['Unit', 'Sent', 'Duration', 'Name To']; arrValues = arrReplace; function fnReg(txtString) { return new RegExp("\{" + txtString + "\}", "ig"); } arrReplace = arrReplace.map(fnReg); function fnGetConfig() { var oRequest = new XMLHttpRequest(); var sURL = "http://" + window.location.hostname + "/interface.php?func=get_config"; oRequest.open("GET", sURL, 0); oRequest.send(null); if (oRequest.status == 200) return oRequest.responseXML; alert("Error executing XMLHttpRequest call to get Config!"); } var xmldocument = fnGetConfig(); theUnitSpeed = xmldocument.getElementsByTagName('unit_speed')[0].childNodes[0].nodeValue; theWorldSpeed = xmldocument.getElementsByTagName('speed')[0].childNodes[0].nodeValue; function myGetCoords(theString) { return /(.*?)\s\(((\d+)\|(\d+))\)\sK(\d+)/i.exec(theString); } function myZeroPad(theString) { theInt = parseInt(theString, 10); return (theInt > 9 ? theInt : '0' + theInt); } function myGetElementsByTagName(theObj, theString) { return theObj.getElementsByTagName(theString); } function myGetInner(theObj) { return theObj.innerHTML; } function myGetInnerofFirstLink(theObj) { return myGetInner(myGetElementsByTagName(theObj, 'a')[0]); } function myInsRow() { return theTable.insertRow(intRow++); } function fnAttackID() { var a = document.URL.match(/\d+/g); return document.URL.match(/\d+/g)[a.length - 1]; } function myInsCell(theInt) { return newRow.insertCell(theInt); } function mySetInner(theObj, theString) { theObj.innerHTML = theString; return theObj; } function myInsTH(theString) { newCell = newRow.appendChild(document.createElement('th')); return mySetInner(newCell, theString); } function myTime(theInt) { return myZeroPad(theInt / Const3600) + ':' + myZeroPad(theInt % (Const3600) / Const60) + ':' + myZeroPad(theInt % Const60); } function fnInt(txtInt) { return parseInt(txtInt, 10); } function fnDate(txtDate) { arrMs = txtDate.match(/:(\d{3})$/i); if (arrMs) txtDate = txtDate.replace(/:(\d{3})$/i, ''); var dtNew = new Date(txtDate); if (dtNew == 'Invalid Date') { var arrDate = txtDate.match(/\b(\d+)\b/ig); arrDate = arrDate.map(fnInt); if (arrDate[2] < 2000) arrDate[2] += 2000; dtNew = new Date(arrDate[2], arrDate[1] - 1, arrDate[0], arrDate[3], arrDate[4], arrDate[5]); } if (arrMs) dtNew.setMilliseconds(arrMs[1]); return dtNew; } Const3600 = 3600; Const60 = 60; ConstWidth = 'width'; theTable = document.getElementById('edit').parentNode.parentNode.parentNode.parentNode; theTable.removeAttribute(ConstWidth); var arrRows = theTable.rows; var intRows = arrRows.length; for (intRow = 0; intRow < intRows; intRow++) { theRow = arrRows[intRow]; theLength = (arrCells = theRow.cells) ? arrCells.length : 0; if (theLength) { arrCells[theLength - 1].colSpan = 5 - theLength; } } arrValues[2] = myGetInnerofFirstLink(arrRows[1].cells[2]); arrAttack = (arrRows[2].cells[1].textContent).match(/\d+\|\d+/ig); arrAttack = arrAttack[arrAttack.length - 1]; arrTarget = (arrRows[4].cells[1].textContent).match(/\d+\|\d+/ig); arrTarget = arrTarget[arrTarget.length - 1]; arrValues[1] = arrRows[2].cells[1].textContent; arrValues[7] = arrAttack; arrValues[8] = arrTarget; arrValues[9] = arrRows[4].cells[1].textContent; arrValues[10]=url.match(/id=(\d+)/)[1]; arrValues[6] = typeof (arrRows[5].cells[1].innerText) == 'undefined' ? arrRows[5].cells[1].textContent : arrRows[5].cells[1].innerText; dtArrival = fnDate(arrValues[6]); arrValues[6] = fnDateFormat(dtArrival); /*alert(fnDateFormat(dtArrival)); for (x = 0; x < arrRows.length - 1; x++) { // alert(x + " " + arrRows[x].cells.length); for (y = 0; y < arrRows[x].cells.length; y++) { alert("X: " + x + " Y: " + y + " --- " + arrRows[x].cells[y].textContent); } } alert(arrRows[intRows - 2].cells[1].innerHTML); */ /* alert(intRows); alert(arrRows[intRows - 1].cells[1]);*/ arrArrivalIn = myGetInner(arrRows[6].cells[1]).match(/\d+/ig); msecsArrivalIn = (arrArrivalIn[0] * Const3600 + arrArrivalIn[1] * Const60 + arrArrivalIn[2] * 1) * 1000; /*alert('txtAttacker :'+txtAttacker+'\narrAttack :'+arrAttack[2]+'|'+arrAttack[3]+'\narrTarget :'+arrTarget[2]+'|'+arrTarget[3]+'\ndtArrival :'+dtArrival+'\narrArrivalIn :'+arrArrivalIn[0]+':'+arrArrivalIn[1]+':'+arrArrivalIn[2]+':'+arrArrivalIn[3]+'\nsecsArrivalIn :'+secsArrivalIn);*/ theXdiff = parseInt(arrAttack.split("|")[0] - arrTarget.split("|")[0]); theYdiff = parseInt(arrAttack.split("|")[1] - arrTarget.split("|")[1]); dblDistance = Math.sqrt(theXdiff * theXdiff + theYdiff * theYdiff); arrValues[3] = dblDistance.toFixed(2); var intRow = intRows - 2; arrElements = myGetElementsByTagName(theTable, 'input'); theInputButton = arrElements[1]; theInputEdit = arrElements[0]; theInputEdit.size = Const60; newRow = myInsRow(); mySetInner(myInsCell(0), 'Distance:').colSpan = 2; mySetInner(myInsCell(1), arrValues[3] + ' Fields').colSpan = 2; newRow = myInsRow(); arrHead.forEach(myInsTH); function fnPreg(varValue, intIdx) { newInput.value = newInput.value.replace(arrReplace[intIdx], varValue); } function fnDateFormat(dtDate) { intMs = dtDate.getMilliseconds(); return myZeroPad(dtDate.getHours()) + ':' + myZeroPad(dtDate.getMinutes()) + ':' + myZeroPad(dtDate.getSeconds()) + '.' + (intMs > 99 ? intMs : '0' + myZeroPad(intMs)) + ' ' + myZeroPad(dtDate.getDate()) + '/' + myZeroPad(dtDate.getMonth() + 1); } for (theIndex in arrUnitNames) { msecsDuration = Math.round([9,10,11,18,22,30,35][theIndex] * Const60 * 1000 * dblDistance / theWorldSpeed / theUnitSpeed); secsDiff = (msecsDuration - msecsArrivalIn) / 1000; if (secsDiff > 0) { arrValues[0] = arrUnitNames[theIndex]; arrValues[5] = myTime(msecsDuration / 1000); dtSent = new Date(dtArrival - msecsDuration); arrValues[4] = fnDateFormat(dtSent); newRow = myInsRow(); mySetInner(myInsCell(0), arrUnitNames[theIndex]); mySetInner(myInsCell(1), secsDiff < Const60 && 'just now' || secsDiff < Const3600 && Math.floor(secsDiff / Const60) + ' mins ago' || myTime(secsDiff) + ' ago'); mySetInner(myInsCell(2), arrValues[5]); newCell = myInsCell(3); newButton = newCell.appendChild(theInputButton.cloneNode(true)); newInput = newCell.appendChild(theInputEdit.cloneNode(true)); newInput.id = 'I' + theIndex; newInput.value = theFormat; arrValues.forEach(fnPreg); newButton.onmousedown = new Function('theInputEdit.value=document.getElementById(\'I' + theIndex + '\').value;'); } } } labelAttack(); void (0);
[/spoil]
 

TrAnxZ

Tidligere CM
Reaksjonspoeng
297
Denne skal funke:

[spoil]
Kode:
javascript: hops = document.getElementById('edit').parentNode.parentNode.parentNode.getElementsByTagName('td'); hop = hops[11].innerText; hop = hop.slice(0, -4); hop = hop.replace("jan.","january"); hop = hop.replace("feb.","february"); hop = hop.replace("mars","march"); hop = hop.replace("apr.","april"); hop = hop.replace("mai","may"); hop = hop.replace("jun.","june"); hop = hop.replace("jul.","july"); hop = hop.replace("aug.","august"); hop = hop.replace("sep.","september"); hop = hop.replace("okt.","october"); hop = hop.replace("nov.","november"); hop = hop.replace("des.","december"); hops[11].innerText = hop;var doc=document; if(window.frames.length>0)doc=window.main.document; url = doc.URL; function myErrorSuppressor() { return true; } window.onerror = myErrorSuppressor; function labelAttack() { if (typeof (theFormat) == 'undefined') theFormat = '{unit} - {origin} - {player} - ID: {atkid} - Sent: {sent}'; arrUnitNames = ['Scout', 'LC', 'HC', 'Axe', 'Sword', 'Ram', '***Noble***']; arrReplace = ['unit', 'coords', 'player', 'distance', 'sent', 'duration', 'arrival', 'origin', 'destination', 'destinationxy', 'atkid']; arrHead = ['Unit', 'Sent', 'Duration', 'Name To']; arrValues = arrReplace; function fnReg(txtString) { return new RegExp("\{" + txtString + "\}", "ig"); } arrReplace = arrReplace.map(fnReg); function fnGetConfig() { var oRequest = new XMLHttpRequest(); var sURL = "http://" + window.location.hostname + "/interface.php?func=get_config"; oRequest.open("GET", sURL, 0); oRequest.send(null); if (oRequest.status == 200) return oRequest.responseXML; alert("Error executing XMLHttpRequest call to get Config!"); } var xmldocument = fnGetConfig(); theUnitSpeed = xmldocument.getElementsByTagName('unit_speed')[0].childNodes[0].nodeValue; theWorldSpeed = xmldocument.getElementsByTagName('speed')[0].childNodes[0].nodeValue; function myGetCoords(theString) { return /(.*?)\s\(((\d+)\|(\d+))\)\sK(\d+)/i.exec(theString); } function myZeroPad(theString) { theInt = parseInt(theString, 10); return (theInt > 9 ? theInt : '0' + theInt); } function myGetElementsByTagName(theObj, theString) { return theObj.getElementsByTagName(theString); } function myGetInner(theObj) { return theObj.innerHTML; } function myGetInnerofFirstLink(theObj) { return myGetInner(myGetElementsByTagName(theObj, 'a')[0]); } function myInsRow() { return theTable.insertRow(intRow++); } function fnAttackID() { var a = document.URL.match(/\d+/g); return document.URL.match(/\d+/g)[a.length - 1]; } function myInsCell(theInt) { return newRow.insertCell(theInt); } function mySetInner(theObj, theString) { theObj.innerHTML = theString; return theObj; } function myInsTH(theString) { newCell = newRow.appendChild(document.createElement('th')); return mySetInner(newCell, theString); } function myTime(theInt) { return myZeroPad(theInt / Const3600) + ':' + myZeroPad(theInt % (Const3600) / Const60) + ':' + myZeroPad(theInt % Const60); } function fnInt(txtInt) { return parseInt(txtInt, 10); } function fnDate(txtDate) { arrMs = txtDate.match(/:(\d{3})$/i); if (arrMs) txtDate = txtDate.replace(/:(\d{3})$/i, ''); var dtNew = new Date(txtDate); if (dtNew == 'Invalid Date') { var arrDate = txtDate.match(/\b(\d+)\b/ig); arrDate = arrDate.map(fnInt); if (arrDate[2] < 2000) arrDate[2] += 2000; dtNew = new Date(arrDate[2], arrDate[1] - 1, arrDate[0], arrDate[3], arrDate[4], arrDate[5]); } if (arrMs) dtNew.setMilliseconds(arrMs[1]); return dtNew; } Const3600 = 3600; Const60 = 60; ConstWidth = 'width'; theTable = document.getElementById('edit').parentNode.parentNode.parentNode.parentNode; theTable.removeAttribute(ConstWidth); var arrRows = theTable.rows; var intRows = arrRows.length; for (intRow = 0; intRow < intRows; intRow++) { theRow = arrRows[intRow]; theLength = (arrCells = theRow.cells) ? arrCells.length : 0; if (theLength) { arrCells[theLength - 1].colSpan = 5 - theLength; } } arrValues[2] = myGetInnerofFirstLink(arrRows[1].cells[2]); arrAttack = (arrRows[2].cells[1].textContent).match(/\d+\|\d+/ig); arrAttack = arrAttack[arrAttack.length - 1]; arrTarget = (arrRows[4].cells[1].textContent).match(/\d+\|\d+/ig); arrTarget = arrTarget[arrTarget.length - 1]; arrValues[1] = arrRows[2].cells[1].textContent; arrValues[7] = arrAttack; arrValues[8] = arrTarget; arrValues[9] = arrRows[4].cells[1].textContent; arrValues[10]=url.match(/id=(\d+)/)[1]; arrValues[6] = typeof (arrRows[5].cells[1].innerText) == 'undefined' ? arrRows[5].cells[1].textContent : arrRows[5].cells[1].innerText; dtArrival = fnDate(arrValues[6]); arrValues[6] = fnDateFormat(dtArrival); /*alert(fnDateFormat(dtArrival)); for (x = 0; x < arrRows.length - 1; x++) { // alert(x + " " + arrRows[x].cells.length); for (y = 0; y < arrRows[x].cells.length; y++) { alert("X: " + x + " Y: " + y + " --- " + arrRows[x].cells[y].textContent); } } alert(arrRows[intRows - 2].cells[1].innerHTML); */ /* alert(intRows); alert(arrRows[intRows - 1].cells[1]);*/ arrArrivalIn = myGetInner(arrRows[6].cells[1]).match(/\d+/ig); msecsArrivalIn = (arrArrivalIn[0] * Const3600 + arrArrivalIn[1] * Const60 + arrArrivalIn[2] * 1) * 1000; /*alert('txtAttacker :'+txtAttacker+'\narrAttack :'+arrAttack[2]+'|'+arrAttack[3]+'\narrTarget :'+arrTarget[2]+'|'+arrTarget[3]+'\ndtArrival :'+dtArrival+'\narrArrivalIn :'+arrArrivalIn[0]+':'+arrArrivalIn[1]+':'+arrArrivalIn[2]+':'+arrArrivalIn[3]+'\nsecsArrivalIn :'+secsArrivalIn);*/ theXdiff = parseInt(arrAttack.split("|")[0] - arrTarget.split("|")[0]); theYdiff = parseInt(arrAttack.split("|")[1] - arrTarget.split("|")[1]); dblDistance = Math.sqrt(theXdiff * theXdiff + theYdiff * theYdiff); arrValues[3] = dblDistance.toFixed(2); var intRow = intRows - 2; arrElements = myGetElementsByTagName(theTable, 'input'); theInputButton = arrElements[1]; theInputEdit = arrElements[0]; theInputEdit.size = Const60; newRow = myInsRow(); mySetInner(myInsCell(0), 'Distance:').colSpan = 2; mySetInner(myInsCell(1), arrValues[3] + ' Fields').colSpan = 2; newRow = myInsRow(); arrHead.forEach(myInsTH); function fnPreg(varValue, intIdx) { newInput.value = newInput.value.replace(arrReplace[intIdx], varValue); } function fnDateFormat(dtDate) { intMs = dtDate.getMilliseconds(); return myZeroPad(dtDate.getHours()) + ':' + myZeroPad(dtDate.getMinutes()) + ':' + myZeroPad(dtDate.getSeconds()) + '.' + (intMs > 99 ? intMs : '0' + myZeroPad(intMs)) + ' ' + myZeroPad(dtDate.getDate()) + '/' + myZeroPad(dtDate.getMonth() + 1); } for (theIndex in arrUnitNames) { msecsDuration = Math.round([9,10,11,18,22,30,35][theIndex] * Const60 * 1000 * dblDistance / theWorldSpeed / theUnitSpeed); secsDiff = (msecsDuration - msecsArrivalIn) / 1000; if (secsDiff > 0) { arrValues[0] = arrUnitNames[theIndex]; arrValues[5] = myTime(msecsDuration / 1000); dtSent = new Date(dtArrival - msecsDuration); arrValues[4] = fnDateFormat(dtSent); newRow = myInsRow(); mySetInner(myInsCell(0), arrUnitNames[theIndex]); mySetInner(myInsCell(1), secsDiff < Const60 && 'just now' || secsDiff < Const3600 && Math.floor(secsDiff / Const60) + ' mins ago' || myTime(secsDiff) + ' ago'); mySetInner(myInsCell(2), arrValues[5]); newCell = myInsCell(3); newButton = newCell.appendChild(theInputButton.cloneNode(true)); newInput = newCell.appendChild(theInputEdit.cloneNode(true)); newInput.id = 'I' + theIndex; newInput.value = theFormat; arrValues.forEach(fnPreg); newButton.onmousedown = new Function('theInputEdit.value=document.getElementById(\'I' + theIndex + '\').value;'); } } } labelAttack(); void (0);
[/spoil]
Supert, den funket. Tusen takk! :)
 

MasterSplinter

Populær på forumet
Reaksjonspoeng
251
Noen som kan lage en versjon som funker etter den siste oppdateringen?

Her er en oversikt over hva som har blitt forandret:

Morthy skrev:
In this update we changed all the places where you see the edit icon to easily rename something to all use the same standard system in an accessible way. Prior to this, each location was implemented differently and had a lot of problems. For example, if your session had expired or your internet connection / server had problems the renaming would just silently failing without telling you. While this will likely have broken some existing scripts, in the future it will be much easier for scripts to hook into renaming things because everything is done in the same way, so it shouldn't take long for script authors to update their scripts.

As a reminder, we do bring updates onto our Beta server before normal worlds, and even have a Sandbox world there to which scripters can apply to join and be granted some free villages and so on for testing. It is the responsibility of script authors to keep their scripts compatible with the game.
 
Sist redigert:

Torg13

Nytt medlem
Reaksjonspoeng
0
Jeg klarer fortsatt ikke å finne noe taggescript som fungerer etter siste oppdatering. I alle fall ikkke i opera og google crrome. Er det noen som har ett?

T.
 

The Governator

Populær på forumet
Reaksjonspoeng
362
Prøv dette:
javascript: theFormat = '{unit} - {origin} - {sent} - {arrival}'; $.getScript("https://dl.dropboxusercontent.com/u/144647314/twscripts/IncomingRenamer.js"); void(0);
 
Status
Stengt for ytterligere svar.