Skip to content

Instantly share code, notes, and snippets.

@corbob
Last active Jul 13, 2020
Embed
What would you like to do?
// Put the contents of this gist into any js file within "C:\Users\<user>\AppData\Roaming\discord\0.0.306\modules\"
// I put it in "C:\Users\<username>\AppData\Roaming\discord\0.0.306\modules\discord_dispatch\index.js"
const sb = document.querySelector('[class^="sidebar-"]');
const sbWidth = sb.style.width;
function toggleHide() {
if (sb.style.width === sbWidth) {
sb.style.width = "0"
} else {
sb.style.width = sbWidth
}
}
function markAllRead() {
document.querySelector('[aria-label="Inbox"]').click();
document.querySelector('[aria-label="Mark Inbox As Read"]').click();
const butts = document.getElementsByTagName('button')
for (let i = 0; i < butts.length; i++) {
if (butts[i].type === 'submit') {
butts[i].click();
}
}
}
const servers = document.querySelector('[aria-label="Servers"]')
const myContainer = servers.insertAdjacentElement('beforebegin', document.createElement('div'));
myContainer.style = "padding: 10px;"
const markRead = myContainer.appendChild(document.createElement('span'))
markRead.innerText = '✅';
markRead.addEventListener("click", markAllRead);
const hideChannels = myContainer.appendChild(document.createElement('span'))
hideChannels.innerText = '🐱‍🐉';
hideChannels.addEventListener("click", toggleHide);
document.addEventListener("keypress", (e) => {
console.log(e.keyCode);
if(e.ctrlKey && e.keyCode === 17 && e.shiftKey){
markAllRead();
}
if(e.ctrlKey && e.keyCode === 2 && e.shiftKey){
toggleHide();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment