Greasy Fork is available in English.

ICV Highlighter

highlights new posts of the day in www.icv-crew.com pages

  1. // ==UserScript==
  2. // @name ICV Highlighter
  3. // @description highlights new posts of the day in www.icv-crew.com pages
  4. // @author SH3LL
  5. // @version 1.8.1
  6. // @match https://www.icv-crew.com/forum/index.php?*
  7. // @grant none
  8. // @copyright GPL3
  9. // @namespace https://greasyfork.org/users/762057
  10. // ==/UserScript==
  11.  
  12. let months = {
  13. '01':'Gennaio', '02':'Febbraio', '03':'Marzo', '04':'Aprile', '05':'Maggio', '06':'Giugno', '07':'Luglio', '08':'Agosto', '09':'Settembre', '10':'Ottobre', '11':'Novembre', '12':'Dicembre'
  14. };
  15.  
  16. function get_thread_page(post_link){
  17. return new Promise(function (resolve, reject) {
  18. let req = new XMLHttpRequest();
  19. req.open('GET', post_link , false);
  20. req.send(null);
  21. if(req.status == 200) {
  22. resolve(req.responseText);
  23. }else{
  24. resolve("err");
  25. }
  26. });
  27. }
  28.  
  29. function get_data_oggi(){
  30. return new Promise(function (resolve, reject) {
  31. let ieri = new Date();
  32. ieri.setDate(ieri.getDate());
  33. let mese= months[String(ieri.getMonth() + 1).padStart(2, '0')];
  34. let dd = String(ieri.getDate()).padStart(2, '0');
  35. let yyyy = ieri.getFullYear();
  36. ieri = dd + ' ' + mese + ' ' + yyyy;
  37. resolve(ieri);
  38. });
  39. }
  40. function get_data_ieri(){
  41. return new Promise(function (resolve, reject) {
  42. let ieri = new Date();
  43. ieri.setDate(ieri.getDate() - 1);
  44. let mese= months[String(ieri.getMonth() + 1).padStart(2, '0')];
  45. let dd = String(ieri.getDate()).padStart(2, '0');
  46. let yyyy = ieri.getFullYear();
  47. ieri = dd + ' ' + mese + ' ' + yyyy;
  48. resolve(ieri);
  49. });
  50. }
  51.  
  52. async function main(){
  53. //setto la data di ieri
  54. let ieri = await get_data_ieri();
  55. let oggi = await get_data_oggi();
  56. console.log(ieri)
  57.  
  58. //--------------rendo grigi tutti i post PINNATI tolgo le etichette "nuovo--------------
  59. let pinnati = document.getElementsByClassName("windowbg sticky locked");
  60. for (pinnato of pinnati){
  61. if (pinnato.children[1].children[0].children[1].children[0].innerText.includes("Nuovo")){
  62. pinnato.children[1].children[0].children[1].children[1].children[0].children[0].style.color = 'grey';
  63. pinnato.children[1].children[0].children[1].children[0].remove();
  64. }else{
  65. pinnato.children[1].children[0].children[1].children[0].children[0].children[0].style.color = 'grey';
  66. }
  67. }
  68. //--------------rimuovo le linee di separazione tra thread e descrizione----------------
  69. /*
  70. let hrElements = document.querySelectorAll('hr.topicdesc');
  71. hrElements.forEach((hrElement) => {
  72. hrElement.remove();
  73. });
  74. */
  75. //--------------rimuovi tags----------------
  76. var tags = document.querySelectorAll('ul.tags');
  77. tags.forEach(function(ulElemento) {
  78. ulElemento.remove();
  79. });
  80.  
  81. //--------------coloro di grigio tutti i post RELEASES--------------
  82. let releases = document.querySelectorAll('.windowbg:not(.sticky)');
  83. for (release of releases){
  84.  
  85. if(release.children[1].children[0].children[1].children[0].innerText.includes("Nuovo")){
  86. if(release.children[1].children[0].children[1].children[1].innerText.includes("SPOSTATO")){release.children[1].children[0].children[1].children[1].style.textDecoration = "line-through";}
  87. release.children[1].children[0].children[1].children[1].children[0].children[0].style.color = 'grey';
  88. release.children[1].children[0].children[1].children[0].remove();
  89.  
  90. }else{
  91. if(release.children[1].children[0].children[1].children[0].innerText.includes("SPOSTATO")){release.children[1].children[0].children[1].children[0].style.textDecoration = "line-through";}
  92. release.children[1].children[0].children[1].children[0].children[0].children[0].style.color = 'grey';
  93. }
  94. }
  95.  
  96. //-------------- coloro i post --------------
  97. for (el of releases){
  98. let original_text=el.children[1].children[0].children[1].children[0].children[0].children[0].innerText;
  99. let post_link= el.children[1].children[0].children[1].children[0].children[0].children[0].href;
  100. let codec_icon=el.children[0];
  101.  
  102. //--------------APPENDO LABEL "PARSING"--------------
  103. let parsing_label=document.createElement("small");
  104. parsing_label.style.color="orange";
  105. parsing_label.innerText=" <-- Parsing"
  106. el.children[1].children[0].children[1].children[0].children[0].append(parsing_label);
  107.  
  108. //--------------CONTROLLI SU OGNI POST PER VEDERE SE E' NECESSARIO SCARICARE LA PAGINA--------------
  109. let data_e_releaser_name=el.querySelectorAll('.lastpost')[0].children[0].children[0].innerText;
  110. let n_risposte_e_n_visite=el.querySelectorAll('.board_stats.centertext')[0].innerText;
  111.  
  112. if(data_e_releaser_name.includes("Oggi") && n_risposte_e_n_visite.includes("Risposte: 0")){ // >>>>>> se c'è scritto OGGI e ha 0 RISPOSTE: coloro subito di arancione
  113. el.children[1].children[0].children[1].children[0].children[0].children[0].style.color = 'orange';
  114. el.children[1].children[0].children[1].children[0].children[0].lastElementChild.remove();
  115. continue;
  116.  
  117. }else if(data_e_releaser_name.includes(ieri) && n_risposte_e_n_visite.includes("Risposte: 0")){ // >>>>>> se c'è scritto IERI e ha 0 RISPOSTE: coloro subito di marrone
  118. el.children[1].children[0].children[1].children[0].children[0].children[0].style.color = 'saddlebrown';
  119. el.children[1].children[0].children[1].children[0].children[0].lastElementChild.remove();
  120. continue;
  121.  
  122. }else if(!data_e_releaser_name.includes("Oggi") && !data_e_releaser_name.includes(ieri)){ // >>>>>> se non c'è scritto OGGI/IERI, a prescindere dal numero di risposte, è vecchio, quindi lo salto direttamente
  123. el.children[1].children[0].children[1].children[0].children[0].lastElementChild.remove();
  124. continue;
  125.  
  126. }else{ // >>>>>> post incerto da verificare all'interno
  127. //ricevo pagina html del thread
  128. let html_page = await get_thread_page(post_link);
  129.  
  130. //converto pagina html in DOM
  131. let dom_page = document.createElement('html');
  132. dom_page.innerHTML = html_page;
  133.  
  134. let postinfo = dom_page.querySelectorAll('.postinfo')[0];
  135.  
  136. if(postinfo.children[1].innerText.includes(oggi)) {
  137. el.children[1].children[0].children[1].children[0].children[0].children[0].style.color = 'orange';
  138. }
  139. if(postinfo.children[1].innerText.includes(ieri) ) {
  140. el.children[1].children[0].children[1].children[0].children[0].children[0].style.color = 'saddlebrown';
  141. }
  142.  
  143. el.children[1].children[0].children[1].children[0].children[0].lastElementChild.remove();
  144. }
  145. }
  146.  
  147. }
  148.  
  149. main();