Telegram without Muted

Hide muted chats from chat list.

  1. // ==UserScript==
  2. // @name Telegram without Muted
  3. // @namespace hidemuted.telegram.aurium.one
  4. // @version 1.1
  5. // @description Hide muted chats from chat list.
  6. // @author Aurélio A. Heckert
  7. // @match https://web.telegram.org/
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. function applyRole(li) {
  15. li.style.display = toggler.checked ? 'none' : 'block';
  16. }
  17. function updateChatList() {
  18. //jQuery('.im_dialog_badge_muted').parents('li.im_dialog_wrap').hide();
  19. document.querySelectorAll('li.im_dialog_wrap').forEach((li)=> {
  20. if (li.querySelector('.im_dialog_badge_muted')) applyRole(li);
  21. });
  22. }
  23.  
  24. // It may be removed, so test and retry forever.
  25. function addNoiseTogglerBtn() {
  26. if (document.querySelector('#noiseToggler')) return; // It is ok, for now.
  27. toggler = document.createElement('input');
  28. toggler.id = 'noiseToggler';
  29. toggler.type = 'checkbox';
  30. toggler.title = 'Hide muted chats.';
  31. toggler.checked = true;
  32. toggler.style.float = 'right';
  33. toggler.style.margin = '15px 10px';
  34. toggler.onclick = updateChatList;
  35. console.log('Try to Insert noiseToggler Btn...')
  36. try {
  37. var topBar = document.querySelector('.tg_head_main_peer_wrap');
  38. topBar.insertBefore(toggler, topBar.firstChild);
  39. //topBar.appendChild(toggler);
  40. console.log('>>> Insert noiseToggler Btn Success!')
  41. } catch(err) {
  42. console.log('Fail to Insert noiseToggler Btn.')
  43. }
  44. }
  45. setInterval(addNoiseTogglerBtn, 2000);
  46.  
  47. setInterval(()=> {
  48. try {
  49. updateChatList()
  50. } catch(err) {
  51. console.log('Deu merda.', err)
  52. }
  53. }, 2000);
  54.  
  55. })();