├── .gitattributes ├── LICENSE ├── README.md └── online.plugin.js /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Elyse Yao 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Discord Status Updates 2 | 3 | Love Discord but miss the status notifications from Skype? I made a BetterDiscord plugin that'll notify you whenever someone on your friends list comes online or goes offline. 4 | 5 | ## Prerequisites 6 | 7 | What things you need to install the software and how to install them 8 | 9 | - [Discord](https://discordapp.com/) 10 | - [BetterDiscord](https://github.com/Jiiks/BetterDiscordApp/releases) 11 | 12 | I'm working on Win 10, and am not sure if this will work on other OS's. Let me know if you have issues! 13 | 14 | ## Installing 15 | 16 | This is a plugin for [BetterDiscord](https://github.com/Jiiks/BetterDiscordApp/releases), so install that if you haven't already. Then download this plugin and put `online.plugin.js` in `%appdata%\BetterDiscord\plugins`. Then enable it in your BetterDiscord settings and you're good to go! 17 | 18 | ## Note 19 | 20 | Because of how Discord is structured, my solution isn't exactly elegant. The plugin will rapidly switch to your friends list to parse the list before returning to your original screen. This may sometimes cause a slight flicker. 21 | 22 | ## Issues/Todo 23 | 24 | - [ ] Discord throttles refresh rate if it is not focused. As a result, notifications may be delayed. (Currently no fix) 25 | - [x] Will not work if currently in a PM (Fixed) 26 | - [x] Will sometimes not switch back correctly (Fixed) 27 | 28 | ## License 29 | 30 | This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details 31 | -------------------------------------------------------------------------------- /online.plugin.js: -------------------------------------------------------------------------------- 1 | //META{"name":"onlinePlugin"}*// 2 | //By Elyse 3 | 4 | var onlinePlugin = function() {}; 5 | 6 | onlinePlugin.prototype.start = function() { 7 | 8 | 9 | var x = $(".friends-online").html(); 10 | var online = []; 11 | 12 | 13 | updateC(); 14 | populate(); 15 | 16 | 17 | 18 | 19 | function populate() { 20 | console.log("Populating..."); 21 | var orig = window.location.href.substr(23); 22 | var switched = false; 23 | 24 | 25 | if (window.location.href != "https://discordapp.com/channels/@me") { 26 | $('a[href="/"]').addClass('click'); 27 | try { 28 | document.getElementsByClassName("click")[0].click(); 29 | 30 | } catch (err) { 31 | $('a[href*="channels/@me"]').addClass('click'); 32 | document.getElementsByClassName("click")[0].click(); 33 | 34 | } 35 | 36 | switched = true; 37 | } 38 | 39 | $(".discord-tag").children(".username").each(function(i, el) { 40 | var m = $(el).text(); 41 | online.push(m); 42 | }); 43 | console.log("Initialized: " + online); 44 | 45 | if (switched) { 46 | $('[href*="' + orig + '"]').addClass("selected"); 47 | document.getElementsByClassName("selected")[0].click(); 48 | } 49 | 50 | } 51 | 52 | 53 | function updateC() { 54 | 55 | content = $(".friends-online").html(); 56 | 57 | 58 | } 59 | 60 | 61 | 62 | function checkFriends() { 63 | var orig = window.location.href.substr(23); 64 | var switched = false; 65 | var checkthis = []; 66 | 67 | if (window.location.href != "https://discordapp.com/channels/@me") { 68 | $('a[href="/"]').addClass('click'); 69 | try { 70 | document.getElementsByClassName("click")[0].click(); 71 | 72 | } catch (err) { 73 | $('a[href*="channels/@me"]').addClass('click'); 74 | document.getElementsByClassName("click")[0].click(); 75 | 76 | } 77 | 78 | switched = true; 79 | } 80 | 81 | $(".discord-tag").children(".username").each(function(i, el) { 82 | var x = $(el).text(); 83 | checkthis.push(x); 84 | }); 85 | console.log("Friends Updated"); 86 | console.log(checkthis); 87 | if (switched) { 88 | $('[href*="' + orig + '"]').addClass("selected"); 89 | document.getElementsByClassName("selected")[0].click(); 90 | } 91 | 92 | var nowoff = []; 93 | var nowon = []; 94 | 95 | for (i = 0; i < checkthis.length; i++) { 96 | if (!online.includes(checkthis[i])) nowon.push(checkthis[i]); 97 | } 98 | 99 | for (i = 0; i < online.length; i++) { 100 | if (!checkthis.includes(online[i])) nowoff.push(online[i]); 101 | } 102 | var onstring; 103 | var offstring; 104 | 105 | onstring = nowon.toString().replace(/"[/]/, ''); 106 | offstring = nowoff.toString().replace(/"[/]/, ''); 107 | 108 | 109 | if (offstring.length != 0){ 110 | let myNotification = new Notification('Now Offline', { 111 | body: offstring 112 | }) 113 | 114 | myNotification.onclick = () => { 115 | console.log('Notification clicked') 116 | } 117 | } 118 | 119 | if(onstring.length !=0){ 120 | let myNotification = new Notification('Now Online', { 121 | body: onstring 122 | }) 123 | 124 | myNotification.onclick = () => { 125 | console.log('Notification clicked') 126 | } 127 | } 128 | 129 | online = checkthis; 130 | checkthis = []; 131 | 132 | } 133 | 134 | 135 | window.setInterval(function() { 136 | 137 | if ($(".friends-online").html() != content) { 138 | updateC(); 139 | checkFriends(); 140 | 141 | } 142 | }, 500); 143 | 144 | 145 | 146 | }; 147 | 148 | onlinePlugin.prototype.load = function() { 149 | 150 | }; 151 | 152 | onlinePlugin.prototype.unload = function() {}; 153 | 154 | onlinePlugin.prototype.stop = function() { 155 | 156 | }; 157 | 158 | onlinePlugin.prototype.onMessage = function() { 159 | 160 | }; 161 | 162 | onlinePlugin.prototype.onSwitch = function() { 163 | 164 | }; 165 | 166 | onlinePlugin.prototype.observer = function(e) { 167 | 168 | }; 169 | 170 | onlinePlugin.prototype.getSettingsPanel = function() { 171 | return ""; 172 | }; 173 | 174 | onlinePlugin.prototype.getName = function() { 175 | return "Online Notification"; 176 | }; 177 | 178 | onlinePlugin.prototype.getDescription = function() { 179 | return "Adds online notifications to Discord"; 180 | }; 181 | 182 | onlinePlugin.prototype.getVersion = function() { 183 | return "0.1.0"; 184 | }; 185 | 186 | onlinePlugin.prototype.getAuthor = function() { 187 | return "Elyse/Raliryx"; 188 | }; --------------------------------------------------------------------------------