diff options
author | 2020-02-18 15:15:12 +0100 | |
---|---|---|
committer | 2020-02-18 15:15:12 +0100 | |
commit | daf7433a29938f1689154b08645a0e416d4687f2 (patch) | |
tree | ba7af98ea52c0d1e6cd592f2f2257a464a4a5a2e /uncompressed/discord | |
parent | Update slack: Fix incorrect notification count (#41) (diff) | |
download | ferdium-recipes-daf7433a29938f1689154b08645a0e416d4687f2.tar.gz ferdium-recipes-daf7433a29938f1689154b08645a0e416d4687f2.tar.zst ferdium-recipes-daf7433a29938f1689154b08645a0e416d4687f2.zip |
Fix indirect discord notifications, simplify code
Diffstat (limited to 'uncompressed/discord')
-rw-r--r-- | uncompressed/discord/package.json | 2 | ||||
-rw-r--r-- | uncompressed/discord/webview.js | 25 |
2 files changed, 14 insertions, 13 deletions
diff --git a/uncompressed/discord/package.json b/uncompressed/discord/package.json index 60721dd..76b680d 100644 --- a/uncompressed/discord/package.json +++ b/uncompressed/discord/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "discord", | 2 | "id": "discord", |
3 | "name": "Discord", | 3 | "name": "Discord", |
4 | "version": "1.1.0", | 4 | "version": "1.1.1", |
5 | "description": "Discord", | 5 | "description": "Discord", |
6 | "main": "index.js", | 6 | "main": "index.js", |
7 | "author": "Stefan Malzner <stefan@adlk.io>", | 7 | "author": "Stefan Malzner <stefan@adlk.io>", |
diff --git a/uncompressed/discord/webview.js b/uncompressed/discord/webview.js index f4a90b9..2a204dc 100644 --- a/uncompressed/discord/webview.js +++ b/uncompressed/discord/webview.js | |||
@@ -5,26 +5,27 @@ var _path = _interopRequireDefault(require("path")); | |||
5 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | 5 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
6 | 6 | ||
7 | module.exports = Franz => { | 7 | module.exports = Franz => { |
8 | const iconValues = [ | ||
9 | 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAY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7kG8RoadW9MDt2HE4cb5F48gvfMLLDZ3cc4xcjmUhYXoWf0k2mPWBGzzCqDVv0qv4Ti61OtES9tQYO/ZDal4YIUaUx0dMD9fDrmpWygTsOjz0LHxNTgTUudvxTT8NA3Bi/5Kwwf98JKylpKrUfncUijPn8Hw5s2CxMGASXUSvtx+EnsaSsLPgkMVmbzNZsDqQrdpAvdl3AXtn52w5udHRO4HUxExTnvKMsDGO4zqK/WBKUX7s8vlhUrJ7X6D2dlwX7lySwJuHPowAyjlFVBFwqtNnEsB7enGaxOkDSuxbIkKEydPwF5efjvk7Fnyk9bwClDHRIEWYgYh8y/a0bq6x3Dmgg1PndiC+N6feQVoKioQt3s3GBUR2tyM0epq+DweXixx+VbY9wA1rCS5Xk2mYLpOyabg3da/YDY5ULZvFa9DVXExUtraODbHgQNwHDzIiycclyN+kMTbTCg1FPM6TGpshOam1Ex3dmIoNzdsuiIWkDx4FZsaSngdxu3di4S6Oo7temsrbCX8eAqMWECsfQDPvLGeVwBtvbqLFyHPymLt3pERWNetg8doXLgIUE879mRD6uUvLEahgKqoiC1C19mz8Nq5UzBYCSnCH4MjMEmMSjF3q+j9l5Bu/FYMdF4MIa8NCKisN54iiraK8Zpx+Rweb3lFDFQIsyIgoPp1U+yM1P0pOVEgdIrai9/bgbSe78RAw11BA2nFVSEPrl2GXj3jm00R8nzvb5+n5H9U00hqIeL/kUPLc5HX9xN3GAkR8tn7gBzipZ3YBAX7z1Pyr7Ydx5Gah25fAHV6DdCS2nmTfBWcyzPRyuNNtV0074UhD5JbiUDwGTPwCHn3lpK/KnlEULbfRq8a2btAPlvI9PujrOkXmXo8pokI2E4x/wEv2KYDh7TO6QAAAABJRU5ErkJggg==' | ||
11 | ]; | ||
12 | |||
8 | const getMessages = function getMessages() { | 13 | const getMessages = function getMessages() { |
9 | // Get direct messages | 14 | // Get direct messages |
10 | const directElements = document.querySelectorAll('[class^="numberBadge-2s8kKX"]'); | 15 | let direct = 0; |
11 | var direct = 0; | ||
12 | 16 | ||
13 | directElements.forEach(function(directElement) { | 17 | document.querySelectorAll('[class^="numberBadge-2s8kKX"]').forEach((directElement) => { |
14 | direct = direct + parseInt(directElement.innerHTML); | 18 | direct = direct + parseInt(directElement.innerHTML); |
15 | }); | 19 | }); |
16 | 20 | ||
17 | // Get indirect messages | 21 | // Get indirect messages |
18 | const linkElements = document.getElementsByTagName('link'); | 22 | let indirect = 0; |
19 | var indirect = 0; | 23 | |
20 | 24 | document.querySelectorAll('link[rel="icon"]').forEach((linkElement) => { | |
21 | for (var i = 0; i < linkElements.length; i++) { | 25 | if(iconValues.indexOf(linkElement.getAttribute('href')) !== -1) { |
22 | if(linkElements[i].getAttribute('rel') == 'icon') { | 26 | indirect = 1; |
23 | if(linkElements[i].getAttribute('href') == 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAEJ0lEQVRYR+2WXUybVRjHf20ptLBSx8cqIKy1W2wlCnGiXjgzhS1ezEFNxAsV3BaXKDPGDTS6TTFzmwkwXdToJokiu5kfGUTj4saIu9AliAZM+FiywmAW+ZJRWim0tK95G1qotPTtILvy3LzJe/7P8/+f5+scGfPrqa8ERc5g7wEEXgFSAv9X+TuBjBODOaYjX5fKvKJvWYBgf23vQQTh8CoThncnkx2qqzS9GyqgpmccSL0lAuDvuipz2n8FCLeI3E9TV2X2R38hBTU9/wuIGIHM9AQ25Wq5TaPENjpDZ+8UapWChHi5P5wzbh9uj4/N960lM13FwF8ufuuyMzQ2GzGrklKgSYzDUqRDlxrP8LjbT7g+Q+UnD7cc/8zRb3OhSpCTtU7F1cFpmi6O4JieWwKXJODZ7Zncs1HjN1YoguUiqVY9Hh9KpZyO3ilOfz8UuwCtJo4DezYgj413CZFPgCOnrmJ3hEYhagQefzidoodWZyxcuDzOjz+LY2ZhRRXw5gtGUrRKSeGOBpqwezj6mVW6ALHq95Ublviddfv4c2SGO3SqYAcEQM5pL6MTs+RkqIlTyHB3dBCfnx/0cbyhP6Qrlo3A5k0pFD+6LkSAa8bL8S+vcWPKw9pkJfvK9MFuGLvhpum1egyXz5LqHEI70B20VW3ZglKv5497d3DOaw7+X1aAWP35puQQAZ1XHDR+Zwv+e+6JLPLu0uCbnKSr5BmSLv0QLRO0bdtL+9aK6KNYDL+YhsVLPGXt5/14fQIKuYzKnQY0nb8wbLH4RUhd45lmzpV/SPWxosh3weG9G8MOm4EhF91WJ3cb15CdOMugwRATeUCkzfgAj1jbIguoqTQFbylxPrtcXhLVodNvuKSE6eZmqQcPh3vHCNVhb8OqnQZ0qQspEGd6T5+T9Rlq7sxOxNXcxIjFshJyv60cDGEFaJLiEAvRmJ0YJBEn2u/dds62jLD99Mvo2s+vWADwasT3gLhhNq7h/lwt+ky1PwX13173XzCl71tIG+oNKyCjpQV1YaF/z2uzMVpWhqu1NSxWgIabepC8VLXQz4s9p9fXo9m9O4TM093N9dzcSNHqiFlAmq2H0g+ejHr6AEBwOBirqMDZ2BjWJmYBopfVioAAl25KQPEnZWT1/Ro1CtFqADixWMA0oJZS2o+deQNTe5MUaDTMQhdU1vQ0CFAWzULcz7K2UfxpuRTochi7HPTBCLz+nlU7p3B/AxRJ8Vxw/iMKLnwsBRqpBS0boGnJg2t/7RWTTPDdLsXzroMF9QmzTqMU7GJMX24hW7suht4FsToR8f2g94FYDHlS7UXy1qePcuytB1cuIEBqhWrg7Sgi7M5k3YsNh356XgbbljxIpJ4gEm4+GiUC5MtAfIvlzfd5B3BNDl8YYHLPyXalZirpZF2VeZfo61+PD6XFPaCuOgAAAABJRU5ErkJggg==') { | ||
24 | indirect = 1; | ||
25 | } | ||
26 | } | 27 | } |
27 | } | 28 | }); |
28 | 29 | ||
29 | // Set badge | 30 | // Set badge |
30 | Franz.setBadge(direct, indirect); | 31 | Franz.setBadge(direct, indirect); |