Sparx Maths Enhancements with Dark Mode

Adds productivity tools and dark mode for Sparx Maths platform.

  1. // ==UserScript==
  2. // @name Sparx Maths Enhancements with Dark Mode
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.0
  5. // @description Adds productivity tools and dark mode for Sparx Maths platform.
  6. // @author CyphrNX
  7. // @match *://*.sparxmaths.uk/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13.  
  14. // Inject CSS for custom styles (e.g., timer, dark mode)
  15. const style = document.createElement('style');
  16. style.id = 'custom-style';
  17. style.innerHTML = `
  18. #custom-timer {
  19. position: fixed;
  20. top: 20px;
  21. right: 20px;
  22. background: rgba(0, 0, 0, 0.8);
  23. color: white;
  24. padding: 10px 20px;
  25. border-radius: 10px;
  26. font-size: 16px;
  27. z-index: 9999;
  28. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  29. }
  30. .highlighted {
  31. background-color: yellow !important;
  32. border: 2px solid red !important;
  33. }
  34. .dark-mode {
  35. background-color: #1e1e1e !important;
  36. color: #d4d4d4 !important;
  37. }
  38. .dark-mode input, .dark-mode textarea {
  39. background-color: #2d2d2d !important;
  40. color: #ffffff !important;
  41. border: 1px solid #555 !important;
  42. }
  43. .dark-mode button {
  44. background-color: #444 !important;
  45. color: #fff !important;
  46. border: 1px solid #555 !important;
  47. }
  48. .dark-mode a {
  49. color: #79b8ff !important;
  50. }
  51. `;
  52. document.head.appendChild(style);
  53.  
  54. // Add dark mode toggle button
  55. const darkModeButton = document.createElement('button');
  56. darkModeButton.innerText = 'Toggle Dark Mode';
  57. darkModeButton.style.position = 'fixed';
  58. darkModeButton.style.top = '20px';
  59. darkModeButton.style.left = '20px';
  60. darkModeButton.style.zIndex = '9999';
  61. darkModeButton.style.padding = '10px 20px';
  62. darkModeButton.style.background = '#333';
  63. darkModeButton.style.color = '#fff';
  64. darkModeButton.style.border = 'none';
  65. darkModeButton.style.borderRadius = '5px';
  66. darkModeButton.style.cursor = 'pointer';
  67. darkModeButton.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.2)';
  68. document.body.appendChild(darkModeButton);
  69.  
  70. let darkModeEnabled = false;
  71.  
  72. // Toggle dark mode
  73. darkModeButton.addEventListener('click', () => {
  74. darkModeEnabled = !darkModeEnabled;
  75.  
  76. if (darkModeEnabled) {
  77. document.documentElement.classList.add('dark-mode');
  78. } else {
  79. document.documentElement.classList.remove('dark-mode');
  80. }
  81. });
  82.  
  83. // Highlight key elements
  84. function highlightImportantElements() {
  85. const question = document.querySelector('.question-text'); // Adjust selector based on Sparx
  86. const inputs = document.querySelectorAll('input[type="text"], textarea');
  87.  
  88. if (question) {
  89. question.classList.add('highlighted');
  90. }
  91. inputs.forEach((input) => {
  92. input.classList.add('highlighted');
  93. });
  94. }
  95. highlightImportantElements();
  96.  
  97. // Add a session timer
  98. const timer = document.createElement('div');
  99. timer.id = 'custom-timer';
  100. timer.innerText = 'Session Timer: 0:00';
  101. document.body.appendChild(timer);
  102.  
  103. let seconds = 0;
  104. setInterval(() => {
  105. seconds++;
  106. const minutes = Math.floor(seconds / 60);
  107. const secs = seconds % 60;
  108. timer.innerText = `Session Timer: ${minutes}:${secs < 10 ? '0' : ''}${secs}`;
  109. }, 1000);
  110. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址