Add A Link To Hide All Reddit Posts

Add a link to hide all Reddit posts listed in currently logged-on user's page tab (Overview, Submitted, Downvoted, etc.). This script will auto-navigate to the next page (if any) and will continue hiding any hideable posts until the last page.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Add A Link To Hide All Reddit Posts
// @namespace    AddALinkToHideAllRedditPosts
// @version      1.0.1
// @description  Add a link to hide all Reddit posts listed in currently logged-on user's page tab (Overview, Submitted, Downvoted, etc.). This script will auto-navigate to the next page (if any) and will continue hiding any hideable posts until the last page.
// @author       jcunews
// @include      *://*.reddit.com/user/*/*/*
// @grant        none
// ==/UserScript==

var hideLinks = document.querySelectorAll('.thing .hide-button a'), linkIndex = 0, hidePostsInProgress = false;
if (hideLinks.length) {
  var rActionsTrigger = r.actions.trigger;
  r.actions.trigger = function(name, object) {
    if (hidePostsInProgress && (name === "legacy:change-state")) {
      var oldPostCallback = object.post_callback;
      object.post_callback = function(){
        var result, nextLink;
        if (oldPostCallback) {
          result = oldPostCallback.apply(this, arguments);
        }
        if (hidePostsInProgress) {
          if (++linkIndex < hideLinks.length) {
            hideLinks[linkIndex].click();
          } else {
            nextLink = document.querySelector(".nav-buttons .next-button a");
            if (nextLink) {
              nextLink.click();
            } else {
              hidePostsInProgress = false;
              delete sessionStorage.hidePostsInProgress;
            }
          }
          return result;
        }
      };
    }
    return rActionsTrigger.apply(this, arguments);
  };
  var menuArea = document.querySelector(".menuarea > .spacer");
  var link = document.createElement("A");
  link.textContent = "Hide All Posts";
  link.style.marginLeft = "2ex";
  link.href = "#";
  link.onclick = function() {
    if (!hidePostsInProgress) {
      hidePostsInProgress = true;
      sessionStorage.hidePostsInProgress = 1;
      hideLinks[0].click();
    }
    return false;
  };
  menuArea.appendChild(link);
  if (hidePostsInProgress = sessionStorage.hidePostsInProgress) {
    hideLinks[0].click();
  }
} else {
  hidePostsInProgress = false;
  delete sessionStorage.hidePostsInProgress;
}