Clutter Disappearifier

hides ads and navigation from around the comics

  1. // ==UserScript==
  2. // @name Clutter Disappearifier
  3. // @namespace abrad45
  4. // @description hides ads and navigation from around the comics
  5. // @include http://www.mspaintadventures.com/*
  6. // @include http://mspaintadventures.com/*
  7. // @require https://code.jquery.com/jquery-2.2.3.min.js
  8. // @require https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.1/js.cookie.js
  9. // @version 2
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. $(function () {
  14. if(/s=6/.test(window.location.search)) {
  15. var $body = $('body');
  16. var cookieName = 'homestuck_cd';
  17. var appear = 'Appearify Clutter';
  18. var disappear = 'Disappearify Clutter';
  19.  
  20. if (getCookieValue() !== 0) {
  21. $body
  22. .css('background-color', '#c6c6c6')
  23. .find('> center > table > tbody > tr:not(:eq(1))')
  24. .hide();
  25.  
  26. setCookie(1, {
  27. 'path': '/',
  28. 'expires': 180
  29. });
  30. }
  31.  
  32. $('table[width=600]')
  33. .first()
  34. .parent()
  35. .css('position', 'relative')
  36. .append(
  37. $('<div />',
  38. {
  39. 'id': 'clutter_disappearifier',
  40. 'css': {
  41. 'position': 'absolute',
  42. 'right': '5px',
  43. 'top': '0'
  44. }
  45. }
  46. ).append(
  47. $('<a />',
  48. {
  49. 'href': '#',
  50. 'text': function () {
  51. if(getCookieValue() === 1) {
  52. return appear;
  53. } else {
  54. return disappear;
  55. }
  56. }
  57. }
  58. )
  59. )
  60. );
  61.  
  62. $('#clutter_disappearifier a').click(function () {
  63. if ($('body[style]').length) {
  64. $body
  65. .removeAttr('style')
  66. .find('> center > table > tbody > tr')
  67. .show();
  68.  
  69. setCookie(0);
  70. $(this).text(disappear);
  71. } else {
  72. $body
  73. .css('background-color', '#c6c6c6')
  74. .find('> center > table > tbody > tr:not(:eq(1))')
  75. .hide();
  76.  
  77. setCookie(1);
  78. $(this).text(appear);
  79. }
  80. return false;
  81. });
  82. }
  83.  
  84. function getCookieValue() {
  85. return Number(Cookies.get(cookieName)) || -1;
  86. }
  87.  
  88. function setCookie(val, options) {
  89. if (typeof options === "object") {
  90. Cookies.set(cookieName, !!val, options);
  91. } else {
  92. Cookies.set(cookieName, !!val);
  93. }
  94. }
  95. });