Gab.ai Connection Status

Gray out notification area when disconnected from updates and try to reconnect.

目前为 2016-10-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Gab.ai Connection Status
  3. // @namespace https://www.ekkooff.com/
  4. // @version 0.1
  5. // @description Gray out notification area when disconnected from updates and try to reconnect.
  6. // @author Kevin Roberts
  7. // @match https://gab.ai/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Your code here...
  15. setInterval(function() {
  16. var state = null,count=null;
  17. if(Pusher && Pusher.instances[0] && Pusher.instances[0].connection && Pusher.instances[0].connection.state) {
  18. state = Pusher.instances[0].connection.state;
  19. } else {
  20. return;
  21. }
  22. //console.log('state:',state);
  23. if(state==='disconnected') {
  24. count = $('.notification-count span');
  25. count.css('background-color','#444');
  26. count.removeClass('hidden');
  27. Pusher.instances[0].connection.connect();
  28. } else {
  29. count = $('.notification-count span');
  30. count.css('background-color','');
  31. if(parseInt(count.text()) === 0) {
  32. count.addClass('hidden');
  33. }
  34. }
  35. },5000);
  36. })();