diff options
Diffstat (limited to 'uncompressed/discord')
-rw-r--r-- | uncompressed/discord/index.js | 6 | ||||
-rw-r--r-- | uncompressed/discord/webview.js | 25 |
2 files changed, 24 insertions, 7 deletions
diff --git a/uncompressed/discord/index.js b/uncompressed/discord/index.js index 629d7c7..dd2bcf2 100644 --- a/uncompressed/discord/index.js +++ b/uncompressed/discord/index.js | |||
@@ -1,10 +1,8 @@ | |||
1 | "use strict"; | ||
2 | |||
3 | module.exports = Franz => class Discord extends Franz { | 1 | module.exports = Franz => class Discord extends Franz { |
4 | overrideUserAgent() { | 2 | overrideUserAgent() { |
5 | const useragent = window.navigator.userAgent; | 3 | const useragent = window.navigator.userAgent; |
6 | const parts = useragent.split('(KHTML, like Gecko)'); | 4 | const parts = useragent.split('(KHTML, like Gecko)'); |
5 | |||
7 | return parts.join('(KHTML, like Gecko) discord/0.0.250').replace('Electron', 'Discord').replace('Franz', 'Discord'); | 6 | return parts.join('(KHTML, like Gecko) discord/0.0.250').replace('Electron', 'Discord').replace('Franz', 'Discord'); |
8 | } | 7 | } |
9 | 8 | }; | |
10 | }; \ No newline at end of file | ||
diff --git a/uncompressed/discord/webview.js b/uncompressed/discord/webview.js index 9a72420..f4a90b9 100644 --- a/uncompressed/discord/webview.js +++ b/uncompressed/discord/webview.js | |||
@@ -6,11 +6,30 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
6 | 6 | ||
7 | module.exports = Franz => { | 7 | module.exports = Franz => { |
8 | const getMessages = function getMessages() { | 8 | const getMessages = function getMessages() { |
9 | const direct = document.querySelectorAll('[class^="guildsWrapper"] [class*="badge"]').length; | 9 | // Get direct messages |
10 | const indirect = document.querySelectorAll('[class^="guildsWrapper"] [class^="guild-"]+[class*="unread-"]').length; | 10 | const directElements = document.querySelectorAll('[class^="numberBadge-2s8kKX"]'); |
11 | var direct = 0; | ||
12 | |||
13 | directElements.forEach(function(directElement) { | ||
14 | direct = direct + parseInt(directElement.innerHTML); | ||
15 | }); | ||
16 | |||
17 | // Get indirect messages | ||
18 | const linkElements = document.getElementsByTagName('link'); | ||
19 | var indirect = 0; | ||
20 | |||
21 | for (var i = 0; i < linkElements.length; i++) { | ||
22 | if(linkElements[i].getAttribute('rel') == 'icon') { | ||
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 | } | ||
28 | |||
29 | // Set badge | ||
11 | Franz.setBadge(direct, indirect); | 30 | Franz.setBadge(direct, indirect); |
12 | }; | 31 | }; |
13 | 32 | ||
14 | Franz.loop(getMessages); | 33 | Franz.loop(getMessages); |
15 | Franz.injectCSS(_path.default.join(__dirname, 'service.css')); | 34 | Franz.injectCSS(_path.default.join(__dirname, 'service.css')); |
16 | }; \ No newline at end of file | 35 | }; |