fixed youtube captions

Some of youtube entancer of mine

目前为 2020-06-28 提交的版本。查看 最新版本

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