Comick Client

Comick Client (Alpha)

  1. // ==UserScript==
  2. // @name Comick Client
  3. // @namespace https://github.com/Nublord33/Comick-CLient
  4. // @version 0.1
  5. // @description Comick Client (Alpha)
  6. // @author Nublord33/SkibidiSKid(joke name)
  7. // @match https://comick.io/*
  8. // @license Apache license 2.0
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. const SOLID_COLOR = '#121318'; // Original solid background color
  16. const SECONDARY_COLOR = '#212328'; // Secondary color
  17. const OTHER_COLOR = '#3a3f47'; // New color for specific <a> elements
  18. const ICON_COLOR = '#e38783'; // Icon color for <path> elements with fill-rule="evenodd"
  19. const FONT_COLOR = '#e5e7eb'; // Font color
  20. const FONT_STYLE = 'JetBrains Mono, monospace'; // Font style
  21.  
  22. // Class name variables with dots for CSS selectors
  23. const COMICK_STATUS = '.flex-1.mt-0.py-3.px-2.h-12.border.border-gray-300.dark\\:bg-gray-700.dark\\:border-gray-700.rounded';
  24. const BUTTON_CLASS = '.md\\:w-96.h-12.btn.px-2.py-3.flex-1';
  25. const A_CLASS = '.flex-1.md\\:w-96.h-12.btn.btn-primary.px-2.py-3.flex.items-center.rounded.flex.flex-1';
  26. const SELECT_SECONDARY_CLASS = '.cursor-pointer.pl-2.pr-6.py-1.border.border-gray-300.rounded.dark\\:border-gray-600';
  27. const TABLE_CLASS = '.table-fixed.w-full.whitespace-nowrap';
  28. const UL_CLASS = '.scrollbox.dark\\:scrollbox-dark.mt-3.mb-3.flex.flex-wrap.max-h-32.md\\:max-h-48.xl\\:max-h-48.overflow-y-auto.items-center.scrollbar-thin.scrollbar-thumb-gray-300.scrollbar-track-gray-100.dark\\:scrollbar-thumb-gray-600.dark\\:scrollbar-track-gray-700.scrollbar-thumb-rounded';
  29. const COMICK_TOPBAR = '.flex.items-center.justify-between.space-x-2.px-3.sm\\:px-6.lg\\:px-8.py-2.lg\\:border-b.border-gray-100.dark\\:border-gray-700.max-sm\\:overflow-x-auto.drop-shadow-sm.bg-white\\/95.dark\\:bg-gray-800\\/95';
  30. const BUTTON_SECONDARY_CLASS = '.btn.w-full.text-center.text-xs.px-0.border-none';
  31. const SCROLLBOX_CLASS = '.max-h-64.overflow-y-auto.scrollbox.dark\\:scrollbox-dark.scrollbar-thin.scrollbar-thumb-gray-300.scrollbar-track-gray-100.dark\\:scrollbar-thumb-gray-600.dark\\:scrollbar-track-gray-700.scrollbar-thumb-rounded.mt-1';
  32.  
  33. // Long class selectors as variables
  34. const COMIC_DESC = '.comic-desc.xl\\:h-auto.max-h-96.overflow-y-auto.scrollbox.dark\\:scrollbox-dark.scrollbar-thin.scrollbar-thumb-gray-300.scrollbar-track-gray-100.dark\\:scrollbar-thumb-gray-600.dark\\:scrollbar-track-gray-700.scrollbar-thumb-rounded.my-3.md\\:my-5.prose.prose-hr\\:my-3.dark\\:prose-invert.max-w-none.prose-table\\:w-auto';
  35. const SCROLLBOX_CLASS_1 = '.scrollbox.dark\\:scrollbox-dark.mt-3.mb-3.flex.flex-wrap.max-h-32.md\\:max-h-48.xl\\:max-h-48.overflow-y-auto.items-center.scrollbar-thin.scrollbar-thumb-gray-300.scrollbar-track-gray-100.dark\\:scrollbar-thumb-gray-600.dark\\:scrollbar-track-gray-700.scrollbar-thumb-rounded';
  36. const SCROLLBOX_CLASS_2 = '.flex.items-center.max-w-max.overflow-x-auto.scrollbox.dark\\:scrollbox-dark.scrollbar-thin.scrollbar-thumb-gray-300.scrollbar-track-gray-100.dark\\:scrollbar-thumb-gray-600.dark\\:scrollbar-track-gray-700.scrollbar-thumb-rounded.space-x-3';
  37.  
  38. //Set solid background and remove background image if not an image.
  39. function setSolidBackground(element, color) {
  40. element.style.backgroundColor = color;
  41. if (element.tagName.toLowerCase() !== 'img') {
  42. element.style.backgroundImage = 'none';
  43. }
  44. }
  45.  
  46. // Helper: Set color for <path> elements with fill-rule="evenodd" and clip-rule="evenodd"
  47. function setIconColorForPaths() {
  48. document.querySelectorAll('path').forEach(path => {
  49. path.style.color = ICON_COLOR; // Apply the icon color to all paths
  50. });
  51. }
  52.  
  53. //Apply styles to multiple selectors
  54. function applyStylesToSelectors(selectors, color) {
  55. selectors.forEach(selector => {
  56. document.querySelectorAll(selector).forEach(element => {
  57. setSolidBackground(element, color);
  58. element.style.border = 'none'; // Remove the border
  59. });
  60. });
  61. }
  62.  
  63. // Function to apply styles to all relevant elements
  64. function applyCustomStyles() {
  65. // Apply solid background to body
  66. setSolidBackground(document.body, SOLID_COLOR);
  67. // Apply FONT_COLOR and FONT_STYLE to body
  68. document.body.style.color = FONT_COLOR;
  69. document.body.style.fontFamily = FONT_STYLE;
  70.  
  71. // Apply styles to individual elements
  72. applyStylesToSelectors([BUTTON_CLASS, A_CLASS], OTHER_COLOR);
  73. applyStylesToSelectors([SELECT_SECONDARY_CLASS, COMICK_STATUS], SECONDARY_COLOR);
  74.  
  75. document.querySelectorAll(TABLE_CLASS).forEach(table => {
  76. table.querySelectorAll('*').forEach(element => {
  77. if (element.tagName.toLowerCase() === 'input' && element.type === 'text' && element.placeholder === 'Goto chap') {
  78. setSolidBackground(element, SECONDARY_COLOR); // Apply secondary color
  79. return;
  80. }
  81. if (element.tagName.toLowerCase() !== 'i' || !element.classList.contains('flag-icon')) {
  82. setSolidBackground(element, SOLID_COLOR); // Apply solid color to other elements
  83. }
  84. });
  85. });
  86.  
  87. // Apply solid background to specific content areas
  88. applyStylesToSelectors([COMIC_DESC, SCROLLBOX_CLASS_1, SCROLLBOX_CLASS_2], SOLID_COLOR);
  89.  
  90. // Style list items
  91. document.querySelectorAll(UL_CLASS).forEach(ul => {
  92. ul.querySelectorAll('li[title^="Vote:"]').forEach(li => {
  93. li.style.backgroundColor = SECONDARY_COLOR;
  94. });
  95. });
  96. document.querySelectorAll(SCROLLBOX_CLASS_2).forEach(div => {
  97. div.querySelectorAll('.dark\\:hover\\:bg-gray-600').forEach(innerDiv => {
  98. innerDiv.style.backgroundColor = SECONDARY_COLOR;
  99. });
  100. });
  101.  
  102.  
  103. // Apply styles to secondary buttons
  104. applyStylesToSelectors([BUTTON_SECONDARY_CLASS], OTHER_COLOR);
  105.  
  106. // Apply styles to scrollboxes
  107. applyStylesToSelectors([SCROLLBOX_CLASS], SOLID_COLOR);
  108.  
  109. // Apply styles to the top bar
  110. applyStylesToSelectors([COMICK_TOPBAR], SECONDARY_COLOR);
  111.  
  112. // Apply styles to .bg-blue-500 elements
  113. applyStylesToSelectors(['.bg-blue-500'], OTHER_COLOR);
  114.  
  115. // Apply ICON_COLOR to <path> elements with fill-rule="evenodd" and clip-rule="evenodd"
  116. setIconColorForPaths();
  117. }
  118.  
  119. // Initial style application
  120. applyCustomStyles();
  121.  
  122. // Reapply styles on navigation changes
  123. const originalPushState = history.pushState;
  124. history.pushState = function(...args) {
  125. originalPushState.apply(history, args);
  126. applyCustomStyles();
  127. };
  128.  
  129. window.addEventListener('popstate', applyCustomStyles);
  130. document.addEventListener("DOMContentLoaded", applyCustomStyles);
  131.  
  132. // MutationObserver for dynamically loaded content
  133. let styleTimeout;
  134. const observer = new MutationObserver((mutationsList) => {
  135. clearTimeout(styleTimeout);
  136. styleTimeout = setTimeout(() => {
  137. for (let mutation of mutationsList) {
  138. if (mutation.type === 'childList' || mutation.type === 'attributes') {
  139. applyCustomStyles();
  140. break;
  141. }
  142. }
  143. }, 100);
  144. });
  145.  
  146. observer.observe(document.body, {
  147. childList: true,
  148. subtree: true,
  149. attributes: true
  150. });
  151.  
  152. // Hook into fetch() to handle dynamically loaded content
  153. const originalFetch = window.fetch;
  154. window.fetch = async function(...args) {
  155. const response = await originalFetch(...args);
  156. applyCustomStyles();
  157. return response;
  158. };
  159. })();