summaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2021-08-16 23:01:35 +0200
committernea <romangraef@gmail.com>2021-08-16 23:01:35 +0200
commit73d29ebbcca1e1e00ad54b7a2f43982dad81e1c2 (patch)
treef440e76faf1ec2aa98244775be2a679723a434de /index.js
downloadpowercord-timezone-73d29ebbcca1e1e00ad54b7a2f43982dad81e1c2.tar.gz
powercord-timezone-73d29ebbcca1e1e00ad54b7a2f43982dad81e1c2.tar.bz2
powercord-timezone-73d29ebbcca1e1e00ad54b7a2f43982dad81e1c2.zip
Initial commit
Diffstat (limited to 'index.js')
-rw-r--r--index.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..7cb98dd
--- /dev/null
+++ b/index.js
@@ -0,0 +1,43 @@
+const { Plugin } = require('powercord/entities');
+const Settings = require('./Settings.jsx');
+const manifest = require('./manifest.json');
+const { getModule } = require('powercord/webpack');
+const {
+ inject,
+ uninject
+} = require('powercord/injector');
+const { lookup } = require('./tz');
+
+const { transformMessageArray } = require('./transformation.jsx');
+
+const PLUGIN_ID = 'timezone-powercord';
+const INJECTION_ID_MESSAGE_RENDER = PLUGIN_ID + '-message-render';
+
+const MessageContent = getModule((m) => m.type && m.type.displayName === 'MessageContent', false);
+
+
+module.exports = class TimezonePowercord extends Plugin {
+ async startPlugin () {
+ inject(INJECTION_ID_MESSAGE_RENDER, MessageContent, 'type', (args) => {
+ let x = transformMessageArray(
+ () => lookup(this.settings.get('timezone', 'GMT')))(args);
+ console.log(x);
+ return x;
+ }, true);
+ powercord.api.notices.sendAnnouncement('timezone-request-tz', {
+ color: 'green',
+ message: 'Timezone Powercord Plugin has been loaded.'
+ });
+ powercord.api.settings.registerSettings(PLUGIN_ID, {
+ category: this.entityID,
+ label: 'Timezone Powercord Plugin',
+ render: Settings
+ });
+ }
+
+ async pluginWillUnload () {
+ uninject(INJECTION_ID_MESSAGE_RENDER);
+ powercord.api.settings.unregisterSettings(this.entityID);
+ }
+
+};