Last active
March 18, 2016 01:25
-
-
Save pl12133/9882cad3212ef939c45b 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
| // A tiny script to move channels around on the DiscordApp.com chat servers. | |
| // | |
| // Open up your console and paste in all the functions | |
| // Then just call `moveChannelToTopByName` on the channel you want to pin to the top | |
| function getIndexOfChannelByName(channel) { | |
| var channelTextList = document.querySelectorAll('#guild-channels > ul:nth-child(2) span.channel-name') | |
| return [].slice.call(channelTextList) | |
| .map(elem => elem.innerHTML) | |
| .indexOf(channel) | |
| } | |
| function moveChannelToTop(index) { | |
| var channelList = document.querySelector('#guild-channels > ul:nth-child(2)') | |
| var channels = document.querySelectorAll('#guild-channels > ul:nth-child(2) > li') | |
| channelList | |
| .insertBefore( | |
| channelList.removeChild(channels[index]), | |
| channelList.childNodes[0] | |
| ) | |
| } | |
| function moveChannelToTopByName(channel) { | |
| moveChannelToTop(getIndexOfChannelByName(channel)) | |
| } | |
| // To move a single channel to the top: | |
| // moveChannelToTopByName('conferences') | |
| // To move multiple channels to the top: | |
| // Arrange your channels in the order that you want them to appear: | |
| var topChannels = ['general', 'random', 'jobs', 'need-help', 'news-and-links', 'editors', 'react-bootstrap', 'react-router', | |
| 'redux', 'testing', 'tooling', 'webpack']; | |
| topChannels.reverse().forEach(moveChannelToTopByName) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment