Created
May 7, 2018 14:16
-
-
Save disjukr/9ef2980a40629d460a536333b88c2f45 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
// ==UserScript== | |
// @name discord-mini | |
// @namespace http://0xabcdef.com/discord-mini | |
// @version 0.0.1 | |
// @description 디스코드 방목록이랑 유저목록 가리고싶엉 | |
// @author JongChan Choi <[email protected]> | |
// @match https://discordapp.com/channels/* | |
// @grant none | |
// ==/UserScript== | |
(async () => { | |
await wait('.content'); | |
const guildsScroller = document.querySelector('.guilds.scroller'); | |
const guildsWrapper = document.querySelector('.guilds-wrapper'); | |
const layout = guildsWrapper.nextElementSibling.lastElementChild; | |
const roomsSideBar = layout.firstElementChild; | |
const usersSideBar = layout.lastElementChild.querySelector('.content').lastElementChild; | |
const toggleRoomsButton = button('방목록', toggle(roomsSideBar)); | |
const toggleUsersButton = button('유저목록', toggle(usersSideBar)); | |
guildsScroller.appendChild(toggleRoomsButton); | |
guildsScroller.appendChild(toggleUsersButton); | |
function button(textContent, onclick) { | |
const element = document.createElement('button'); | |
Object.assign(element, { textContent, onclick }); | |
return element; | |
} | |
function toggle(element) { | |
return () => element.style.display = element.style.display === 'none' ? 'initial' : 'none'; | |
} | |
function wait(selector) { | |
return new Promise(resolve => { | |
const id = setInterval(() => { | |
if (document.querySelector(selector) != null) { | |
clearInterval(id); | |
resolve(); | |
} | |
}, 100); | |
}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment