GDQ Schedule Highlighter

try to take over the world!

  1. // ==UserScript==
  2. // @name GDQ Schedule Highlighter
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://gamesdonequick.com/schedule
  8. // @grant GM_addStyle
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // ==/UserScript==
  12. /*jshint multistr: true */
  13.  
  14. GM_addStyle ( " \
  15. .scheduled { \
  16. background-color:#a5d6a7; \
  17. } \
  18. " );
  19.  
  20. (function() {
  21. 'use strict';
  22.  
  23. // Your code here...
  24. var config = GM_getValue("config", {});
  25.  
  26. $("tr.second-row").append('<td><button style="float:right" class="schedule">Highlight</button></td>');
  27. $("#runTable tr").not(".second-row").not(".day-split").addClass("first-row");
  28. var i = 0;
  29. $("#runTable tr").not(".day-split").not(".first-row").each(function() {
  30. i++;
  31. $(this).attr("row-count", i);
  32. $(this).prev(".first-row").attr("row-count", i);
  33. });
  34.  
  35. Object.keys(config).forEach(function(entry) {
  36. $("#runTable tr[row-count='" + entry + "']").addClass("scheduled");
  37. });
  38.  
  39. $( "button.schedule" ).on( "click", function( event ) {
  40. if (config[$( event.target ).closest( "tr.second-row" ).attr("row-count")]){
  41. delete config[$( event.target ).closest( "tr.second-row" ).attr("row-count")];
  42. } else {
  43. config[$( event.target ).closest( "tr.second-row" ).attr("row-count")] = true;
  44. }
  45. $( event.target ).closest( "tr.second-row" ).toggleClass( "scheduled" );
  46. $( event.target ).closest( "tr.second-row" ).prev("tr.first-row").toggleClass( "scheduled" );
  47. GM_setValue("config", config);
  48. });
  49. $("tr.first-row").append('<td><button style="float:right;visibility: hidden;" class="schedule">Highlight</button></td>');
  50. })();