fixed youtube captions

Some of youtube entancer of mine

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         fixed youtube captions
// @namespace    http://www.chaochaogege.com
// @version      0.9.1
// @description  Some of youtube entancer of mine
// @author       iamwwc
// @match        https://www.youtube.com/*
// @grant        none
// @require https://greasyfork.org/scripts/402597-monitor-dom-change/code/monitor%20dom%20change.js?version=801281
// @run-at document-end
// ==/UserScript==

!function youtubeofmine() {
  const over = document.querySelector('body')
  let container = document.querySelector('body')
  function start() {
    // const subtitlesdiv = document.querySelector('.caption-window')
    function addMultipleListener(target, events, fn, useCapture) {
      for (const e of events) {
        target.addEventListener(e, fn, useCapture)
      }
    }
    addMultipleListener(container, ['click', 'touchstart', 'mouseout', 'mousedown', 'mousemove'], e => {
      for (let idx = 0; idx < 5; idx++) {
        if (e.path[idx].className.includes('caption-window')) {
          e.stopPropagation()
          return
        }
      }
    }, true)
    monitordom(over, (lists) => {
      if (lists.addedNodes.length > 0) {
        const n = lists.addedNodes[0]
        if (typeof n.className == 'string') {
          if (n.className.includes('ytp-caption-segment')) {
            let stylelists = n.style
            stylelists['user-select'] = 'text'
          }
        }
      }
    }, { attributes: true, childList: true, subtree: true })
  }
  start()
}()