GitHub Halloween

Experience Halloween every day

当前为 2016-11-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GitHub Halloween
  3. // @namespace https://github.com/KeyWeeUsr/Userscripts
  4. // @version 0.3
  5. // @description Experience Halloween every day
  6. // @author Peter Badida
  7. // @copyright 2016+, Peter Badida
  8. // @license GNU GPLv3
  9. // @homepage https://github.com/KeyWeeUsr/Userscripts/tree/master/Halloween
  10. // @supportURL https://github.com/KeyWeeUsr/Userscripts/issues
  11. // @icon https://github.com/favicon.ico
  12. // @include https://*github.com/*
  13. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  14. // @contributionURL https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ACVM74AYCXVWQ
  15. // @grant GM_addStyle
  16. // ==/UserScript==
  17. /* jshint -W097 */
  18. 'use strict';
  19. (function () {
  20. var items = document.getElementsByClassName("day");
  21. var dc;
  22. var max = 0;
  23. var second;
  24. var third;
  25. var fourth;
  26. for (var i=0; i<items.length; i++) {
  27. dc = parseInt($(items[i]).attr('data-count'));
  28. if (max < dc) {
  29. max = dc;
  30. }
  31. }
  32. second = Math.round(max / 2.0);
  33. third = Math.round(second / 2.0);
  34. for (var i=0; i<items.length; i++) {
  35. dc = parseInt($(items[i]).attr('data-count'));
  36. if (dc == max && dc != 0) {
  37. $(items[i]).attr('fill', '#03001C');
  38. } else if (second < dc && dc <= max - 1) {
  39. $(items[i]).attr('fill', '#FE9600');
  40. } else if (third < dc && dc <= second) {
  41. $(items[i]).attr('fill', '#FFC501');
  42. } else if (0 < dc && dc <= third) {
  43. $(items[i]).attr('fill', '#FFEE4A');
  44. } else {
  45. $(items[i]).attr('fill', '#EEEEEE');
  46. }
  47. }
  48. var css = '\
  49. ul.legend > li {\
  50. background-color: #EEEEEE !important;\
  51. }\
  52. ul.legend > li + li {\
  53. background-color: #FFEE4A !important;\
  54. }\
  55. ul.legend > li + li + li {\
  56. background-color: #FFC501 !important;\
  57. }\
  58. ul.legend > li + li + li + li {\
  59. background-color: #FE9600 !important;\
  60. }\
  61. ul.legend > li + li + li + li + li {\
  62. background-color: #03001C !important;\
  63. }\
  64. \
  65. ';
  66. GM_addStyle(css);
  67. })();
  68. /*
  69. Notify me if there's something missing/undesirable.
  70. */