forked from v-qu/discord-channel-collapse-button
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannelcollapsebutton.plugin.js
55 lines (51 loc) · 2.89 KB
/
channelcollapsebutton.plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//META{"name":"channelCollapseButton"}*//
function channelCollapseButton(){};
channelCollapseButton.prototype.addToolbarItem = function(){
if(document.querySelectorAll('.show-channels-button').length == 0) {
var newToolbarItem = document.createElement('button');
newToolbarItem.type = 'button';
newToolbarItem.classList.add('show-channels-button');
newToolbarItem.classList.add('active');
newToolbarItem.innerHTML = '<span style="display: block; color: #fefefe; -webkit-transform: scale(2.0, 1.0); -moz-transform:scale(2.0, 1.0); -ms-transform:scale(2.0, 1.0); -o-transform:scale(2.0, 1.0); transform: scale(6,1); width: 0; height: 5px; text-align: center; position: absolute; top: 1px; left: 0;">-</span><span style="display: block; color: #fefefe; -webkit-transform: scale(2.0, 1.0); -moz-transform:scale(2.0, 1.0); -ms-transform:scale(2.0, 1.0); -o-transform:scale(2.0, 1.0); transform: scale(6,1); width: 0; height: 5px; position: absolute; top: 6px; left: 0;">-</span><span style="display: block; color: #fefefe; -webkit-transform: scale(2.0, 1.0); -moz-transform:scale(2.0, 1.0); -ms-transform:scale(2.0, 1.0); -o-transform:scale(2.0, 1.0); transform: scale(6,1); width: 0; height: 5px; position: absolute; top: 11px; left: 0;">-</span>';
document.querySelector('.header-toolbar').insertBefore(newToolbarItem,document.querySelector('.header-toolbar div.separator'));
document.querySelector('.show-channels-button').addEventListener('click',function(e){
if(this.classList.contains('active')) {
document.querySelector('.channels-wrap').style.display = 'none';
this.classList.toggle('active');
} else {
document.querySelector('.channels-wrap').style.display = 'flex';
this.classList.toggle('active');
}
});
}
}
channelCollapseButton.prototype.getName = function(){
return "Channel Collapse Button";
};
channelCollapseButton.prototype.getDescription = function(){
return "Create a button that allows for hiding of channel list";
};
channelCollapseButton.prototype.getVersion = function(){
return "1.0.0";
};
channelCollapseButton.prototype.getAuthor = function(){
return "DeNial";
};
channelCollapseButton.prototype.start = function(){
this.addToolbarItem();
console.log("channelCollapseButton loaded");
};
channelCollapseButton.prototype.stop = function(){
if(document.querySelectorAll('.show-channels-button').length) {
document.querySelector('.show-channels-button').outerHTML = "";
delete document.querySelector('.show-channels-button');
}
document.querySelector('.channels-wrap').style.display = 'flex';
console.log("channelCollapseButton unloaded");
};
channelCollapseButton.prototype.load = function(){
this.addToolbarItem();
};
channelCollapseButton.prototype.onSwitch = function(){
this.addToolbarItem();
}