Toggle Reddit Sidebar

Adds a button to toggle the sidebar on Reddit, with the option to have it hidden or shown by default.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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         Toggle Reddit Sidebar
// @namespace    toggle-reddit-sidebar
// @version      1.0
// @description  Adds a button to toggle the sidebar on Reddit, with the option to have it hidden or shown by default.
// @author       GemedetAdept
// @match        *://*.reddit.com/*
// @credits      Adapted, with permission, from "Hide Reddit Side Bar" script by u/pm_all_ahri_art @ https://greasyfork.org/en/scripts/375201-hide-reddit-side-bar
// @license      GNU v3.0
// ==/UserScript==

var IsHidden = true;

var sidebar = document.querySelector(".side");
sidebar.style.overflow = "hidden";

function toggleSidebar () {

	if (IsHidden == true) {

		sidebar.style.height = "";
		sidebar.style.width = "";
		IsHidden = false;
	}

	else if (IsHidden == false) {

		sidebar.style.height = "0px";
		sidebar.style.width = "0px";
		IsHidden = true;
	}
}

var togglebutton = document.createElement("button");
var toggletext = document.createTextNode("toggleBar");
togglebutton.appendChild(toggletext);

togglebutton.style.fontSize = "10px";
togglebutton.style.fontWeight = "bold";
togglebutton.style.left = "4px";
togglebutton.style.color = "#81b3d9";

togglebutton.addEventListener("click", toggleSidebar);

var navBar = document.querySelector("#header");
var buttonSection = navBar.querySelector("#header-bottom-right");
var itemBarDivider = buttonSection.querySelector(".logout.hover");

buttonSection.appendChild(togglebutton);
itemBarDivider.append(" | ");
itemBarDivider.style.color = "#808080";

if (IsHidden == true) {

	sidebar.style.height = "0px";
	sidebar.style.width = "0px";
}

else if (IsHidden == false) {

	sidebar.style.height = "";
	sidebar.style.width = "";
}