Skip Navigation

1-Click Hide Post in Feed

A simple Tampermonkey script that adds a one-click hide button to posts on piefed.social (main feed). It uses PieFed’s native web route to hide posts and restores the scroll position after the page reloads. Needs: https://www.tampermonkey.net/ This is an independent, unofficial userscript. Made with ChatGPT. My personal motivation for making this: I prefer to use social media with an inbox zero approach. I want to hide everything that I have seen so that in the end my inbox is empty. (Voyager app has a nice swipe mechanism for this, but it doesn't use the hide feature of PieFed but rather remains local.)

 
if (!csrfMeta) {  
  alert("PieFed Hide: CSRF-Token nicht gefunden.");  
  return;  
}  

const form = document.createElement("form");  
form.method = "POST";  
form.action = `/post/${postId}/hide/yes`;  
form.style.display = "none";  

const tokenInput = document.createElement("input");  
tokenInput.type = "hidden";  
tokenInput.name = "csrf_token";  
tokenInput.value = csrfMeta.content;  

form.appendChild(tokenInput);  
document.body.appendChild(form);  

// Aktuelle Scrollposition vor dem Absenden speichern  
sessionStorage.setItem(  
  scrollKey,  
  String(window.scrollY)  
);  

form.submit();  

 
const match = teaser.id.match(/^post_(\d+)$/);  
if (!match) return;  

const optionsLink = teaser.querySelector(  
  ".post_options_link"  
);  
if (!optionsLink) return;  

const wrap = document.createElement("span");  
wrap.style.display = "inline-block";  
wrap.style.marginRight = "4px";  
wrap.title = "Diesen Beitrag vor mir verbergen";  

const link = document.createElement("a");  
link.href = "#";  
link.setAttribute(  
  "aria-label",  
  "Diesen Beitrag vor mir verbergen"  
);  
link.innerHTML =  
  `<span class="fe ${HIDE_ICON_CLASS}"></span>`;  

link.addEventListener("click", function (event) {  
  event.preventDefault();  
  event.stopPropagation();  

  hidePost(match[1]);  
});  

wrap.appendChild(link);  
optionsLink.insertBefore(wrap, optionsLink.firstChild);  

teaser.dataset.oneclickHideAdded = "1";  

Comments (5)