-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
55 lines (47 loc) 路 1.27 KB
/
index.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
const { Plugin } = require('powercord/entities');
const { React, getModule } = require('powercord/webpack');
const Settings = require('./components/Settings.jsx');
module.exports = class MinimizeShortcut extends Plugin {
constructor() {
super();
this._eventRegisterId = -1;
}
async startPlugin() {
powercord.api.settings.registerSettings(this.entityID, {
category: this.entityID,
label: 'Minimize Shortcut',
render: Settings, // currently does not work because we need the keycodes, not the actual name of the key.
});
this._window = await getModule(['minimize', 'focus']);
this._discordUtilities = await getModule([
'inputEventRegister',
'inputEventUnregister',
]);
// register the key event
this._discordUtilities.inputEventRegister(
(this._eventRegisterId = new Date().getTime()),
[
[0, 162], // Ctrl
[0, 89], // Y
],
this._toggleWindow.bind(this),
{
blurred: true,
focused: true,
keydown: true,
}
);
}
_toggleWindow() {
if (document.hidden) {
this._window.focus(true, true);
return;
}
this._window.minimize();
}
pluginWillUnload() {
powercord.api.settings.unregisterSettings(this.entityID);
// does not work yet
this._discordUtilities.inputEventUnregister(this._eventRegisterId);
}
};