Guest User

Untitled

a guest
Mar 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. function findClassNames() {
  2. var results = [].slice.call(document.querySelectorAll("div")).filter(function(o) {return o.innerText == "_Helper_"});
  3. if(results.length == 1) {
  4. nameNode = results[0];
  5. nameClass = nameNode.classList[0]
  6. countNode = [].slice.call(nameNode.parentNode.querySelectorAll("div")).filter(function(o) {return o.innerText == "1"})[0]
  7. countClass = countNode.classList[0]
  8.  
  9. return {
  10. nameClass: "." + nameClass,
  11. countClass: "." + countClass
  12. }
  13. } else {
  14. alert("Failed to find helper list");
  15. }
  16. }
  17.  
  18. var TARGET_LIST = "Now"
  19. var LONG_WAIT = 10000;
  20. var SHORT_WAIT = 10000;
  21.  
  22. var CLASS_LIST_NAME = null
  23. var CLASS_LIST_COUNT = null
  24.  
  25. window.fluid.dockBadge = '';
  26. setTimeout(updateDockBadge, LONG_WAIT);
  27.  
  28. function updateDockBadge() {
  29. if(!CLASS_LIST_NAME) {
  30. var names = findClassNames()
  31. CLASS_LIST_NAME = names["nameClass"];
  32. CLASS_LIST_COUNT = names["countClass"];
  33. }
  34.  
  35. try {
  36. var newBadge = '';
  37. var listNameNodes = [].slice.call(document.querySelectorAll(CLASS_LIST_NAME))
  38. var nowNode = listNameNodes.filter(function(node) { return node.outerText == TARGET_LIST })[0]
  39. var countNode = nowNode.parentNode.querySelector(CLASS_LIST_COUNT)
  40.  
  41. window.fluid.dockBadge = countNode.outerText;
  42. if(countNode.outerText) {
  43. window.fluid.requestUserAttention();
  44. setTimeout(updateDockBadge, SHORT_WAIT);
  45. } else {
  46. setTimeout(updateDockBadge, LONG_WAIT);
  47. }
  48.  
  49. } catch(err) {
  50. alert("Failed to show badge: " + err)
  51. }
  52. }
Add Comment
Please, Sign In to add comment