• [^] # Re: Petites remarques sur le script

    Posté par . En réponse au journal Karma is considered harmful. Évalué à 1.

    Ça vient peut-être du moment où le script est exécuté, genre onload versus DOMContentLoaded ?

    Bien vu !

    J'ai mis à jour le script pour utiliser l'injection de CSS, mettre un peu au propre tout ça et définir le moment de l'exécution (doc de @run-at pour tamper). Ça donne ça :

    // ==UserScript==
    // @name DLFPNoKarma
    // @namespace DLFPNoKarma
    // @version 0.1
    // @description https://linuxfr.org/users/peetah/journaux/plonk
    // @author You
    // @match https://linuxfr.org/*
    // @grant none
    // @run-at document-body
    // ==/UserScript==
    (function() {
     'use strict';
     let style = document.createElement("style");
     style.textContent = `
     .details, .vote {
     display: none !important;
     }
     .fold {
     display: contents !important;
     }
     .hidden {
     display: contents !important;
     }
     .score {
     display: none !important;
     }
     `;
     document.querySelector("head").appendChild(style);
     // user space
     let nbVotes = document.getElementById('nb_votes');
     if (nbVotes) nbVotes.parentNode.style.display = 'none';
     // column notes in board
     let comments = document.getElementById('my_comments');
     if (comments) {
     for(let myComments of comments.childNodes[1].childNodes) {
     if (myComments.nodeType === Node.ELEMENT_NODE) {
     myComments.removeChild(myComments.childNodes[7]);
     }
     }
     }
     // karma counter in user space
     for(let userKarma of document.querySelectorAll("#user_recent_contents > ul > li")) {
     if(userKarma.textContent.includes('Karma')) {
     userKarma.style.display = 'none'
     }
     }
     // remove notes
     for(let score of document.querySelectorAll("span.score")) {
     score.parentNode.childNodes[3].textContent='';
     score.parentNode.childNodes[5].textContent='';
     }
    })();

    Il n'y a plus de glitch initial.

    https://linuxfr.org/users/barmic/journaux/y-en-a-marre-de-ce-gros-troll