// ==UserScript==// @name Mark Post As (You) on 8chanmoe// @namespace pcgia// @description Mark a post as (You) on 8chanmoe// @match https://8chan.moe/*/res/*// @match https://8chan.se/*/res/*// @grant none// @run-at document-end// @author Starknight// @version 1.0.0// ==/UserScript==constaddYouButton=function(postCell){constextraMenuButton=postCell.querySelector('.innerPost label.extraMenuButton');if(!extraMenuButton){console.error('I can\'t find this post\'s menu buttons :(');returnfalse;}constyouButton=document.createElement('label');youButton.classList.add('pcgiaYouButton','glowOnHover','coloredIcon');youButton.title='Mark this post as (You)';constmarkPostAsYou=function(event){constpostCell=event.target.parentNode.parentNode.parentNode;constpostId=parseInt(postCell.id);constboardName=document.getElementById('boardIdentifier').value;constkey=boardName+'-yous';letallYous=JSON.parse(localStorage.getItem(key))||[];allYous.push(postId);allYous.sort();allYous=allYous.filter((e,i,a)=>a.indexOf(e)===i);localStorage.setItem(key,JSON.stringify(allYous));constquoteLinks=Array.from(document.querySelectorAll('a.quoteLink'));for(quoteofquoteLinks){if('>>'+postId===quote.innerText){quote.classList.add('you');}}constpostName=postCell.querySelector('.linkName');if(postName){postName.classList.add('youName');}};youButton.addEventListener('click',markPostAsYou);extraMenuButton.after(youButton);returntrue;};constpostCells=Array.from(document.querySelectorAll('div.postCell'));for(letpostCellofpostCells){addYouButton(postCell);}constallPosts=document.querySelector('#threadList .divPosts');if(allPosts){constmutationObserver=newMutationObserver((changes,self)=>{for(changeofchanges){for(nodeofchange.addedNodes){addYouButton(node);}}});mutationObserver.observe(allPosts,{attributes:false,childList:true,subtree:false});}constthisCss=`.innerPost label.pcgiaYouButton::before { content: '\\e0A5';}`constthisStyle=document.createElement('style');thisStyle.innerText=thisCss;document.head.appendChild(thisStyle);
Warning
LINK
You are about to visit a link which has been flagged with the above content warnings. Do you wish to continue?