Advertisement
SophieDebleeckere

Report Viewer

Jun 20th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. javascript:
  2. //reportviewer by Sophie 'Shinko to Kuma'
  3. if (window.location.href.indexOf('&screen=report') < 0) {
  4.     //relocate
  5.     window.location.assign(game_data.link_base_pure + "&screen=report");
  6. }
  7.  
  8.  
  9. thisPageURLs = [];
  10. var htmlLinks = [];
  11. thisPageText = $.find(".float_right");
  12. for (var i = 0; i < thisPageText.length; i++) {
  13.     if ($(thisPageText[i]).children().length != 0) {
  14.         htmlLinks.push(thisPageText[i]);
  15.     }
  16. }
  17. console.log(htmlLinks);
  18. for (var k = 0; k < htmlLinks.length; k++) {
  19.     //grab link
  20.     console.log(k);
  21.     thisPageURLs.push(htmlLinks[k].parentElement.lastElementChild.firstElementChild.firstElementChild.href);
  22. }
  23. data = [];
  24. reportHTML = [];
  25.  
  26.  
  27. $.getAll = function (
  28.     urls, // array of URLs
  29.     onLoad, // called when any URL is loaded, params (index, data)
  30.     onDone, // called when all URLs successfully loaded, no params
  31.     onError // called when a URL load fails or if onLoad throws an exception, params (error)
  32. ) {
  33.     var numDone = 0;
  34.     var lastRequestTime = 0;
  35.     var minWaitTime = 200; // ms between requests
  36.     loadNext();
  37.     function loadNext() {
  38.         if (numDone == urls.length) {
  39.             onDone();
  40.             return;
  41.         }
  42.  
  43.         let now = Date.now();
  44.         let timeElapsed = now - lastRequestTime;
  45.         if (timeElapsed < minWaitTime) {
  46.             let timeRemaining = minWaitTime - timeElapsed;
  47.             setTimeout(loadNext, timeRemaining);
  48.             return;
  49.         }
  50.  
  51.         console.log('Getting ', urls[numDone]);
  52.         lastRequestTime = now;
  53.         $.get(urls[numDone])
  54.             .done((data) => {
  55.                 try {
  56.                     onLoad(numDone, data);
  57.                     ++numDone;
  58.                     loadNext();
  59.                 } catch (e) {
  60.                     onError(e);
  61.                 }
  62.             })
  63.             .fail((xhr) => {
  64.                 onError(xhr);
  65.             })
  66.     }
  67. };
  68.  
  69.  
  70. var html = `<td></td><td><div id="report" class="map_container ui-widget-content" style="overflow-y: auto;width:500px;height:500px" >`;
  71. $.getAll(thisPageURLs,
  72.     (i, blabla) => {
  73.         console.log($(blabla).find(".report_ReportAttack")[0]);
  74.         if ($(blabla).find(".report_ReportAttack")[0] != undefined) {
  75.             reportHTML.push($(blabla).find(".report_ReportAttack")[0]);
  76.         }
  77.     },
  78.     () => {
  79.         for (var j = 0; j < reportHTML.length; j++) {
  80.             html += `
  81.             <div style="margin:20px; margin-top:5px"><div class="quotetitle"><b>Report ${j+1}:</b> <input type="button" value="Show" style="width:45px;font-size:10px;margin:0px;padding:0px;" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = '';        this.innerText = ''; this.value = 'Hide'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Show'; }" /></div><div class="quotecontent"><div style="display: none;">${reportHTML[j].innerHTML}</div></div></div>`
  82.            
  83.         ;
  84.         }
  85.         html += `</div></td><td></td>`
  86.         $("#report_list").prepend(html);
  87.         $("#report").draggable();
  88.     },
  89.     (error) => {
  90.         console.error(error);
  91.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement