Substack - dark-on-light

Substack - change journal themes to dark-on-light

  1. // ==UserScript==
  2. // @name Substack - dark-on-light
  3. // @namespace Violentmonkey Scripts
  4. // @match *://*.substack.com/*
  5. // @exclude *://substack.com/*
  6. // @version 1.5
  7. // @author jez9999
  8. // @description Substack - change journal themes to dark-on-light
  9. // @require https://code.jquery.com/jquery-3.6.0.min.js
  10. // @run-at document-body
  11. // @grant none
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. // ********************
  19. // Reminder: set the following in Violentmonkey advanced settings for Editor:
  20. // "tabSize": 4,
  21. // "indentUnit": 4,
  22. // "autoCloseBrackets": false,
  23. //
  24. // Also, bear in mind there appears to be a bug in Violentmonkey where after a while, MutationObserver's
  25. // stop being debuggable and the whole browser needs restarting before it'll work again.
  26. // ********************
  27.  
  28. // Allow strings for HTML/CSS/etc. trusted injections
  29. if (window.trustedTypes && window.trustedTypes.createPolicy && !window.trustedTypes.defaultPolicy) {
  30. window.trustedTypes.createPolicy('default', {
  31. createHTML: string => string,
  32. createScriptURL: string => string,
  33. createScript: string => string
  34. });
  35. }
  36.  
  37. var utils = {};
  38. utils.jq = jQuery.noConflict( true );
  39. utils.isUnspecified = function(input) {
  40. return ((typeof input === "undefined") || (input === null));
  41. }
  42. utils.isSpecified = function(input) {
  43. return ((typeof input !== "undefined") && (input !== null));
  44. }
  45.  
  46. // Add styling to DOM
  47. var sheet = document.createElement('style');
  48. sheet.innerHTML = `
  49. :root {
  50. --web_bg_color: #f3f3f3 !important;
  51. --print_on_web_bg_color: #000000 !important;
  52. --cover_bg_color: #ffffff !important;
  53. --print_secondary_on_web_bg_color: #666666 !important;
  54. --background_contrast_1: #ffffff !important;
  55. --background_contrast_2: #f5f4f4 !important;
  56. --background_contrast_3: #e9e9e9 !important;
  57. --background_contrast_4: #dbdbdb !important;
  58. --background_contrast_5: #cacaca !important;
  59. --print_on_pop: #ffffff !important;
  60. --cover_print_primary: #000000 !important;
  61. --cover_print_secondary: #cacaca !important;
  62. --cover_border_color: #000000 !important;
  63. --input_background: #e9e9e9 !important;
  64. --cover_input_background: #e9e9e9 !important;
  65. --tooltip_background: #dbdbdb !important;
  66. --selected_comment_background_color: #f5f4f4 !important;
  67. }
  68. `;
  69. document.head.appendChild(sheet);
  70. })();

QingJ © 2025

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