Sticky Element Modifier

Make the next element of StoryViewer sticky with a specific background color on bestdori.com/tool/storyviewer/

  1. // ==UserScript==
  2. // @name Sticky Element Modifier
  3. // @namespace https://bestdori.com/
  4. // @version 0.1
  5. // @description Make the next element of StoryViewer sticky with a specific background color on bestdori.com/tool/storyviewer/
  6. // @match https://bestdori.com/tool/storyviewer/*
  7. // @grant none
  8. // @license WTFPL
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // 创建一个观察器实例
  15. const observer = new MutationObserver(function(mutations) {
  16. // 遍历所有的变化
  17. for (let mutation of mutations) {
  18. // 检查是否有新的节点被添加
  19. if (mutation.addedNodes) {
  20. // 遍历所有的新增节点
  21. for (let node of mutation.addedNodes) {
  22. // 检查是否是我们关心的节点
  23. if (node.id === 'StoryViewer') {
  24. // 获取StoryViewer元素的下一个兄弟元素
  25. const nextElement = node.nextElementSibling;
  26.  
  27. // 将下一个元素修改为吸顶,并设置背景颜色
  28. nextElement.style.position = 'sticky';
  29. nextElement.style.top = '52px';
  30. nextElement.style.backgroundColor = 'var(--color-background)';
  31. nextElement.style.zIndex = '9999';
  32.  
  33. // 结束循环
  34. return;
  35. }
  36. }
  37. }
  38. }
  39. });
  40.  
  41. // 配置观察器:观察目标节点的子节点或后代节点的变化
  42. const config = { childList: true, subtree: true };
  43.  
  44. // 开始观察document
  45. observer.observe(document, config);
  46. })();

QingJ © 2025

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