-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (31 loc) · 1.08 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
const { Plugin } = require('powercord/entities');
const { getModuleByDisplayName } = require('powercord/webpack');
const { inject, uninject } = require('powercord/injector');
const { sleep, waitFor } = require('powercord/util');
module.exports = class PendingDefault extends Plugin {
startPlugin() {
// Use injectId to not repeat
this.injectId = 'pendingDefault';
// Keep track of one shot
this.hasChangedSelected = false;
this.patchTabBar();
}
async patchTabBar() {
const TabBar = getModuleByDisplayName('TabBar', false);
inject(this.injectId, TabBar.prototype, 'render', (_, res) => {
// Only select once
if (this.hasChangedSelected) return res;
this.hasChangedSelected = true;
(async () => {
// Wait for selected online element
await waitFor(`.tabBar-ZmDY9v.topPill-30KHOu > .item-3HknzM.selected-3s45Ha[data-item-id="ONLINE"]`);
// Select pending instead
res._owner.memoizedProps.onItemSelect('PENDING');
})();
return res;
});
}
pluginWillUnload() {
uninject(this.injectId);
}
}