返回首頁 

Greasy Fork is available in English.

Reddit FL - Hello Tinder

Ajoute un bouton qui cache les top-comments qui ne parlent PAS de Tinder sur le FL de /r/france (Old Reddit).


Installer ce script?
// ==UserScript==// @name         Reddit FL - Hello Tinder// @author       RandomUsername404// @namespace    https://greasyfork.org/en/users/105361-randomusername404// @version      0.8// @description  Ajoute un bouton qui cache les top-comments qui ne parlent PAS de Tinder sur le FL de /r/france (Old Reddit).// @run-at       document-start// @include      https://old.reddit.com/r/france/*// @grant        none// @icon         https://i.imgtc.com/kAtByTB.png// ==/UserScript==var indexLastLinkMoreCmts;var targetNode;var config;var callback;var observer;var bool;var regex = new RegExp('(?:^|\\W)tinder|tinderette|okcupid|bumble|badoo|un date|mon date|adopte un mec|meetic|mon ex|mon copain|ma copine|ma femme|mon mari|ma fiancée|mon fiancé(?:$|\\W)');var flair = " 🌘𝐙𝐙𝐙𝐙🌒";window.onload = function() {if (document.getElementsByTagName("title")[0].innerHTML.includes("Forum Libre")) { //document.title non compatible avec tous les navigateurs// Au chargement de la page, surveillance désactivéebool = 0;// Création du bouton pour déclencher le masquagevar btn = document.createElement("BUTTON");btn.innerHTML = 'Tinder <img src="https://svgur.com/i/CNH.svg" height="10px">';var zoneAjoutBtn = document.getElementsByClassName("panestack-title")[0];btn.style.float = "right";btn.style.marginLeft = "5px";btn.style.lineHeight = "12px";btn.style.backgroundImage = "linear-gradient(to top right, #e6457c, #fb8b3e)";btn.style.borderRadius = "5px";btn.style.fontWeight = "bold";btn.style.fontFamily = "inherit";zoneAjoutBtn.appendChild(btn);// Lorsque bouton pressé, active la surveillance et masque certains commentairesbtn.onclick = function() {if (bool == 1) {bool = 0;observer.disconnect();} else {bool = 1;surveillance();}helloTinder();}}}// Surveillance si de nouveaux commentaires sont chargésfunction surveillance() {indexLastLinkMoreCmts = document.getElementsByClassName("morechildren").length - 1;targetNode = document.getElementById((document.getElementsByClassName("morechildren")[indexLastLinkMoreCmts]).id);config = { attributes: false, childList: true, subtree: true };callback = function(mutationsList, observer) {for (var mutation of mutationsList) {if (mutation.type == 'childList') {// Si le bouton a été pressé, masque certains commentaires et reprend la surveillanceif (bool == 1) {setNewObserverAndHelloTinder();}}}};observer = new MutationObserver(callback);observer.observe(targetNode, config);}function setNewObserverAndHelloTinder() {observer.disconnect();setTimeout(function() {indexLastLinkMoreCmts = document.getElementsByClassName("morechildren").length - 1;targetNode = document.getElementById((document.getElementsByClassName("morechildren")[indexLastLinkMoreCmts]).id);helloTinder();observer = new MutationObserver(callback);observer.observe(targetNode, config);}, 1400);}function helloTinder() {var nbComments = document.getElementsByClassName("usertext").length;var compteur;for (compteur = 0; compteur < nbComments; compteur++) {var oneComment = document.getElementsByClassName("usertext")[compteur];var text = oneComment.parentElement.innerHTML.toLowerCase();// N'agit que sur les top commentairesif (!text.includes('data-event-action="parent"')) {// Si bouton a été pressé (et donc la surveillance activée), replie certains commentairesif (bool == 1) {if (text.search(regex) === -1) {oneComment.parentElement.parentElement.classList.replace("noncollapsed", "collapsed");// Evite d'afficher le flair plusieurs fois de suite sur le même commentaire lors de chargementsif (oneComment.previousSibling != null && !oneComment.previousSibling.innerHTML.includes(flair)) {oneComment.previousSibling.append(flair);}}}// Si bouton re-pressé, rétablit l'état précédent des commentaireselse {if (oneComment.previousSibling != null && oneComment.previousSibling.innerHTML.includes(flair)) {oneComment.parentElement.parentElement.classList.replace("collapsed", "noncollapsed");}}}}}