mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Make clicking notifications focus ArmCord (#262)
This commit is contained in:
parent
ed775cbf31
commit
a4968e7529
1 changed files with 20 additions and 4 deletions
|
@ -45,13 +45,13 @@ if (window.location.href.indexOf("splash.html") > -1) {
|
||||||
addScript(`
|
addScript(`
|
||||||
const dispatch = (() => {
|
const dispatch = (() => {
|
||||||
let Dispatcher;
|
let Dispatcher;
|
||||||
|
|
||||||
return function (event) {
|
return function (event) {
|
||||||
Dispatcher ??= window.Vencord?.Webpack.Common.FluxDispatcher
|
Dispatcher ??= window.Vencord?.Webpack.Common.FluxDispatcher
|
||||||
if (!Dispatcher) {
|
if (!Dispatcher) {
|
||||||
const cache = webpackChunkdiscord_app.push([[Symbol()], {}, w => w]).c;
|
const cache = webpackChunkdiscord_app.push([[Symbol()], {}, w => w]).c;
|
||||||
webpackChunkdiscord_app.pop()
|
webpackChunkdiscord_app.pop()
|
||||||
|
|
||||||
outer:
|
outer:
|
||||||
for (const id in cache) {
|
for (const id in cache) {
|
||||||
const mod = cache[id].exports;
|
const mod = cache[id].exports;
|
||||||
|
@ -63,9 +63,9 @@ if (window.location.href.indexOf("splash.html") > -1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Dispatcher)
|
if (!Dispatcher)
|
||||||
return; // failed to find, your choice if and how u wanna handle this
|
return; // failed to find, your choice if and how u wanna handle this
|
||||||
|
|
||||||
return Dispatcher.dispatch(event);
|
return Dispatcher.dispatch(event);
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
@ -114,3 +114,19 @@ setInterval(() => {
|
||||||
el.onclick = () => ipcRenderer.send("openSettingsWindow");
|
el.onclick = () => ipcRenderer.send("openSettingsWindow");
|
||||||
host.append(el);
|
host.append(el);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
|
// dirty hack to make clicking notifications focus ArmCord
|
||||||
|
addScript(`
|
||||||
|
(() => {
|
||||||
|
const originalSetter = Object.getOwnPropertyDescriptor(Notification.prototype, "onclick").set;
|
||||||
|
Object.defineProperty(Notification.prototype, "onclick", {
|
||||||
|
set(onClick) {
|
||||||
|
originalSetter.call(this, function() {
|
||||||
|
onClick.apply(this, arguments);
|
||||||
|
armcord.window.show();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
`);
|
||||||
|
|
Loading…
Reference in a new issue