Cookie Clicker Notification

Desktop notifications for golden cookies and deers.

目前为 2015-04-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Cookie Clicker Notification
  3. // @icon http://orteil.dashnet.org/cookieclicker/img/goldCookie.png
  4. // @namespace x4_ccn
  5. // @version 0.2
  6. // @description Desktop notifications for golden cookies and deers.
  7. // @author x4fab
  8. // @match http://orteil.dashnet.org/cookieclicker/
  9. // @grant none
  10. // @license CC0
  11. // ==/UserScript==
  12.  
  13. if (Notification.permission == 'default'){
  14. document.body.onclick = function (){
  15. Notification.requestPermission();
  16. document.body.onclick = null;
  17. }
  18. }
  19.  
  20. setTimeout(function(q,r){
  21. setInterval(function(){
  22. if (document.querySelector('#goldenCookie').style.display != 'none'){
  23. if (!q)
  24. (q = new Notification('Golden Cookie!',
  25. { icon: document.querySelector('#goldenCookie').style.backgroundImage.slice(4, -1) }))
  26. .onclick = document.body.click.bind(document.querySelector('#goldenCookie'));
  27. } else if (q){
  28. q.close();
  29. q = 0;
  30. }
  31. if (document.querySelector('#seasonPopup').style.display != 'none'){
  32. if (!r)
  33. (r = new Notification('Season Popup!',
  34. { icon: document.querySelector('#seasonPopup').style.backgroundImage.slice(4, -1) }))
  35. .onclick = document.body.click.bind(document.querySelector('#seasonPopup'));
  36. } else if (r){
  37. r.close();
  38. r = 0;
  39. }
  40. }, 100);
  41. window.onkeydown = window.onkeypress = function(e){
  42. if (e.keyCode == 32)
  43. return false;
  44. }
  45. window.onkeyup = function(e){
  46. if (e.keyCode == 32 && e.shiftKey)
  47. Game.Notify('Heavenly Chips', 'Reset now and total count will be ' + Beautify(Game.HowMuchPrestige(Game.cookiesReset+Game.cookiesEarned)), 0, 3);
  48. if ([ 13, 17, 32 ].indexOf(e.keyCode) + 1)
  49. document.querySelector('#bigCookie').click();
  50. }
  51. }, 500);