Serieslan Enhancements

Select video provider option automatically and change the background color of the page to improve visibility and reduce eye strain

  1. // ==UserScript==
  2. // @name Serieslan Enhancements
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Select video provider option automatically and change the background color of the page to improve visibility and reduce eye strain
  6. // @author JJJ
  7. // @match https://serieslan.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=serieslan.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. // Constants
  17. const CLASS_SELECTOR = 'div.sels > button.selop';
  18. const STORAGE_KEY = 'selectedOption';
  19.  
  20. // CSS styles for the custom menu and page background
  21. const menuStyles = `
  22. /* Set background color to #2F353A for all elements */
  23. body,div, li, ul, header, footer {
  24. background-color: #2F353A !important;
  25. }
  26. /* Set text color to white for all text elements */
  27. body, p, h1, h2, h3, h4, h5, h6, span, a, li, div:not(#customMenu div), button:not(#customMenu button) {
  28. color: white !important;
  29. }
  30. /* Additional styles to improve visibility on links, if needed */
  31. a:not(#customMenu a) {
  32. text-decoration: underline !important;
  33. }
  34. #customMenu {
  35. position: fixed;
  36. top: 50%;
  37. left: 50%;
  38. transform: translate(-50%, -50%);
  39. background-color: rgba(255, 255, 255, 0.95) !important; /* Ensure background color is not overridden */
  40. border: 2px solid #000;
  41. padding: 15px;
  42. z-index: 9999;
  43. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  44. border-radius: 8px;
  45. font-family: Arial, sans-serif;
  46. width: 300px;
  47. text-align: center;
  48. color: black !important; /* Ensure text color is not overridden */
  49. }
  50. #customMenu select {
  51. width: 100% !important;
  52. padding: 10px !important;
  53. margin-bottom: 10px !important;
  54. border: 1px solid #ccc !important;
  55. border-radius: 4px !important;
  56. background-color: #FFFFFF !important; /* Ensure background color is white */
  57. color: black !important; /* Ensure text color is not overridden */
  58. -webkit-appearance: none !important; /* Disable default styling */
  59. -moz-appearance: none !important; /* Disable default styling */
  60. appearance: none !important; /* Disable default styling */
  61. }
  62. #customMenu button {
  63. padding: 10px 20px;
  64. border: none;
  65. background-color: #007bff !important; /* Ensure background color is not overridden */
  66. color: white !important; /* Ensure text color is not overridden */
  67. font-size: 14px;
  68. cursor: pointer;
  69. border-radius: 4px;
  70. }
  71. #customMenu button:hover {
  72. background-color: #0056b3 !important; /* Ensure hover background color is not overridden */
  73. }
  74. `;
  75.  
  76. // Function to create the dropdown menu
  77. function createDropdownMenu(options) {
  78. const dropdownMenu = document.createElement('select');
  79. dropdownMenu.id = 'optionDropdown';
  80.  
  81. options.forEach((option) => {
  82. const dropdownOption = document.createElement('option');
  83. dropdownOption.value = option.getAttribute('title') || option.textContent.trim();
  84. dropdownOption.textContent = option.getAttribute('title') || option.textContent.trim();
  85. dropdownMenu.appendChild(dropdownOption);
  86. });
  87.  
  88. return dropdownMenu;
  89. }
  90.  
  91. // Function to toggle the menu visibility
  92. function toggleMenu() {
  93. const menu = document.getElementById('customMenu');
  94. if (menu) {
  95. menu.style.display = menu.style.display === 'none' ? 'block' : 'none';
  96. console.log('Menu toggled, new display:', menu.style.display);
  97. } else {
  98. console.log('Menu element not found.');
  99. }
  100. }
  101.  
  102. // Function to handle option selection
  103. function handleOptionSelection() {
  104. const selectedOptionValue = document.getElementById('optionDropdown').value;
  105. const options = document.querySelectorAll(CLASS_SELECTOR);
  106.  
  107. options.forEach((option) => {
  108. if ((option.getAttribute('title') || option.textContent.trim()) === selectedOptionValue) {
  109. option.click();
  110. localStorage.setItem(STORAGE_KEY, selectedOptionValue);
  111. toggleMenu();
  112. }
  113. });
  114. }
  115.  
  116. // Function to create the custom menu
  117. function createCustomMenu() {
  118. const options = document.querySelectorAll(CLASS_SELECTOR);
  119.  
  120. const dropdownMenu = createDropdownMenu(options);
  121. const selectedOptionValue = localStorage.getItem(STORAGE_KEY);
  122. if (selectedOptionValue !== null) {
  123. dropdownMenu.value = selectedOptionValue;
  124. }
  125.  
  126. const confirmButton = document.createElement('button');
  127. confirmButton.textContent = 'Confirm';
  128. confirmButton.addEventListener('click', handleOptionSelection);
  129.  
  130. const customMenu = document.createElement('div');
  131. customMenu.id = 'customMenu';
  132. customMenu.style.display = 'none';
  133. customMenu.appendChild(dropdownMenu);
  134. customMenu.appendChild(confirmButton);
  135.  
  136. document.body.appendChild(customMenu);
  137. console.log('Custom menu created and added to the body');
  138. }
  139.  
  140. // Function to automatically select the saved option
  141. function autoSelectOption() {
  142. const selectedOptionValue = localStorage.getItem(STORAGE_KEY);
  143. if (selectedOptionValue !== null) {
  144. const options = document.querySelectorAll(CLASS_SELECTOR);
  145. options.forEach((option) => {
  146. if ((option.getAttribute('title') || option.textContent.trim()) === selectedOptionValue) {
  147. option.click();
  148. }
  149. });
  150. }
  151. }
  152.  
  153. // Function to initialize the script
  154. function init() {
  155. const styleElement = document.createElement('style');
  156. styleElement.textContent = menuStyles;
  157. document.head.appendChild(styleElement);
  158. console.log('Styles added to the head');
  159.  
  160. createCustomMenu();
  161.  
  162. document.addEventListener('keydown', function (event) {
  163. if (event.key === 'F2') {
  164. console.log('F2 key pressed');
  165. toggleMenu();
  166. }
  167. });
  168.  
  169. setTimeout(autoSelectOption, 100); // Delay execution to allow page load
  170.  
  171. console.log('Script initialized');
  172. }
  173.  
  174. // Run the script
  175. init();
  176. })();