Pure Bing Addon

使 Stylus 样式也可应用于 Shadow DOM 元素。

  1. // ==UserScript==
  2. // @name Pure Bing Addon
  3. // @name:en Pure Bing Addon
  4. // @namespace
  5. // @version 1.0.2
  6. // @license AGPLv3
  7. // @author jcunews
  8. // @description 使 Stylus 样式也可应用于 Shadow DOM 元素。
  9. // @description:en Make Stylus styles also be applied to Shadow DOM elements.
  10. // @match *://*.bing.com/search?*
  11. // @grant none
  12. // @run-at document-start
  13. // ==/UserScript==
  14.  
  15. var style = document.createElement('style');
  16. style.setAttribute("id","stylus-62");
  17. style.textContent = `
  18. cib-see-more-container, #waitListDefault {
  19. background: var(--bg2);
  20. }
  21. cib-feedback, .ac-container a.tooltip-target.hover, .ac-container span.tooltip-target.hover,
  22. .container {
  23. background: var(--bg3);
  24. }
  25.  
  26. #waitListDefault {
  27. color: var(--fg1);
  28. }
  29. .content .ac-container .ac-textBlock *, div[aria-label="Learn more:"] span {
  30. color: var(--fg2) !important;
  31. }
  32.  
  33. #waitListDefault.containerWidth .actionContainer .link.secondary {
  34. color: var(--blue);
  35. }
  36.  
  37. .fade {
  38. background: linear-gradient(rgba(249, 249, 249, 0) 0%, var(--bg2) calc(100% - 28px)) !important;
  39. }
  40. body {
  41. --cib-color-brand-gradient-core: linear-gradient(81.62deg, var(--blue) 8.72%, var(--green) 85.01%);
  42. --cib-color-brand-solid-denim: var(--blue);
  43. }
  44. #waitListDefault .actionContainer .link.primary {
  45. background: var(--cib-color-brand-gradient-core);
  46. }`;
  47. // document.body.appendChild(style);
  48.  
  49.  
  50. ((updDelay, ass, eas, at) => {
  51. function chkNode(e) {
  52. return (e.tagName === "STYLE") && /^stylus-/.test(e.id)
  53. }
  54. function applyStylus(ss) {
  55. ss = document.querySelectorAll('html>style[id^="stylus-"]');
  56. ass.forEach(e => {
  57. if (!e.shadowRoot) return;
  58. Array.from(e.shadowRoot.children).forEach(el => chkNode(el) && el.remove());
  59. // ss.forEach(el => e.shadowRoot.append(el.cloneNode(true)))
  60. e.shadowRoot.append(style.cloneNode(true))
  61. })
  62. }
  63. updDelay = 500;
  64. ass = [];
  65. eas = Element.prototype.attachShadow;
  66. Element.prototype.attachShadow = function() {
  67. !ass.includes(this) && ass.push(this);
  68. clearTimeout(at);
  69. at = setTimeout(applyStylus, updDelay);
  70. return eas.apply(this, arguments)
  71. };
  72. at = 0;
  73. if (!document.documentElement) return;
  74. (new MutationObserver(function(recs, b) {
  75. recs.forEach(rec => {
  76. rec.addedNodes.forEach(e => {
  77. if (!chkNode(e)) return;
  78. (e.obs = new MutationObserver(function(recs, b) {
  79. clearTimeout(at);
  80. at = setTimeout(applyStylus, updDelay);
  81. })).observe(e, {characterData: true, subtree: true});
  82. b = true
  83. });
  84. rec.removedNodes.forEach(e => {
  85. if (!e.obs) return
  86. e.obs.disconnect();
  87. b = true
  88. });
  89. });
  90. if (b) {
  91. clearTimeout(at);
  92. at = setTimeout(applyStylus, updDelay);
  93. }
  94. })).observe(document.documentElement, {childList: true});
  95. })();

QingJ © 2025

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