Reddit Vote and Comment Fuzzer

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

  1. // ==UserScript==
  2. // @name Reddit Vote and Comment Fuzzer
  3. // @namespace http://kmcdeals.com
  4. // @version 1.1
  5. // @description Fuzzes comments (on your front page) for a specific subreddit
  6. // @author Kmc - admin@kmcdeals.com
  7. // @match *://*.reddit.com/
  8. // @match *://*.reddit.com/r/all/
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. //configurables - all selections are random
  13.  
  14. //list of words that replace the subs below - separate subreddits with ; (eg. "videos;unexpected;wtf")
  15. var subReplacementList = "videos",
  16. //subreddit(s) that get replaced with the above list - separate multiple subreddits with ; (eg. "unexpectedjihad;unexpectedcena;unexpected")
  17. subsToReplace = "unexpectedjihad;unexpectedcena",
  18. maxScore = 3700,
  19. minScore = 1700,
  20.  
  21. maxCommentNum = 2500,
  22. minCommentNum = 700,
  23.  
  24. maxTime = 15,
  25. minTime = 4;
  26.  
  27.  
  28. //in case of an error, here are the default values
  29. /*
  30. var subReplacementList = "videos",
  31. subsToReplace = "unexpectedjihad;unexpectedcena",
  32. maxScore = 3700,
  33. minScore = 1700,
  34.  
  35. maxCommentNum = 2500,
  36. minCommentNum = 700,
  37.  
  38. maxTime = 15,
  39. minTime = 4;
  40.  
  41. */
  42.  
  43.  
  44. //ignore everything below here
  45.  
  46. fuzzScores();
  47. function fuzzScores() {
  48. 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!");
  49. var subElements = document.querySelectorAll('.link .entry .tagline .subreddit');
  50.  
  51. for (i = 0; i < subElements.length; i++) {
  52. var subsToReplaceArr = subsToReplace.split(";");
  53. for (j = 0; j < subsToReplaceArr.length; j++) {
  54. var subHref = subElements[i].href.toLowerCase();
  55.  
  56. if (subHref.indexOf(subsToReplaceArr[j].toLowerCase()) > -1 && subElements[i].className.indexOf('kmc-fuzzed') == -1) {
  57. subElements[i].className += " kmc-fuzzed";
  58.  
  59. var randScore = Math.floor(Math.random() * (maxScore - minScore) + minScore) - 1;
  60. var randCommentNum = Math.floor(Math.random() * (maxCommentNum - minCommentNum) + minCommentNum);
  61. var randTime = Math.floor(Math.random() * (maxTime - minTime) + minTime);
  62.  
  63. var scoreElement = subElements[i].parentElement.parentElement.parentElement.querySelectorAll('.midcol .score');
  64. var commentElement = subElements[i].parentElement.parentElement.parentElement.querySelector('.buttons .first .comments');
  65. var timeElement = subElements[i].parentElement.parentElement.parentElement.querySelector('.entry .tagline .live-timestamp');
  66.  
  67.  
  68. var subsArr = subReplacementList.split(";");
  69. var randSub = subsArr[Math.floor(Math.random() * subsArr.length)];
  70.  
  71.  
  72.  
  73. if (subElements[i].innerHTML != null && randSub != null) {
  74. subElements[i].innerHTML = "/r/" + randSub;
  75. }
  76.  
  77. if (scoreElement != null) {
  78. for (v = 0; v < scoreElement.length; v++) {
  79. scoreElement[v].innerHTML = randScore;
  80. randScore++;
  81. }
  82. }
  83.  
  84. if (commentElement != null) {
  85. commentElement.innerHTML = randCommentNum + " comments";
  86. }
  87.  
  88. if (timeElement != null) {
  89. timeElement.outerHTML = '<time class="live-timestamp">' + randTime + ' hours ago</time>';
  90. }
  91. }
  92. }
  93. }
  94. }
  95.  
  96.  
  97. var mutationObvserver = window.WebKitMutationObserver || window.MutationObserver;
  98. //called everytime the dom changes
  99. var observer = new mutationObvserver(function(mutations) {
  100. for (i = 0; i < mutations.length; i++) {
  101. //this seemed to be the best way to check if RES loaded a new page
  102. if (mutations[i].target.id.match(/([A-Za-z-])+/g) == "page-") {
  103. fuzzScores();
  104. }
  105. }
  106. });
  107.  
  108. observer.observe(document, {subtree: true, attributes: true});