New Cheevos Notification

Notify when a new cheevo is added.

  1. // ==UserScript==
  2. // @name New Cheevos Notification
  3. // @namespace pxgamer
  4. // @version 0.1
  5. // @description Notify when a new cheevo is added.
  6. // @author pxgamer
  7. // @include *kat.cr*
  8. // @grant GM_notification
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. var currentCount;
  17. var newCount;
  18. var returnedData = [];
  19. var re = /<span class=\"achBadge/ig, matches, ret = [];
  20.  
  21. $.ajax({
  22. type: "GET",
  23. url: "/achievements/",
  24. async: false,
  25. success: function (data) {
  26. while (matches = re.exec(data.html)) {
  27. returnedData.push(matches[1]);
  28. }
  29. },
  30. returnData: "json"
  31. });
  32.  
  33. currentCount = GM_getValue("cheevoCurrentCount", returnedData.length);
  34. GM_setValue("cheevoCurrentCount", returnedData.length);
  35.  
  36. if (currentCount < returnedData.length) {
  37. GM_notification("A new cheevo has been added!",
  38. "New Cheevo", "https://kastatic.com/images/achMedal_bronze.jpg",
  39. function () { window.location.href = "https://kat.cr/achievements/"; }
  40. );
  41. }
  42. })();