Revisions for ⁨bunkerchan scripts⁩

View the changes made to this paste.

unlisted ⁨4⁩ ⁨files⁩ 2020-04-07 16:23:57 UTC

unknown file

@@ -1,16 +0,0 @@

-// Fix watch button
-let fixWatch = function () {
-  let watcherButton = document.getElementById("watcherButton");
-  if (watcherButton) {
-    watcherButton.parentNode.removeChild(watcherButton.previousSibling);
-    watcherButton.parentNode.removeChild(watcherButton);
-    document.body.removeChild(watcher.watchedMenu);
-    let runWatchedThreadsCheck = watcher.runWatchedThreadsCheck;
-    watcher.runWatchedThreadsCheck = function () {
-      if (Date.now() - localStorage.lastWatchCheck >= 10000) runWatchedThreadsCheck();
-      else setTimeout(watcher.scheduleWatchedThreadsCheck, 10000);
-    };
-    watcher.init();
-  }
-};
-document.readyState === "loading" ? window.addEventListener("DOMContentLoaded", fixWatch) : fixWatch();

custom.css

@@ -2,6 +2,13 @@

 .divMessage {
   max-width: 80em;
 }
+/* Compact top bar */
+nav span,
+nav a {
+  margin: 0 -0.1em;
+  font-size: 11px;
+  display: inline-block;
+}
 /* Differentiate pdf/epub thumbnails */
 .uploadCell > a[href$=".pdf"]:before {
   content: "PDF";

custom.css

@@ -2,10 +2,14 @@

 .divMessage {
   max-width: 80em;
 }
-/* Differentiate pdf/epub thumbnails from webm/mp4 */
-.uploadCell a[href$=".pdf"] img,
-.uploadCell a[href$="epub+zip"] img {
-  filter: grayscale(100%);
+/* Differentiate pdf/epub thumbnails */
+.uploadCell > a[href$=".pdf"]:before {
+  content: "PDF";
+  display: block;
+}
+.uploadCell > a[href$="epub+zip"]:before {
+  content: "EPUB";
+  display: block;
 }
 /* Hide ugly green borders in default theme */
 #divLatestPosts .latestPostCell,

custom.css

@@ -39,12 +39,3 @@ button,

 .deletionCheckBox {
   display: none;
 }
-/* Hide SFW overboard */
-#navOverboardSFW,
-#navOverboardSFW + span {
-  display: none;
-}
-/* Reduce layout shift */
-.imgLink {
-  min-height: 120px;
-}

custom.css

@@ -46,5 +46,5 @@ button,

 }
 /* Reduce layout shift */
 .imgLink {
-  min-height: 200px;
+  min-height: 120px;
 }

unknown file

@@ -8,6 +8,7 @@ let fixWatch = function () {

     let runWatchedThreadsCheck = watcher.runWatchedThreadsCheck;
     watcher.runWatchedThreadsCheck = function () {
       if (Date.now() - localStorage.lastWatchCheck >= 10000) runWatchedThreadsCheck();
+      else setTimeout(watcher.scheduleWatchedThreadsCheck, 10000);
     };
     watcher.init();
   }

unknown file

@@ -5,10 +5,11 @@ let fixWatch = function () {

     watcherButton.parentNode.removeChild(watcherButton.previousSibling);
     watcherButton.parentNode.removeChild(watcherButton);
     document.body.removeChild(watcher.watchedMenu);
-    let scheduleWatchedThreadsCheck = watcher.scheduleWatchedThreadsCheck;
-    watcher.scheduleWatchedThreadsCheck = () => {};
+    let runWatchedThreadsCheck = watcher.runWatchedThreadsCheck;
+    watcher.runWatchedThreadsCheck = function () {
+      if (Date.now() - localStorage.lastWatchCheck >= 10000) runWatchedThreadsCheck();
+    };
     watcher.init();
-    watcher.scheduleWatchedThreadsCheck = scheduleWatchedThreadsCheck;
   }
 };
 document.readyState === "loading" ? window.addEventListener("DOMContentLoaded", fixWatch) : fixWatch();

last-read-auto-scroll.js

@@ -1,23 +1,23 @@

 // Store the last read post for each thread and scroll to it automatically
