Last active
July 13, 2020 00:59
-
-
Save corbob/a1432f10f2c720160f7d8f57aa8b968e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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