--- /dev/null
+// ==UserScript==
+// @name dfde-singlepage
+// @namespace de.debianforum
+// @version 0.1
+// @description View all pages of a thread on one page
+// @author You
+// @match https://debianforum.de/forum/viewtopic.php*t=*
+// @icon https://www.google.com/s2/favicons?sz=64&domain=debianforum.de
+// @grant none
+// ==/UserScript==
+
+(function() {
+ 'use strict';
+ const pages = [...document.querySelector(".pagination").querySelectorAll("li")]
+ .map((p) => parseInt(p.innerText))
+ .filter(n => !isNaN(n))
+ .slice(-1)[0];
+
+ const thread_id = window.location.search.match(/t=[0-9]+/);
+ const unsuitable = window.location.search.match(/p=[0-9]+|start=/);
+
+ const pageBody = document.querySelector("#page-body");
+ const pageBar = pageBody.querySelector(".action-bar.bar-bottom");
+
+ const myButton = document.createElement("li")
+ const myButton_a = document.createElement("a")
+ myButton_a.className = "button";
+ myButton_a.innerText = "∞";
+
+ myButton.appendChild(myButton_a)
+ document.querySelector(".pagination ul").prepend(myButton);
+
+ function clickit() {
+ if (unsuitable) { window.location.href= "https://debianforum.de/forum/viewtopic.php?" + thread_id; }
+ let promises = []
+
+ // async wrapper to fix the order of requests/posts
+ const fn = async() => {
+ for (var p=1; p<pages; p++) {
+ const url = "https://debianforum.de/forum/viewtopic.php?" + thread_id + "&start=" + p*15;
+
+ promises.push(
+ fetch(url)
+ .then(xhr => xhr.text())
+ .then(htmlstring => {
+ const d = document.createElement('div');
+ d.innerHTML = htmlstring.trim();
+ return d
+ })
+ .then(d => d.querySelectorAll("#page-body .post"))
+ );
+
+ }
+ await Promise.all(promises)
+ .then(nodelist => nodelist.forEach(posts => posts.forEach(post => pageBody.insertBefore(post, pageBar))));
+ }
+ fn();
+
+ document.querySelectorAll(".pagination li a").forEach((pg, idx) => {
+ if(idx > 0 && pg.innerHTML.match(/[0-9]+/))
+ pg.style.backgroundColor = "#d70751";
+ pg.style.color = "#fff";
+ })
+ }
+ myButton.addEventListener("click", clickit);
+})();
+