Skip to content

Instantly share code, notes, and snippets.

@corbob
Last active July 13, 2020 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corbob/a1432f10f2c720160f7d8f57aa8b968e to your computer and use it in GitHub Desktop.
Save corbob/a1432f10f2c720160f7d8f57aa8b968e to your computer and use it in GitHub Desktop.
// 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