🏠 Home 

LogcheckerPlus

Enhancements for Logchecker


Install this script?
  1. // ==UserScript==
  2. // @name LogcheckerPlus
  3. // @namespace LogcheckerPlus
  4. // @author TNSepta
  5. // @description Enhancements for Logchecker
  6. // @include http*://*apollo.rip/logchecker.php
  7. // @include http*://*passtheheadphones.me/logchecker.php
  8. // @include http*://*notwhat.cd/logchecker.php
  9. // @include http*://*hydra.zone/logchecker.php
  10. // @version 1
  11. // @grant GM_addStyle
  12. // ==/UserScript==
  13. upTable = document.getElementsByClassName('forum_post vertical_margin')
  14. if (upTable.length > 0) {
  15. GM_addStyle (".LCPtooltip {\
  16. position: absolute;\
  17. display: inline-block;\
  18. border-bottom: 1px dotted black; /* If you want dots under the hoverable text */}\
  19. .LCPtooltip .LCPtooltiptext {\
  20. visibility: hidden;\
  21. width: 480px;\
  22. background-color: black;\
  23. color: #fff;\
  24. text-align: center;\
  25. padding: 5px 0;\
  26. border-radius: 6px;\
  27. position: absolute;\
  28. z-index: 1;}\
  29. .LCPtooltip:hover .LCPtooltiptext {\
  30. visibility: visible;}");
  31. upTable[0].innerHTML = '<tr class = \'colhead\'><td colspan=\'2\'>Bulk Upload Files</td></tr><tr><td> <div id=\'fileselect\'>\t<div id=\'filedrag\'><font size = \'60\'>Drop files here</font></div><div id = \'output\'></div></div> </td></tr>' + upTable[0].innerHTML
  32. // getElementById
  33. function $id(id) {
  34. return document.getElementById(id);
  35. }
  36. // output information
  37. function Output(msg) {
  38. var m = $id('output');
  39. m.innerHTML = msg + m.innerHTML;
  40. }
  41. // call initialization file
  42. if (window.File && window.FileList && window.FileReader) {
  43. Init();
  44. }else{
  45. Output("Error, AJAX upload not supported, check your browser!");
  46. }
  47. // initialize
  48. function Init() {
  49. var fileselect = $id('fileselect'),
  50. filedrag = $id('filedrag')
  51. filedrag.style.height = '100px';
  52. // file select
  53. fileselect.addEventListener('change', FileSelectHandler, false);
  54. // is XHR2 available?
  55. var xhr = new XMLHttpRequest();
  56. if (xhr.upload) {
  57. // file drop
  58. filedrag.addEventListener('dragover', FileDragHover, false);
  59. filedrag.addEventListener('dragleave', FileDragHover, false);
  60. filedrag.addEventListener('drop', FileSelectHandler, false);
  61. filedrag.style.display = 'block';
  62. }
  63. }
  64. // file drag hover
  65. function FileDragHover(e) {
  66. e.stopPropagation();
  67. e.preventDefault();
  68. e.target.className = (e.type == 'dragover' ? 'hover' : '');
  69. } // file selection
  70. function FileSelectHandler(e) {
  71. // cancel event and hover styling
  72. FileDragHover(e);
  73. // fetch FileList object
  74. var files = e.target.files || e.dataTransfer.files;
  75. // process all File objects
  76. for (var i = 0, f; f = files[i]; i++) {
  77. UploadFile(f);
  78. }
  79. }
  80. function UploadFile(file) {
  81. var xhr = new XMLHttpRequest();
  82. var reader = new FileReader();
  83. reader.onload = function(e) {
  84. var url = "logchecker.php"
  85. var params = "action=takeupload&submit=Upload+log&pastelog=" + escape(reader.r###lt)
  86. xhr.open("POST", url, true);
  87. xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  88. xhr.onreadystatechange = function() { //Call a function when the state changes.
  89. if (xhr.readyState == 4 && xhr.status == 200) {
  90. //Grab the relevant information.
  91. anaOut = xhr.responseText.split("<div id=\"content\">")[1].split("<div id=\"footer\">")[0];
  92. console.log(anaOut);
  93. fname = file.name;
  94. logScore = anaOut.split("<strong>Score:</strong>")[1].split("(out of 100)")[0];
  95. if (anaOut.indexOf("Log validation report:")>=0){
  96. logReport = anaOut.split("<h3>Log validation report:</h3>")[1].split("</blockquote>")[0];
  97. }else{
  98. logReport = "No log report found, all is good!";
  99. }
  100. Output("<div class = 'LCPtooltip'>"+logScore+"<span class='LCPtooltiptext'>"+logReport+"</span></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+fname+"</div><br>");
  101. }
  102. }
  103. xhr.send(params);
  104. }
  105. reader.readAsText(file);
  106. }
  107. }