Reddit Vote and Comment Fuzzer

Fuzzes comments (on your front page) for a specific subreddit

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Reddit Vote and Comment Fuzzer
// @namespace    http://kmcdeals.com
// @version      1.1
// @description  Fuzzes comments (on your front page) for a specific subreddit
// @author       Kmc - [email protected]
// @match        *://*.reddit.com/
// @match        *://*.reddit.com/r/all/
// @grant        none
// ==/UserScript==

//configurables - all selections are random

    //list of words that replace the subs below - separate subreddits with ; (eg. "videos;unexpected;wtf")
var subReplacementList = "videos",
    
    //subreddit(s) that get replaced with the above list - separate multiple subreddits with ; (eg. "unexpectedjihad;unexpectedcena;unexpected")
    subsToReplace = "unexpectedjihad;unexpectedcena",
    
    maxScore = 3700,
    minScore = 1700,

    maxCommentNum = 2500,
    minCommentNum = 700,

    maxTime = 15,
    minTime = 4;


//in case of an error, here are the default values
/*
var subReplacementList = "videos",
    
    subsToReplace = "unexpectedjihad;unexpectedcena",
    
    maxScore = 3700,
    minScore = 1700,

    maxCommentNum = 2500,
    minCommentNum = 700,

    maxTime = 15,
    minTime = 4;

*/


//ignore everything below here

fuzzScores();
function fuzzScores() {
    if(typeof subReplacementList === "undefined" || typeof subsToReplace === "undefined" || typeof maxScore === "undefined" || typeof minScore === "undefined" || typeof maxCommentNum === "undefined" || typeof minCommentNum === "undefined" || typeof maxTime === "undefined" || typeof minTime === "undefined") return alert("Reddit Vote and Comment Fuzzer:\n\nOne or more of the variables are undefined. Make sure there are 7 in total!");
    
    var subElements = document.querySelectorAll('.link .entry .tagline .subreddit');

    for (i = 0; i < subElements.length; i++) {
       
        var subsToReplaceArr = subsToReplace.split(";");
        
        for (j = 0; j < subsToReplaceArr.length; j++) {
            var subHref = subElements[i].href.toLowerCase();

            if (subHref.indexOf(subsToReplaceArr[j].toLowerCase()) > -1 && subElements[i].className.indexOf('kmc-fuzzed') == -1) {
                subElements[i].className += " kmc-fuzzed";

                var randScore = Math.floor(Math.random() * (maxScore - minScore) + minScore) - 1;
                var randCommentNum = Math.floor(Math.random() * (maxCommentNum - minCommentNum) + minCommentNum);
                var randTime = Math.floor(Math.random() * (maxTime - minTime) + minTime);

                var scoreElement = subElements[i].parentElement.parentElement.parentElement.querySelectorAll('.midcol .score');
                var commentElement = subElements[i].parentElement.parentElement.parentElement.querySelector('.buttons .first .comments');
                var timeElement = subElements[i].parentElement.parentElement.parentElement.querySelector('.entry .tagline .live-timestamp');


                var subsArr = subReplacementList.split(";");
                var randSub = subsArr[Math.floor(Math.random() * subsArr.length)];



                if (subElements[i].innerHTML != null && randSub != null) {
                    subElements[i].innerHTML = "/r/" + randSub;
                }

                if (scoreElement != null) {
                    for (v = 0; v < scoreElement.length; v++) {
                        scoreElement[v].innerHTML = randScore;
                        randScore++;
                    }
                }

                if (commentElement != null) {
                    commentElement.innerHTML = randCommentNum + " comments";
                }

                if (timeElement != null) {
                    timeElement.outerHTML = '<time class="live-timestamp">' + randTime + ' hours ago</time>';
                }
            }
        }
    }
}


var mutationObvserver = window.WebKitMutationObserver || window.MutationObserver;
//called everytime the dom changes
var observer = new mutationObvserver(function(mutations) {
    for (i = 0; i < mutations.length; i++) {
    	//this seemed to be the best way to check if RES loaded a new page
    	if (mutations[i].target.id.match(/([A-Za-z-])+/g) == "page-") {
            fuzzScores();
    	}
    }
});

observer.observe(document, {subtree: true, attributes: true});