-if (location.pathname.indexOf('/res/') >= 0) {
+if (location.pathname.indexOf("/res/") >= 0) {
   let main = function () {
     let maxThreads = 300;
     let delay = 500;
-    let storageKey = 'lastRead';
+    let storageKey = "lastRead";
     let lastRead = JSON.parse(localStorage.getItem(storageKey)) || {};
     let highlighted = null;
     let scrollTimer = null;
-    let scrollContainer = document.getElementById('mainPanel');
+    let scrollContainer = document.getElementById("mainPanel");
 
     function highlight(post) {
-      if (highlighted) highlighted.style.borderBottom = '';
+      if (highlighted) highlighted.style.borderBottom = "";
       highlighted = post;
-      highlighted.style.borderBottom = 'dashed 1px #555';
+      highlighted.style.borderBottom = "dashed 1px #555";
     }
 
     function onScroll() {
       let scrollBottom = scrollContainer.scrollTop + scrollContainer.offsetHeight;
-      let posts = document.getElementsByClassName('postCell');
+      let posts = document.getElementsByClassName("postCell");
       let lastReadPost = null;
       for (let post of posts) {
         if (post.offsetTop + post.offsetHeight > scrollBottom) break;

@@ -40,22 +40,22 @@ if (location.pathname.indexOf('/res/') >= 0) {

       }
     }
 
-    scrollContainer.addEventListener('scroll', () => {
+    scrollContainer.addEventListener("scroll", () => {
       if (scrollTimer) clearTimeout(scrollTimer);
       scrollTimer = setTimeout(onScroll, delay);
     });
 
-    window.addEventListener('storage', (event) => {
+    window.addEventListener("storage", (event) => {
       if (event.key === storageKey) lastRead = JSON.parse(event.newValue) || {};
     });
 
-    let refreshButton = document.getElementById('refreshButton');
+    let refreshButton = document.getElementById("refreshButton");
     if (refreshButton)
-      refreshButton.addEventListener('click', () => {
-        let posts = document.getElementsByClassName('postCell');
+      refreshButton.addEventListener("click", () => {
+        let posts = document.getElementsByClassName("postCell");
         if (posts.length) highlight(posts[posts.length - 1]);
       });
   };
 
-  document.readyState === 'complete' ? main() : window.addEventListener('load', main);
-}
+  document.readyState === "loading" ? window.addEventListener("DOMContentLoaded", main) : main();
+}
\ No newline at end of file

custom.css

@@ -3,8 +3,8 @@

   max-width: 80em;
 }
 /* Differentiate pdf/epub thumbnails from webm/mp4 */
-.uploadCell a[href$='.pdf'] img,
-.uploadCell a[href$='epub+zip'] img {
+.uploadCell a[href$=".pdf"] img,
+.uploadCell a[href$="epub+zip"] img {
   filter: grayscale(100%);
 }
 /* Hide ugly green borders in default theme */

@@ -26,8 +26,8 @@ textarea,

 .floatingMenu,
 #settingsFieldset,
 .reportFieldset,
-input[type='button'],
-input[type='submit'],
+input[type="button"],
+input[type="submit"],
 button,
 .dropzone,
 .selectedCell,

@@ -35,3 +35,16 @@ button,

 .modalTableBody th {
   border-color: #444;
 }
+/* Hide checkbox on posts */
+.deletionCheckBox {
+  display: none;
+}
+/* Hide SFW overboard */
+#navOverboardSFW,
+#navOverboardSFW + span {
+  display: none;
+}
+/* Reduce layout shift */
+.imgLink {
+  min-height: 200px;
+}

unknown file

@@ -1,31 +1,14 @@

 // Fix watch button
 let fixWatch = function () {
-  if (watcher) {
-    watcher.isInThread = !!document.getElementById("threadIdentifier");
-    for (let op of document.getElementsByClassName("innerOP")) {
-      if (!op.getElementsByClassName("watchButton")[0]) watcher.processOP(op);
-    }
-    draggable.setDraggable(watcher.watchedMenu, watcher.watchedMenu.firstChild);
-    if (watcher.isInThread) {
-      let storedWatchedData = watcher.getStoredWatchedData();
-      for (let board of Object.keys(storedWatchedData)) {
-        let threads = storedWatchedData[board];
-        for (let threadId of Object.keys(threads)) {
-          if (board == api.boardUri && threadId == api.threadId) {
-            let thread = threads[threadId];
-            if (thread.lastSeen < thread.lastReplied) {
-              thread.lastSeen = Date.now();
-              localStorage.watchedData = JSON.stringify(storedWatchedData);
-              watcher.elementRelation[board][threadId].style.display = "none";
-              watcher.watcherAlertCounter--;
-              watcher.updateWatcherCounter();
-            }
-            return;
-          }
-        }
-      }
-    }
+  let watcherButton = document.getElementById("watcherButton");
+  if (watcherButton) {
+    watcherButton.parentNode.removeChild(watcherButton.previousSibling);
+    watcherButton.parentNode.removeChild(watcherButton);
+    document.body.removeChild(watcher.watchedMenu);
+    let scheduleWatchedThreadsCheck = watcher.scheduleWatchedThreadsCheck;
+    watcher.scheduleWatchedThreadsCheck = () => {};
+    watcher.init();
+    watcher.scheduleWatchedThreadsCheck = scheduleWatchedThreadsCheck;
   }
 };
-
 document.readyState === "loading" ? window.addEventListener("DOMContentLoaded", fixWatch) : fixWatch();

unknown file

@@ -1,24 +1,27 @@

 // Fix watch button
 let fixWatch = function () {
   if (watcher) {
-    watcher.isInThread = document.getElementById("threadIdentifier") ? true : false;
+    watcher.isInThread = !!document.getElementById("threadIdentifier");
     for (let op of document.getElementsByClassName("innerOP")) {
       if (!op.getElementsByClassName("watchButton")[0]) watcher.processOP(op);
     }
     draggable.setDraggable(watcher.watchedMenu, watcher.watchedMenu.firstChild);
-    let storedWatchedData = watcher.getStoredWatchedData();
-    for (let board of Object.keys(storedWatchedData)) {
-      let threads = storedWatchedData[board];
-      for (let thread of Object.keys(threads)) {
-        if (watcher.isInThread && board == api.boardUri && thread == api.threadId) {
-          if (threads[thread].lastSeen < threads[thread].lastReplied) {
-            threads[thread].lastSeen = new Date().getTime();
-            localStorage.watchedData = JSON.stringify(storedWatchedData);
-            watcher.elementRelation[board][thread].style.display = "none";
-            watcher.watcherAlertCounter--;
-            watcher.updateWatcherCounter();
+    if (watcher.isInThread) {
+      let storedWatchedData = watcher.getStoredWatchedData();
+      for (let board of Object.keys(storedWatchedData)) {
+        let threads = storedWatchedData[board];
+        for (let threadId of Object.keys(threads)) {
+          if (board == api.boardUri && threadId == api.threadId) {
+            let thread = threads[threadId];
+            if (thread.lastSeen < thread.lastReplied) {
+              thread.lastSeen = Date.now();
+              localStorage.watchedData = JSON.stringify(storedWatchedData);
+              watcher.elementRelation[board][threadId].style.display = "none";
+              watcher.watcherAlertCounter--;
+              watcher.updateWatcherCounter();
+            }
+            return;
           }
-          return;
         }
       }
     }

unknown file

@@ -1,7 +1,27 @@

 // Fix watch button
 let fixWatch = function () {
-  for (let op of document.getElementsByClassName("innerOP")) {
-    if (watcher && !op.getElementsByClassName("watchButton")[0]) watcher.processOP(op);
+  if (watcher) {
+    watcher.isInThread = document.getElementById("threadIdentifier") ? true : false;
+    for (let op of document.getElementsByClassName("innerOP")) {
+      if (!op.getElementsByClassName("watchButton")[0]) watcher.processOP(op);
+    }
+    draggable.setDraggable(watcher.watchedMenu, watcher.watchedMenu.firstChild);
+    let storedWatchedData = watcher.getStoredWatchedData();
+    for (let board of Object.keys(storedWatchedData)) {
+      let threads = storedWatchedData[board];
+      for (let thread of Object.keys(threads)) {
+        if (watcher.isInThread && board == api.boardUri && thread == api.threadId) {
+          if (threads[thread].lastSeen < threads[thread].lastReplied) {
+            threads[thread].lastSeen = new Date().getTime();
+            localStorage.watchedData = JSON.stringify(storedWatchedData);
+            watcher.elementRelation[board][thread].style.display = "none";
+            watcher.watcherAlertCounter--;
+            watcher.updateWatcherCounter();
+          }
+          return;
+        }
+      }
+    }
   }
 };
 

unknown file

@@ -1,8 +1,8 @@

 // Fix watch button
 let fixWatch = function () {
-  for (let op of document.getElementsByClassName('innerOP')) {
-    if (watcher && !op.getElementsByClassName('watchButton')[0]) watcher.processOP(op);
+  for (let op of document.getElementsByClassName("innerOP")) {
+    if (watcher && !op.getElementsByClassName("watchButton")[0]) watcher.processOP(op);
   }
 };
 
-document.readyState === 'complete' ? fixWatch() : window.addEventListener('load', fixWatch);
+document.readyState === "loading" ? window.addEventListener("DOMContentLoaded", fixWatch) : fixWatch();

redirect-to-catalog.js

@@ -1,3 +1,3 @@

 if (/^\/\w+\/?$/.test(location.pathname) && !/overboard/.test(location.pathname)) {
-  location.href = 'catalog.html';
+  location.replace('catalog.html');
 }

redirect-to-catalog.js

@@ -0,0 +1,3 @@

+if (/^\/\w+\/?$/.test(location.pathname) && !/overboard/.test(location.pathname)) {
+  location.href = 'catalog.html';
+}

unknown file

@@ -1,7 +1,7 @@

 // Fix watch button
 let fixWatch = function () {
   for (let op of document.getElementsByClassName('innerOP')) {
-    if (!op.getElementsByClassName('watchButton')[0]) watcher.processOP(op);
+    if (watcher && !op.getElementsByClassName('watchButton')[0]) watcher.processOP(op);
   }
 };
 

last-read-auto-scroll.js

@@ -9,14 +9,6 @@ if (location.pathname.indexOf('/res/') >= 0) {

     let scrollTimer = null;
     let scrollContainer = document.getElementById('mainPanel');
 
-    if (lastRead[location.pathname]) {
-      let lastReadPost = document.getElementById(lastRead[location.pathname]);
-      if (lastReadPost) {
-        highlight(lastReadPost);
-        if (!location.hash) lastReadPost.scrollIntoView();
-      }
-    }
-
     function highlight(post) {
       if (highlighted) highlighted.style.borderBottom = '';
       highlighted = post;

@@ -40,6 +32,14 @@ if (location.pathname.indexOf('/res/') >= 0) {

       }
     }
 
+    if (lastRead[location.pathname]) {
+      let lastReadPost = document.getElementById(lastRead[location.pathname]);
+      if (lastReadPost) {
+        highlight(lastReadPost);
+        if (!location.hash) lastReadPost.scrollIntoView();
+      }
+    }
+
     scrollContainer.addEventListener('scroll', () => {
       if (scrollTimer) clearTimeout(scrollTimer);
       scrollTimer = setTimeout(onScroll, delay);

unknown file

@@ -1,8 +1,8 @@

 // Fix watch button
 let fixWatch = function () {
-	for (let op of document.getElementsByClassName('innerOP')) {
-		if (!op.getElementsByClassName('watchButton')[0]) watcher.processOP(op);
-	}
+  for (let op of document.getElementsByClassName('innerOP')) {
+    if (!op.getElementsByClassName('watchButton')[0]) watcher.processOP(op);
+  }
 };
- 
+
 document.readyState === 'complete' ? fixWatch() : window.addEventListener('load', fixWatch);

last-read-auto-scroll.js

@@ -1,61 +1,61 @@

 // Store the last read post for each thread and scroll to it automatically
 if (location.pathname.indexOf('/res/') >= 0) {
-	let main = function () {
-		let maxThreads = 300;
-		let delay = 500;
-		let storageKey = 'lastRead';
-		let lastRead = JSON.parse(localStorage.getItem(storageKey)) || {};
-		let highlighted = null;
-		let scrollTimer = null;
-		let scrollContainer = document.getElementById('mainPanel');
- 
-		if (lastRead[location.pathname]) {
-			let lastReadPost = document.getElementById(lastRead[location.pathname]);
-			if (lastReadPost) {
-				highlight(lastReadPost);
-				if (!location.hash) lastReadPost.scrollIntoView();
-			}
-		}
- 
-		function highlight(post) {
-			if (highlighted) highlighted.style.borderBottom = '';
-			highlighted = post;
-			highlighted.style.borderBottom = 'dashed 1px #555';
-		}
- 
-		function onScroll() {
-			let scrollBottom = scrollContainer.scrollTop + scrollContainer.offsetHeight;
-			let posts = document.getElementsByClassName('postCell');
-			let lastReadPost = null;
-			for (let post of posts) {
-				if (post.offsetTop + post.offsetHeight > scrollBottom) break;
-				lastReadPost = post;
-			}
-			if (lastReadPost) {
-				delete lastRead[location.pathname];
-				lastRead[location.pathname] = Number(lastReadPost.id);
-				let keys = Object.keys(lastRead);
-				if (keys.length > maxThreads) delete lastRead[keys[0]];
-				localStorage.setItem(storageKey, JSON.stringify(lastRead));
-			}
-		}
- 
-		scrollContainer.addEventListener('scroll', () => {
-			if (scrollTimer) clearTimeout(scrollTimer);
-			scrollTimer = setTimeout(onScroll, delay);
-		});
- 
-		window.addEventListener('storage', (event) => {
-			if (event.key === storageKey) lastRead = JSON.parse(event.newValue) || {};
-		});
- 
-		let refreshButton = document.getElementById('refreshButton');
-		if (refreshButton)
-			refreshButton.addEventListener('click', () => {
-				let posts = document.getElementsByClassName('postCell');
-				if (posts.length) highlight(posts[posts.length - 1]);
-			});
-	};
- 
-	document.readyState === 'complete' ? main() : window.addEventListener('load', main);
+  let main = function () {
+    let maxThreads = 300;
+    let delay = 500;
+    let storageKey = 'lastRead';
+    let lastRead = JSON.parse(localStorage.getItem(storageKey)) || {};
+    let highlighted = null;
+    let scrollTimer = null;
+    let scrollContainer = document.getElementById('mainPanel');
+
+    if (lastRead[location.pathname]) {
+      let lastReadPost = document.getElementById(lastRead[location.pathname]);
+      if (lastReadPost) {
+        highlight(lastReadPost);
+        if (!location.hash) lastReadPost.scrollIntoView();
+      }
+    }
+
+    function highlight(post) {
+      if (highlighted) highlighted.style.borderBottom = '';
+      highlighted = post;
+      highlighted.style.borderBottom = 'dashed 1px #555';
+    }
+
+    function onScroll() {
+      let scrollBottom = scrollContainer.scrollTop + scrollContainer.offsetHeight;
+      let posts = document.getElementsByClassName('postCell');
+      let lastReadPost = null;
+      for (let post of posts) {
+        if (post.offsetTop + post.offsetHeight > scrollBottom) break;
+        lastReadPost = post;
+      }
+      if (lastReadPost) {
+        delete lastRead[location.pathname];
+        lastRead[location.pathname] = Number(lastReadPost.id);
+        let keys = Object.keys(lastRead);
+        if (keys.length > maxThreads) delete lastRead[keys[0]];
+        localStorage.setItem(storageKey, JSON.stringify(lastRead));
+      }
+    }
+
+    scrollContainer.addEventListener('scroll', () => {
+      if (scrollTimer) clearTimeout(scrollTimer);
+      scrollTimer = setTimeout(onScroll, delay);
+    });
+
+    window.addEventListener('storage', (event) => {
+      if (event.key === storageKey) lastRead = JSON.parse(event.newValue) || {};
+    });
+
+    let refreshButton = document.getElementById('refreshButton');
+    if (refreshButton)
+      refreshButton.addEventListener('click', () => {
+        let posts = document.getElementsByClassName('postCell');
+        if (posts.length) highlight(posts[posts.length - 1]);
+      });
+  };
+
+  document.readyState === 'complete' ? main() : window.addEventListener('load', main);
 }

unknown file

@@ -0,0 +1,8 @@

+// Fix watch button
+let fixWatch = function () {
+	for (let op of document.getElementsByClassName('innerOP')) {
+		if (!op.getElementsByClassName('watchButton')[0]) watcher.processOP(op);
+	}
+};
+ 
+document.readyState === 'complete' ? fixWatch() : window.addEventListener('load', fixWatch);

last-read-auto-scroll.js

@@ -0,0 +1,61 @@

+// Store the last read post for each thread and scroll to it automatically
+if (location.pathname.indexOf('/res/') >= 0) {
+	let main = function () {
+		let maxThreads = 300;
+		let delay = 500;
+		let storageKey = 'lastRead';
+		let lastRead = JSON.parse(localStorage.getItem(storageKey)) || {};
+		let highlighted = null;
+		let scrollTimer = null;
+		let scrollContainer = document.getElementById('mainPanel');
+ 
+		if (lastRead[location.pathname]) {
+			let lastReadPost = document.getElementById(lastRead[location.pathname]);
+			if (lastReadPost) {
+				highlight(lastReadPost);
+				if (!location.hash) lastReadPost.scrollIntoView();
+			}
+		}
+ 
+		function highlight(post) {
+			if (highlighted) highlighted.style.borderBottom = '';
+			highlighted = post;
+			highlighted.style.borderBottom = 'dashed 1px #555';
+		}
+ 
+		function onScroll() {
+			let scrollBottom = scrollContainer.scrollTop + scrollContainer.offsetHeight;
+			let posts = document.getElementsByClassName('postCell');
+			let lastReadPost = null;
+			for (let post of posts) {
+				if (post.offsetTop + post.offsetHeight > scrollBottom) break;
+				lastReadPost = post;
+			}
+			if (lastReadPost) {
+				delete lastRead[location.pathname];
+				lastRead[location.pathname] = Number(lastReadPost.id);
+				let keys = Object.keys(lastRead);
+				if (keys.length > maxThreads) delete lastRead[keys[0]];
+				localStorage.setItem(storageKey, JSON.stringify(lastRead));
+			}
+		}
+ 
+		scrollContainer.addEventListener('scroll', () => {
+			if (scrollTimer) clearTimeout(scrollTimer);
+			scrollTimer = setTimeout(onScroll, delay);
+		});
+ 
+		window.addEventListener('storage', (event) => {
+			if (event.key === storageKey) lastRead = JSON.parse(event.newValue) || {};
+		});
+ 
+		let refreshButton = document.getElementById('refreshButton');
+		if (refreshButton)
+			refreshButton.addEventListener('click', () => {
+				let posts = document.getElementsByClassName('postCell');
+				if (posts.length) highlight(posts[posts.length - 1]);
+			});
+	};
+ 
+	document.readyState === 'complete' ? main() : window.addEventListener('load', main);
+}

uncheck-auto-refresh.js

@@ -0,0 +1,3 @@

+// Uncheck autorefresh
+let autorefresh = document.getElementById('checkboxChangeRefresh');
+if (autorefresh && autorefresh.checked) autorefresh.click();

custom.css

@@ -0,0 +1,37 @@

+/* Better readability on wide screens */
+.divMessage {
+  max-width: 80em;
+}
+/* Differentiate pdf/epub thumbnails from webm/mp4 */
+.uploadCell a[href$='.pdf'] img,
+.uploadCell a[href$='epub+zip'] img {
+  filter: grayscale(100%);
+}
+/* Hide ugly green borders in default theme */
+#divLatestPosts .latestPostCell,
+.innerPost,
+.sideCatalogCell,
+.markedPost,
+.sideCatalogMarkedCell,
+.catalogCell {
+  border: none;
+}
+hr,
+input,
+select,
+textarea,
+#newPostFieldset,
+#quick-reply table,
+.modalDecorationPanel,
+.floatingMenu,
+#settingsFieldset,
+.reportFieldset,
+input[type='button'],
+input[type='submit'],
+button,
+.dropzone,
+.selectedCell,
+#postingForm th,
+.modalTableBody th {
+  border-color: #444;
+}