From a95ae491027d50cfbc3cd9ddd2304670b880d1df Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= <hugo@lysator.liu.se>
Date: Tue, 27 May 2025 17:19:16 +0200
Subject: [PATCH] Made reddit sidebar sticky.

---
 reddit-hide-sidebar/index.js | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/reddit-hide-sidebar/index.js b/reddit-hide-sidebar/index.js
index 4d8be6f..6a51376 100644
--- a/reddit-hide-sidebar/index.js
+++ b/reddit-hide-sidebar/index.js
@@ -1,7 +1,7 @@
 // ==UserScript==
 // @name         old.reddit hide sidebar
 // @namespace    http://hugo.hornquist.se
-// @version      1.2.1
+// @version      1.2.2
 // @description  Adds toggle to hide Reddit sidebar
 // @author       hugo@lysator.liu.se
 // @match        https://*.reddit.com/*
@@ -18,18 +18,32 @@
 
 	let btn = document.createElement('button');
 	let div = document.createElement('div');
+	let inner = document.createElement('div')
 	div.style = `
 	position: absolute;
 	z-index: 100;
 	left: -2em;
 	width: 2em;
-	height: 2em;
-	display: grid;
+	height: 100%;
 	top: 0;
 	padding: 0;
 	`
 
-	div.appendChild(btn);
+	inner.style = `
+	position: sticky;
+	top: 0;
+	height: 2em;
+	`
+
+	btn.style = `
+	width: 100%;
+	height: 100%;
+	display: grid;
+	place-items: center;
+	`
+
+	inner.appendChild(btn)
+	div.appendChild(inner);
 
 	let sidebar = document.getElementsByClassName('side')[0];
 	sidebar.appendChild(div);
@@ -66,7 +80,7 @@
 	style.innerText = `
 .side {
 	transition: 0.5s;
-		position: relative;
+	position: relative;
 }
 .side.hidden {
 	 width: 0px;
-- 
GitLab