fixed youtube captions

Some of youtube entancer of mine

  1. // ==UserScript==
  2. // @name fixed youtube captions
  3. // @namespace http://www.chaochaogege.com
  4. // @version 0.9.1
  5. // @description Some of youtube entancer of mine
  6. // @author iamwwc
  7. // @match https://www.youtube.com/*
  8. // @grant none
  9. // @require https://greasyfork.org/scripts/402597-monitor-dom-change/code/monitor%20dom%20change.js?version=801281
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13. !function youtubeofmine() {
  14. const over = document.querySelector('body')
  15. let container = document.querySelector('body')
  16. function start() {
  17. // const subtitlesdiv = document.querySelector('.caption-window')
  18. function addMultipleListener(target, events, fn, useCapture) {
  19. for (const e of events) {
  20. target.addEventListener(e, fn, useCapture)
  21. }
  22. }
  23. addMultipleListener(container, ['click', 'touchstart', 'mouseout', 'mousedown', 'mousemove'], e => {
  24. for (let idx = 0; idx < 5; idx++) {
  25. if (e.path[idx].className.includes('caption-window')) {
  26. e.stopPropagation()
  27. return
  28. }
  29. }
  30. }, true)
  31. monitordom(over, (lists) => {
  32. if (lists.addedNodes.length > 0) {
  33. const n = lists.addedNodes[0]
  34. if (typeof n.className == 'string') {
  35. if (n.className.includes('ytp-caption-segment')) {
  36. let stylelists = n.style
  37. stylelists['user-select'] = 'text'
  38. }
  39. }
  40. }
  41. }, { attributes: true, childList: true, subtree: true })
  42. }
  43. start()
  44. }()