JV Notes de test

Affiche les notes des jeux sur la page de listing

  1. // ==UserScript==
  2. // @name JV Notes de test
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Affiche les notes des jeux sur la page de listing
  6. // @author Shuunen
  7. // @match http://www.jeuxvideo.com/tests/*/**
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // enlève la colonne de droite
  15. var col = document.querySelector('.col-right');
  16. if (col) {
  17. col.remove();
  18. }
  19.  
  20. // resize la colonne principale
  21. col = document.querySelector('.col-main');
  22. if (col) {
  23. col.style.maxWidth = '100%';
  24. }
  25.  
  26. // affiche les notes pour chaque jeux
  27. var jeux = document.querySelectorAll('.pres-item-jaq');
  28.  
  29. jeux.forEach(function(jeu) {
  30.  
  31. var url = jeu.querySelector('a').href;
  32. var content = jeu.querySelector('.mask-img');
  33.  
  34. // enlève les notes déjà présentes
  35. content.querySelectorAll('.note').forEach(function(note) {
  36. note.remove();
  37. });
  38.  
  39. fetch(url, {
  40. credentials: 'same-origin'
  41. }).then(function(response) {
  42. return response.text();
  43. }).then(function(html) {
  44. var htmlEl = document.createElement("div");
  45. htmlEl.innerHTML = html;
  46. var notes = htmlEl.querySelectorAll('.note');
  47. var note = '';
  48. if (!notes || !notes.length) {
  49. note = 'introuvable...';
  50. } else {
  51. note = parseInt(notes[0].innerText.split('/')[0]) + parseInt(notes[1].innerText.split('/')[0]);
  52. note = Math.round(note / 2);
  53. }
  54. var fontSize = parseInt((Math.log10(note)+'').split('.')[1].substr(0,2))*1.2 + 10;
  55. var color = (note > 15 ? 'crimson' : note > 12 ? 'navy' : 'gray');
  56. var newHtml = '<span class="note" style="font-size:'+ fontSize +'px; color: '+color+'; letter-spacing: -1px; white-space: nowrap; font-weight: 600; padding-left: 10px; margin-top: 15px; display: block; border-left: 4px solid;">';
  57. newHtml += '<strong>' + note + '</strong><small>&nbsp;/&nbsp;20</small>';
  58. newHtml += '</span>';
  59. content.innerHTML += newHtml;
  60. });
  61.  
  62. });
  63.  
  64. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址