Asspig notifier

Nofifies new messages on the Asspig website through scraping.

  1. // ==UserScript==
  2. // @name Asspig notifier
  3. // @namespace http://blog.regularoddity.com/
  4. // @version 1.1
  5. // @description Nofifies new messages on the Asspig website through scraping.
  6. // @author E E
  7. // @match https://www.asspig.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=asspig.com
  9. // @grant GM_notification
  10. // @license GPLv3
  11. // ==/UserScript==
  12.  
  13. /* jshint esversion: 6 */
  14.  
  15. (function() {
  16. 'use strict';
  17. let messages = 0;
  18. const Query = '#link_messenger span';
  19.  
  20. setInterval(function() {
  21. let element = document.querySelector(Query);
  22. if (!element) {
  23. return;
  24. }
  25. element = element.textContent;
  26. let count = element.length === 0 ? 0 : parseInt(element);
  27. if (count > messages) {
  28. GM_notification(count === 1 ? 'There is a message on Asspig.'
  29. : `There are ${count} messages on Asspig.`);
  30. }
  31. messages = count;
  32. }, 2000);
  33. })();