Last active
June 13, 2021 10:18
-
-
Save rvause/5582a2b52ec7e0b02c6b5a5079c224ab to your computer and use it in GitHub Desktop.
Toggle server bar in Discord client
This file contains 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
function show() { | |
document.querySelector(".guilds-1SWlCJ") | |
.style = "display: inherit;" | |
window.serverBar.isVisible = true; | |
} | |
function hide() { | |
document.querySelector(".guilds-1SWlCJ") | |
.style = "display: none;" | |
window.serverBar.isVisible = false; | |
} | |
function createToggle() { | |
document.querySelectorAll(".serverBarToggle").forEach((e) => e.remove()); | |
const el = document.createElement("span"); | |
el.innerHTML = "<>"; | |
el.className = "serverBarToggle"; | |
el.style = "position: absolute; bottom: 10px; left: 10px; font-size: 24px; color: white; background: #333; padding: 8px 12px; border-radius: 10px; z-index: 9999; cursor: ew-resize;" | |
document.body.appendChild(el); | |
el.addEventListener("click", serverBar.toggle); | |
return el; | |
} | |
function toggle() { | |
if (window.serverBar.isVisible) { | |
window.serverBar.hide(); | |
} else { | |
window.serverBar.show(); | |
} | |
} | |
window.serverBar = { | |
show, | |
hide, | |
createToggle, | |
toggle, | |
isVisible: true, | |
}; | |
window.serverBar.createToggle(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment