JVC Color Respawn

Change l'icone dans la liste des topics selon le nombre de pages

当前为 2014-12-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name JVC Color Respawn
  3. // @namespace Krapoutchniek (Tanil) (repris du code de Matt' & Naptu)
  4. // @description Change l'icone dans la liste des topics selon le nombre de pages
  5. // @include http://www.jeuxvideo.com/forums/*
  6. // @include http://*.forumjv.com/*
  7. // @include http://www.jeuxvideo.com/forums/0-*-0-1-0-1-2-*.htm
  8. // @version 1.1
  9. // ==/UserScript==
  10.  
  11. function color() {
  12. var num_topic = 1, ligne_topic, image_topic, posts_topic, // num_topic = ligne du topic concerné, commence à 1 pour passer la ligne SUJET AUTEUR NB etc.
  13. topic_epingle = '/img/forums/topic-marque-on.png', // Topic épinglé
  14. topic_epingle_verrouille = '/img/forums/topic-marque-off.png', // Topic épinglé et verrouillé
  15. topic_verrouille = '/img/forums/topic-lock.png'; // Topic verrouillé
  16. while(num_topic <= 25) {
  17. ligne_topic = document.getElementById('table-liste-topic-forum').getElementsByTagName('tr')[num_topic]; // Ordre des topic de 1 à 25
  18. image_topic = ligne_topic.getElementsByTagName('td')[0].getElementsByTagName('div')[0].getElementsByTagName('img')[0]; // td[0] = icone du topic
  19. posts_topic = parseInt(ligne_topic.getElementsByTagName('td')[2].textContent); // td[2] = nombre de posts du topic
  20. console.log(image_topic.getAttribute('src'));
  21. // Modification de l'icone selon le nombre de messages - aucune modification des topics épinglés et/ou verrouillés
  22. if(image_topic.getAttribute('src') != topic_epingle && image_topic.getAttribute('src') != topic_epingle_verrouille && image_topic.getAttribute('src') != topic_verrouille)
  23. {
  24. // Plus de 5 pages
  25. if(posts_topic >= 100)
  26. {
  27. image_topic.src = "http://image.noelshack.com/fichiers/2013/20/1368531862-3.gif";
  28. }
  29. // Plus de 20 pages
  30. if(posts_topic >= 400)
  31. {
  32. image_topic.src = "http://image.noelshack.com/fichiers/2013/20/1368531862-4.gif";
  33. }
  34. // Plus de 100 pages
  35. if(posts_topic >= 2000)
  36. {
  37. image_topic.src = "http://image.noelshack.com/fichiers/2013/20/1368531862-5.gif";
  38. }
  39. // Plus de 1000 pages
  40. if(posts_topic >= 20000)
  41. {
  42. image_topic.src = "http://image.noelshack.com/fichiers/2013/20/1368531862-6.gif";
  43. }
  44. }
  45. num_topic++;
  46. }
  47. }
  48.  
  49. color();