YouTube Sticky Live Chat

Pin the latest message written by live owner or moderator to the top

  1. // ==UserScript==
  2. // @name YouTube Sticky Live Chat
  3. // @name:ja YouTube Sticky Live Chat
  4. // @namespace https://i544c.github.io
  5. // @version 0.4.1
  6. // @description Pin the latest message written by live owner or moderator to the top
  7. // @description:ja 生放送主とモデレータの最新のコメントを上に固定するユーザスクリプト
  8. // @author i544c
  9. // @match https://www.youtube.com/live_chat*
  10. // @match https://www.youtube.com/live_chat_replay*
  11. // @grant none
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. (() => {
  16. const style = document.createElement('style');
  17. style.textContent = `
  18. yt-live-chat-app {
  19. /* Global variables */
  20. --ysl-line-length: 3;
  21. --ysl-message-height: calc(1em * var(--ysl-line-length) + 4px);
  22. }
  23.  
  24. #item-offset {
  25. overflow: visible !important;
  26. }
  27.  
  28. #items {
  29. transform: none !important;
  30. }
  31.  
  32. yt-live-chat-text-message-renderer[author-type="owner"],
  33. yt-live-chat-text-message-renderer[author-type="moderator"] {
  34. background: var(--yt-live-chat-message-highlight-background-color);
  35. position: sticky;
  36. top: -1px;
  37. z-index: 1;
  38. height: var(--ysl-message-height);
  39. min-height: var(--ysl-message-height);
  40. }
  41.  
  42. yt-live-chat-text-message-renderer[author-type="owner"]:hover,
  43. yt-live-chat-text-message-renderer[author-type="moderator"]:hover {
  44. height: 100% !important;
  45. }
  46.  
  47. yt-live-chat-text-message-renderer[author-type="owner"] #content,
  48. yt-live-chat-text-message-renderer[author-type="moderator"] #content {
  49. align-self: normal;
  50. /* String truncate */
  51. display: -webkit-box;
  52. -webkit-box-orient: vertical;
  53. -webkit-line-clamp: var(--ysl-line-length);
  54. overflow: hidden;
  55. }
  56.  
  57. yt-live-chat-text-message-renderer[author-type="owner"] #content:hover,
  58. yt-live-chat-text-message-renderer[author-type="moderator"] #content:hover {
  59. -webkit-box-orient: inline-axis;
  60. }
  61. `;
  62. document.body.appendChild(style);
  63. })();

QingJ © 2025

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