OPENREC.tv Screen Comment Scroller [Fix]

OPENREC.tv のコメントをニコニコ風にスクロールさせます。

// ==UserScript==
// @name                OPENREC.tv Screen Comment Scroller [Fix]
// @description         OPENREC.tv のコメントをニコニコ風にスクロールさせます。
// @version             1.1
// @author              Yos_sy
// @match               https://www.openrec.tv/*
// @namespace           http://tampermonkey.net/
// @icon                data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAr/ElEQVR4Xu19d1gUd/f9+7x/vH/9nq+ippjEqHnTY0NjwQr23jC2xN6jsURF7A2RoiKgYsEexV5iLxF7772gYAUEFSwoCnt+587swDLssoBL8+U+z33cLDOzs3POPffczwzkX/+yQQBwZAYjP7IrgpmOehyyPXgSBZjlmIMQH385xSnmR9aFeq0HQb32BfS4ZFsYT8BHOaE3b+JSnGR+ZF3ItVZJ4MMsp8clywLJFS+SL5lf+TkZyUqg4ZG1imD8AGFdsJL5lZ+zkawEwca0rSIgv+LzVqRUhCp6PDMcyK/4vBWpFcFFj2m6Avnu/sMIFbvv9PhaDeS7+w8jjIqgx9dqIH9h50OLwXqM0wzkE+BDiwA9xmYD+b3/w4z0egHk9/4PM5KnA3s95ikC+dL/oUcw81M97kmBfAJ86BEMc3cRkd/7/zcieaUw5T0D4xv5vf9DD3N3EfG/uMZvMACJiUDcayDqKXA/EgiLAEKZdx/zv6OBR0+AiGf8eSzw9AXwnHURFw+8fafuK8fIq2Fyz0AI8L+3xi8AxhPMhwT+0Blg/T5g6W5g8R5gxQFg3VFgyylgzzn+/ApwJgS48ZDbkxgxL9V95Rh5NUzuGQgB8l4YePETCcK7V6zIGCarNIHVnJiQvsp8x+1eke/X7xDwrcDkQGDwHOD3AGDIQmDkcmDSKsB7AzCLP1+8F9hwBNhLQpy8AVy7S8UgeSKpEDFUh1f87Ldv86Qy5E0CCPjxlOhXYUDsJcozqzSOgLyNU0lgLUTGY58DZ7nfTILdyx1oOg5wGg3UnwA0mQy0ngq09wY6s1329qdgzgNGLQW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+KEuSH+UiufMG6QBIBTIgg7SDYdJ/8+KAiGJrsmwv5oXGj/PgwIxhWCJDvBT7EsNT79YF8L/BhhrXerw/kt4IPLYKRlvTrQzY27pQfH0YEI4MEyPcCH0Kkt/frgxv/P+bXzK75XiAPR0Z7v7ngjm2gSsiHc8/gQw2TNX5jZqzyLQUP8imzCvIVIXeHyRq/MTNf+ZaCB3RBviLkjsiqircWUNVAGJa/XpCTkR0Vn1YYPzB/WsjuyKy7t3Ugf+UwZ8IW7t6WgfyFo+yOYGRkYSeN+P94Uw4LhO8XlAAAAABJRU5ErkJggg==
// @license             MIT
// @grant               none
// ==/UserScript==

