Greasy Fork 支持简体中文。

Put Youtube subtitles on top of everything

Use this script if you want subtitles float on entire screen!

目前為 2020-05-06 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Put Youtube subtitles on top of everything
  3. // @namespace http://www.chaochaogege.com
  4. // @version 0.3
  5. // @description Use this script if you want subtitles float on entire screen!
  6. // @author You
  7. // @match https://www.youtube.com/watch?*
  8. // @grant none
  9. // @require https://greasyfork.org/scripts/402597-monitor-dom-change/code/monitor%20dom%20change.js?version=801281
  10. // ==/UserScript==
  11.  
  12. !function() {
  13. const over = document.querySelector('body')
  14. const player = document.querySelector('.html5-video-player')
  15. let right = ''
  16. let left = ''
  17. let top = ''
  18. let bottom = ''
  19. // const subtitlesdiv = document.querySelector('.caption-window')
  20. monitordom(over,(lists) => {
  21. if (lists.addedNodes.length > 0){
  22. const n = lists.addedNodes[0]
  23. if (typeof n.className == 'string' && n.className.includes('caption-window')) {
  24. let stylelists = n.style
  25. n.style.position = "fixed"
  26. stylelists['top'] = top
  27. stylelists['right'] = right
  28. stylelists['left'] = left
  29. stylelists['bottom'] = bottom
  30. }
  31. }
  32. if(lists.type === 'attributes') {
  33. if (typeof lists.target.className === 'string' && lists.target.className.includes('caption-window')) {
  34. let stylelists = lists.target.style
  35. top = stylelists['top']
  36. bottom = stylelists['bottom']
  37. left = stylelists['left']
  38. right = stylelists['right']
  39. }
  40. }
  41. },{attributes: true, childList: true, subtree: true})
  42. over.style['z-index'] = 4000
  43. over.style.position = 'relative'
  44. player.style['z-index'] = 1
  45. }()