Greasy Fork 还支持 简体中文。

selection-black

1/6/2024, 10:02:43 PM

  1. // ==UserScript==
  2. // @name selection-black
  3. // @namespace Violentmonkey Scripts
  4. // @match *://*/*
  5. // @grant none
  6. // @version 0.0.1
  7. // @author -
  8. // @description 1/6/2024, 10:02:43 PM
  9. // @license GPLv2
  10. // ==/UserScript==
  11.  
  12. // 创建一个新的 style 元素
  13. var style = document.createElement('style');
  14.  
  15. // 设置 CSS 规则
  16. // 注意:这里使用了 ES6 模板字符串来保持 CSS 规则的格式,也可以使用普通的字符串连接
  17. var css = `::selection {
  18. color: #fafafa;
  19. background: #0a0a0a;
  20. }`
  21.  
  22. // 为了兼容不同的浏览器,需要检查一下是否存在某些 DOM 方法
  23. if (style.styleSheet) {
  24. // 这是给 IE 的老版本使用的
  25. style.styleSheet.cssText = css;
  26. } else {
  27. // 其他大部分浏览器
  28. style.appendChild(document.createTextNode(css));
  29. }
  30.  
  31. // 将 style 元素添加到 head 中
  32. document.head.appendChild(style);
  33.