BBRT notifier

Nofifies new messages on the BBRT website through scraping.

  1. // ==UserScript==
  2. // @name BBRT notifier
  3. // @namespace http://blog.regularoddity.com/
  4. // @version 0.3
  5. // @description Nofifies new messages on the BBRT website through scraping.
  6. // @author E E
  7. // @match https://www.barebackrt.com/members/default.php
  8. // @icon https://www.barebackrt.com/favicon.ico
  9. // @grant GM_notification
  10. // @license MIT License
  11. // ==/UserScript==
  12.  
  13. /* esversion: 6 */
  14.  
  15. (function() {
  16. 'use strict';
  17. let messages = 0;
  18. const Query = 'emailLogo';
  19.  
  20.  
  21. let getNode = function() {
  22. let doc = top.window.frames[1].document.children[0];
  23. let xpath = document.evaluate('//span[@id="emailLogo"]', doc);
  24. return xpath.iterateNext();
  25. };
  26.  
  27. setInterval(function() {
  28. let node = getNode();
  29. let count;
  30. if (!node) {
  31. count = 0;
  32. } else {
  33. let text = node.textContent;
  34. text = text.substring(1);
  35. count = parseInt(text);
  36. }
  37. if (count > messages) {
  38. GM_notification(
  39. count === 1 ? 'There is a message on BBRT.'
  40. : `There are ${count} messages on BBRT.`);
  41. }
  42. messages = count;
  43. }, 2000);
  44. })();