modwars.com

modwars planeten scanner

  1. // ==UserScript==
  2. // @name modwars.com
  3. // @namespace basti 10121012
  4. // @include *modwars.com*
  5. // @version 2.9
  6. // @description modwars planeten scanner
  7. // @grant GM_getValue
  8. // @grant GM_setValue
  9. // @grant GM_xmlhttpRequest
  10. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
  11.  
  12. // ==/UserScript==
  13. var start=1;
  14. var ende=10;
  15. var interval=1000;//1000 gleich 1 sekunde .Wenn zu schnell streikt der nodwars.com server Bitte testen
  16.  
  17. //-------------------------------------------------------------------------------
  18. function addGlobalStyle(css) {
  19. var head, style;
  20. head = document.getElementsByTagName('body')[0];
  21. if (!head) { return; }
  22. style = document.createElement('style');
  23. style.type = 'text/css';
  24. style.innerHTML = css;
  25. head.appendChild(style);
  26. }
  27. addGlobalStyle('#tisch{width:100%;height:auto;background:white;color:black}');
  28. addGlobalStyle('tr{width:100%;}}');
  29. addGlobalStyle('td{border:1px solid black;width:22%}');
  30. addGlobalStyle('td:nth-child(1){border:1px solid black;width:30px}');
  31. addGlobalStyle('#ad{background:white;width:100%}}');
  32.  
  33.  
  34.  
  35.  
  36.  
  37. (function (root, factory) {
  38. if (typeof define === 'function' && define.amd) {
  39. // AMD. Register as an anonymous module.
  40. define([], factory);
  41. } else if (typeof exports === 'object') {
  42. // Node. Does not work with strict CommonJS, but
  43. // only CommonJS-like environments that support module.exports,
  44. // like Node.
  45. module.exports = factory();
  46. } else {
  47. // Browser globals (root is window)
  48. root.download = factory();
  49. }
  50. }(this, function () {
  51.  
  52. return function download(data, strFileName, strMimeType) {
  53.  
  54. var self = window, // this script is only for browsers anyway...
  55. defaultMime = "application/octet-stream", // this default mime also triggers iframe downloads
  56. mimeType = strMimeType || defaultMime,
  57. payload = data,
  58. url = !strFileName && !strMimeType && payload,
  59. anchor = document.createElement("a"),
  60. toString = function(a){return String(a);},
  61. myBlob = (self.Blob || self.MozBlob || self.WebKitBlob || toString),
  62. fileName = strFileName || "download",
  63. blob,
  64. reader;
  65. myBlob= myBlob.call ? myBlob.bind(self) : Blob ;
  66. if(String(this)==="true"){ //reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback
  67. payload=[payload, mimeType];
  68. mimeType=payload[0];
  69. payload=payload[1];
  70. }
  71.  
  72.  
  73. if(url && url.length< 2048){ // if no filename and no mime, assume a url was passed as the only argument
  74. fileName = url.split("/").pop().split("?")[0];
  75. anchor.href = url; // assign href prop to temp anchor
  76. if(anchor.href.indexOf(url) !== -1){ // if the browser determines that it's a potentially valid url path:
  77. var ajax=new XMLHttpRequest();
  78. ajax.open( "GET", url, true);
  79. ajax.responseType = 'blob';
  80. ajax.onload= function(e){
  81. download(e.target.response, fileName, defaultMime);
  82. };
  83. setTimeout(function(){ ajax.send();}, 0); // allows setting custom ajax headers using the return:
  84. return ajax;
  85. } // end if valid url?
  86. } // end if url?
  87.  
  88.  
  89. //go ahead and download dataURLs right away
  90. if(/^data:([\w+-]+\/[\w+.-]+)?[,;]/.test(payload)){
  91. if(payload.length > (1024*1024*1.999) && myBlob !== toString ){
  92. payload=dataUrlToBlob(payload);
  93. mimeType=payload.type || defaultMime;
  94. }else{
  95. return navigator.msSaveBlob ? // IE10 can't do a[download], only Blobs:
  96. navigator.msSaveBlob(dataUrlToBlob(payload), fileName) :
  97. saver(payload) ; // everyone else can save dataURLs un-processed
  98. }
  99. }else{//not data url, is it a string with special needs?
  100. if(/([\x80-\xff])/.test(payload)){
  101. var i=0, tempUiArr= new Uint8Array(payload.length), mx=tempUiArr.length;
  102. for(i;i<mx;++i) tempUiArr[i]= payload.charCodeAt(i);
  103. payload=new myBlob([tempUiArr], {type: mimeType});
  104. }
  105. }
  106. blob = payload instanceof myBlob ?
  107. payload :
  108. new myBlob([payload], {type: mimeType}) ;
  109.  
  110.  
  111. function dataUrlToBlob(strUrl) {
  112. var parts= strUrl.split(/[:;,]/),
  113. type= parts[1],
  114. indexDecoder = strUrl.indexOf("charset")>0 ? 3: 2,
  115. decoder= parts[indexDecoder] == "base64" ? atob : decodeURIComponent,
  116. binData= decoder( parts.pop() ),
  117. mx= binData.length,
  118. i= 0,
  119. uiArr= new Uint8Array(mx);
  120.  
  121. for(i;i<mx;++i) uiArr[i]= binData.charCodeAt(i);
  122.  
  123. return new myBlob([uiArr], {type: type});
  124. }
  125.  
  126. function saver(url, winMode){
  127.  
  128. if ('download' in anchor) { //html5 A[download]
  129. anchor.href = url;
  130. anchor.setAttribute("download", fileName);
  131. anchor.className = "download-js-link";
  132. anchor.innerHTML = "downloading...";
  133. anchor.style.display = "none";
  134. anchor.addEventListener('click', function(e) {
  135. e.stopPropagation();
  136. this.removeEventListener('click', arguments.callee);
  137. });
  138. document.body.appendChild(anchor);
  139. setTimeout(function() {
  140. anchor.click();
  141. document.body.removeChild(anchor);
  142. if(winMode===true){setTimeout(function(){ self.URL.revokeObjectURL(anchor.href);}, 250 );}
  143. }, 66);
  144. return true;
  145. }
  146.  
  147. // handle non-a[download] safari as best we can:
  148. if(/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)) {
  149. if(/^data:/.test(url)) url="data:"+url.replace(/^data:([\w\/\-\+]+)/, defaultMime);
  150. if(!window.open(url)){ // popup blocked, offer direct download:
  151. if(confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")){ location.href=url; }
  152. }
  153. return true;
  154. }
  155.  
  156. //do iframe dataURL download (old ch+FF):
  157. var f = document.createElement("iframe");
  158. document.body.appendChild(f);
  159.  
  160. if(!winMode && /^data:/.test(url)){ // force a mime that will download:
  161. url="data:"+url.replace(/^data:([\w\/\-\+]+)/, defaultMime);
  162. }
  163. f.src=url;
  164. setTimeout(function(){ document.body.removeChild(f); }, 333);
  165.  
  166. }//end saver
  167.  
  168.  
  169.  
  170.  
  171. if (navigator.msSaveBlob) { // IE10+ : (has Blob, but not a[download] or URL)
  172. return navigator.msSaveBlob(blob, fileName);
  173. }
  174.  
  175. if(self.URL){ // simple fast and modern way using Blob and URL:
  176. saver(self.URL.createObjectURL(blob), true);
  177. }else{
  178. // handle non-Blob()+non-URL browsers:
  179. if(typeof blob === "string" || blob.constructor===toString ){
  180. try{
  181. return saver( "data:" + mimeType + ";base64," + self.btoa(blob) );
  182. }catch(y){
  183. return saver( "data:" + mimeType + "," + encodeURIComponent(blob) );
  184. }
  185. }
  186.  
  187. // Blob but not URL support:
  188. reader=new FileReader();
  189. reader.onload=function(e){
  190. saver(this.result);
  191. };
  192. reader.readAsDataURL(blob);
  193. }
  194. return true;
  195. }; /* end download() */
  196. }));
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238. document.getElementsByTagName('body')[0].innerHTML='';
  239. document.getElementsByTagName('body')[0].innerHTML+='<input type="button" id="save" value="Diese Daten Speichern ?"><table id="tisch"><tr><td>Nr</td><td>Planet</td><td>Status</td><td>Entfernung</td><td>Flugzeit</td></tr><tbody id="ww"></tbody></table>';
  240. h=start;
  241. lauf(h);
  242. function lauf(h){
  243.  
  244. if(h<=ende){
  245.  
  246. $.ajax({
  247. type: "GET",
  248. url: "http://www.modwars.com/paid/sec/ships/fly.jsp?shipId=13419551&ownPlanet=0&destination="+h+"&scan=Anpeilen",
  249. // data: {userlist:userlist},
  250. success: function(responseDetails){
  251. //GM_xmlhttpRequest({
  252. // method: 'GET',
  253. // url: 'http://www.modwars.com/paid/sec/ships/fly.jsp?shipId=13419551&ownPlanet=0&destination='+h+'&scan=Anpeilen',
  254. // onload: function(responseDetails) {
  255. var content = responseDetails;
  256. var planet = content.split('Planet:</span>')[2].split('<br')[0];
  257. var status = content.split('Status:</span>')[2].split('<br')[0];
  258. var entfernung = content.split('Entfernung:</span>')[1].split('<br')[0];
  259. var flugzeit = content.split('label">Flugzeit')[1].split('<br')[0];
  260. document.getElementById('tisch').innerHTML+='<tr><td width="30">'+h+'.<td>'+planet+'</td><td>'+status+'</td><td>'+entfernung+'</td><td>'+flugzeit+'</td></tr>';
  261. h++;
  262. setTimeout(function(){lauf(h)},interval);
  263. }});
  264. }else{
  265. alert('Ende')
  266. }
  267. }
  268.  
  269.  
  270.  
  271.  
  272.  
  273. $('#save').click(function() {
  274. var thehtml = $("#tisch");
  275. thehtml.find("script").remove();
  276. doc = '<!doctype html>' + thehtml.html();
  277. download(doc, "specification.html", "text/html");
  278. });
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.