(function () {
  "use strict";

  // スクリプト名
  const SCRIPTNAME = "ScreenCommentScroller";

  // カスタマイズ設定のデフォルト
  const defaultSettings = {
    COLOR: "FFFFFF", // コメント色
    OCOLOR: "000000", // コメント縁取り色
    OWIDTH: 0.1, // コメント縁取りの太さ(比率)
    OPACITY: 0.5, // コメントの不透明度
    MAXLINES: 15, // コメント最大行数
    LINEHEIGHT: 1.5, // コメント行高さ
    DURATION: 5, // スクロール秒数
    FPS: 60, // 秒間コマ数
  };

  // 設定の保存と読み込み
  const loadSettings = () => {
    const savedSettings = JSON.parse(localStorage.getItem(SCRIPTNAME) || "{}");
    return { ...defaultSettings, ...savedSettings };
  };

  const saveSettings = (settings) => {
    localStorage.setItem(SCRIPTNAME, JSON.stringify(settings));
  };

  let settings = loadSettings();

  // 色の検証と変換
  const validateColor = (color) => {
    color = color.replace(/^#/, "");
    return /^[0-9A-Fa-f]{6}$/.test(color) ? `#${color}` : null;
  };

  // 設定パネルの作成
  const createSettingsPanel = () => {
    const panel = document.createElement("div");
    panel.id = `${SCRIPTNAME}_settingsPanel`;
    panel.style.position = "fixed";
    panel.style.top = "10px";
    panel.style.right = "10px";
    panel.style.backgroundColor = "#535069CC";
    panel.style.color = "#ffffff";
    panel.style.padding = "20px";
    panel.style.borderRadius = "10px";
    panel.style.boxShadow = "0 0 10px #00000080";
    panel.style.zIndex = "9999";
    panel.style.display = "none";
    panel.style.fontFamily = "Arial, sans-serif";
    panel.style.maxWidth = "300px";

    // ボタンスタイルの作成
    const setButtonStyle = (button) => {
      button.style.display = "block";
      button.style.width = "100%";
      button.style.padding = "8px";
      button.style.backgroundColor = "#FF4C11";
      button.style.color = "white";
      button.style.border = "none";
      button.style.borderRadius = "3px";
      button.style.cursor = "pointer";
    };

    // リセットボタンの設定
    const resetButton = document.createElement("button");
    resetButton.textContent = "デフォルト値にリセット";
    setButtonStyle(resetButton);
    resetButton.style.marginBottom = "15px";
    resetButton.onclick = () => {
      if (
        confirm(
          "設定をデフォルト値にリセットしますか?この操作は元に戻せません。"
        )
      ) {
        settings = { ...defaultSettings };
        saveSettings(settings);
        updateSettingsUI();
        core.applySettings();
      }
    };
    panel.appendChild(resetButton);

    // 入力フィールドの設定
    const createInput = (labelText, key, type = "text") => {
      const container = document.createElement("div");
      container.style.marginBottom = "10px";

      const label = document.createElement("label");
      label.textContent = labelText;
      label.style.display = "block";
      label.style.marginBottom = "5px";

      const input = document.createElement("input");
      input.id = `${SCRIPTNAME}_${key}`;
      input.type = type;
      input.value = settings[key];
      input.style.width = "100%";
      input.style.padding = "5px";
      input.style.boxSizing = "border-box";
      input.style.backgroundColor = "#FFFFFF1A";
      input.style.border = "1px solid #FFFFFF4D";
      input.style.borderRadius = "3px";
      input.style.color = "#FFFFFF";
      if (type === "number") {
        input.step = "0.1";
      }
      input.onchange = (e) => {
        let value = e.target.value;
        if (type === "color") {
          value = validateColor(value);
          if (!value) {
            alert("無効な色形式です。6桁の16進数を使用してください。");
            e.target.value = `#${settings[key]}`;
            return;
          }
        }
        settings[key] =
          type === "number" ? parseFloat(value) : value.replace(/^#/, "");
        saveSettings(settings);
        core.applySettings();
        updateSettingsUI();
      };

      if (type === "color") {
        input.value = `#${settings[key]}`;
      }

      container.appendChild(label);
      container.appendChild(input);
      panel.appendChild(container);
    };

    createInput("コメント色", "COLOR", "color");
    createInput("コメント縁取り色", "OCOLOR", "color");
    createInput("縁取りの太さ", "OWIDTH", "number");
    createInput("不透明度", "OPACITY", "number");
    createInput("最大行数", "MAXLINES", "number");
    createInput("行高さ", "LINEHEIGHT", "number");
    createInput("スクロール秒数", "DURATION", "number");
    createInput("秒間コマ数", "FPS", "number");

    // 閉じるボタンの設定
    const closeButton = document.createElement("button");
    closeButton.textContent = "閉じる";
    setButtonStyle(closeButton);
    closeButton.style.marginTop = "15px";
    closeButton.onclick = () => {
      panel.style.display = "none";
    };
    panel.appendChild(closeButton);

    document.body.appendChild(panel);
  };

  // 設定UIの更新
  const updateSettingsUI = () => {
    Object.keys(settings).forEach((key) => {
      const input = document.getElementById(`${SCRIPTNAME}_${key}`);
      if (input) {
        if (input.type === "color") {
          input.value = `#${settings[key]}`;
        } else {
          input.value = settings[key];
        }
      }
    });
  };

  // 設定パネルの表示切り替え
  const toggleSettingsPanel = () => {
    const panel = document.getElementById(`${SCRIPTNAME}_settingsPanel`);
    panel.style.display = panel.style.display === "none" ? "block" : "none";
  };

  // キーボードショートカットの設定
  document.addEventListener("keydown", (e) => {
    if (e.ctrlKey && e.altKey && e.key === "o") {
      toggleSettingsPanel();
    }
  });

  // キャッシュ
  const cache = {
    screen: null,
    board: null,
    play: null,
  };

  const getElement = (key, selector) => {
    if (!cache[key]) {
      cache[key] = document.querySelector(selector);
    }
    return cache[key];
  };

  // サイト定義
  const site = {
    getScreen: () => getElement("screen", ".video-player-wrapper"),
    getBoard: () => getElement("board", ".chat-list-content"),
    getComments: (node) => node.querySelectorAll(".chat-content"),
    getPlay: () =>
      getElement(
        "play",
        '[class^="MovieToolbar"] [class^="TextLabel__Wrapper"]'
      ),
    isPlaying: () => true, // 常に再生中と仮定
  };

  // 処理本体
  let screen,
    board,
    play,
    canvas,
    context,
    lines = [],
    fontsize;

  const core = {
    // 初期化
    initialize: () => {
      console.log(SCRIPTNAME, "initialize...");
      screen = site.getScreen();
      board = site.getBoard();
      play = site.getPlay();
      if (!screen || !board || !play) {
        window.setTimeout(core.initialize, 1000);
        return;
      }

      canvas = document.createElement("canvas");
      canvas.id = SCRIPTNAME;
      screen.appendChild(canvas);
      context = canvas.getContext("2d");

      core.applySettings();
      core.listenComments();
      core.scrollComments();
      createSettingsPanel();
    },

    // 設定の適用
    applySettings: () => {
      core.modify();
      core.addStyle();
    },

    // キャンバスのサイズ調整とフォント設定
    modify: () => {
      const newWidth = screen.offsetWidth;
      const newHeight = screen.offsetHeight;
      canvas.width = newWidth;
      canvas.height = newHeight;
      fontsize = newHeight / settings.MAXLINES / settings.LINEHEIGHT;
      context.font = `bold ${fontsize}px sans-serif`;
      context.fillStyle = validateColor(settings.COLOR) || "#FFFFFF";
      context.strokeStyle = validateColor(settings.OCOLOR) || "#000000";
      context.lineWidth = fontsize * settings.OWIDTH;
    },

    // スタイル追加
    addStyle: () => {
      let canvas = document.querySelector(`canvas#${SCRIPTNAME}`);
      if (!canvas) {
        canvas = document.createElement("canvas");
        canvas.id = SCRIPTNAME;
        document.body.appendChild(canvas);
      }

      // キャンバスのスタイル追加
      canvas.style.pointerEvents = "none";
      canvas.style.position = "absolute";
      canvas.style.top = "0";
      canvas.style.left = "0";
      canvas.style.width = "100%";
      canvas.style.height = "100%";
      canvas.style.opacity = `${settings.OPACITY}`;
      canvas.style.zIndex = "calc(infinity)";
    },

    // コメントの監視
    listenComments: () => {
      board.addEventListener("DOMNodeInserted", (e) => {
        const comments = site.getComments(e.target);
        if (!comments || !comments.length) return;
        for (let comment of comments) {
          core.attachComment(comment);
        }
      });
    },

    // コメントの追加
    attachComment: (comment) => {
      const text = comment.textContent;
      const width = context.measureText(text).width;
      const life = settings.DURATION * settings.FPS;
      const left = canvas.width;
      const delta = (canvas.width + width) / life;

      for (let i = 0; i < settings.MAXLINES; i++) {
        const line = lines[i] || [];
        if (
          line.length === 0 ||
          line[line.length - 1].left < canvas.width - width
        ) {
          lines[i] = line;
          line.push({
            text,
            width,
            life,
            left,
            delta,
            top: (canvas.height / settings.MAXLINES) * i + fontsize,
          });
          break;
        }
      }
    },

    // コメントのスクロール
    scrollComments: () => {
      let lastTime = 0;
      const animate = (currentTime) => {
        if (site.isPlaying()) {
          const deltaTime = (currentTime - lastTime) / 1000;
          lastTime = currentTime;

          context.clearRect(0, 0, canvas.width, canvas.height);

          lines.forEach((line, i) => {
            lines[i] = line.filter((comment) => {
              comment.life -= deltaTime * settings.FPS;
              comment.left -= comment.delta * deltaTime * settings.FPS;
              if (comment.left + comment.width > 0) {
                context.strokeText(comment.text, comment.left, comment.top);
                context.fillText(comment.text, comment.left, comment.top);
                return true;
              }
              return false;
            });
          });
        }
        requestAnimationFrame(animate);
      };
      requestAnimationFrame(animate);
    },
  };

  core.initialize();
})();