Youtube 字幕翻譯重疊修復、字幕字形改微軟正黑體

Youtube caption overlap repair.

  1. // ==UserScript==
  2. // @require http://code.jquery.com/jquery-3.4.1.min.js
  3. // @require https://gf.qytechs.cn/scripts/37236-monkeyconfig/code/MonkeyConfig.js
  4. // @name Youtube 字幕翻譯重疊修復、字幕字形改微軟正黑體
  5. // @namespace https://github.com/InterfaceGUI/
  6. // @version 1.1
  7. // @description Youtube caption overlap repair.
  8. // @author LarsHagrid
  9. // @grant GM_addStyle
  10. // @grant GM_getValue
  11. // @grant GM_setValue
  12. // @grant GM_registerMenuCommand
  13. // @include http*://*.youtube.com/*
  14. // @include http*://youtube.com/*
  15. // @include http*://*.youtu.be/*
  16. // @include http*://youtu.be/*
  17. // ==/UserScript==
  18.  
  19. var fsize = [];
  20. for(var i = 2; i < 100; i+=2){
  21. fsize.push(i);
  22. }
  23.  
  24. var cfg = new MonkeyConfig({
  25. title: 'Setting 設置',
  26. menuCommand: true,
  27. params: {
  28. font_size: {
  29. type: 'select',
  30. choices: fsize,
  31. default: '40'
  32. },
  33. font_weight: {
  34. type: 'select',
  35. choices: ['bold','bolder','normal','lighter'],
  36. default: 'bold'
  37. },
  38. font: {
  39. type: 'text',
  40. default: 'Microsoft JhengHei'
  41. }
  42. }
  43. });
  44.  
  45. var fontSize = cfg.get('font_size');
  46. var font = cfg.get('font');
  47. var fontWeight = cfg.get('font_weight');
  48.  
  49. //字體更改
  50. //font-family:字型清單
  51. //font-weight:字型樣式
  52. //webkit-text-stroke:字型外框
  53. function setFont(){
  54. GM_addStyle(`
  55. .ytp-caption-segment{
  56. font-family: `+ font +`,"Monotype Corsiva", "URW Chancery L", "Apple Chancery", "Dancing Script", cursive !important;
  57. font-weight: `+ fontWeight +` !important;
  58. font-size: `+ fontSize +`pt !important;
  59. -webkit-text-stroke: 1.5px black !important;
  60. }
  61. ` )};
  62.  
  63. var $ = window.jQuery;
  64. 'use strict';
  65.  
  66.  
  67. $(document).ready(function () {
  68. setFont();
  69. setInterval(CCFixs, 10); //檢查字幕重疊頻率(10ms)
  70. setInterval(CheckConfiguration, 1000);
  71. });
  72.  
  73. function CheckConfiguration() {
  74. if (fontSize == cfg.get('font_size') && font == cfg.get('font') && fontWeight == cfg.get('font_weight')){
  75. }else{
  76. fontSize = cfg.get('font_size');
  77. font = cfg.get('font');
  78. fontWeight = cfg.get('font_weight');
  79. setFont();
  80. }
  81.  
  82. }
  83. function CCFixs() {
  84. var temp1 = ["", ""];
  85.  
  86. $(".caption-window").each(function (index, element) {
  87. temp1[index] = $(this).attr('id').replace("caption-window-_", "");
  88. })
  89. if (parseInt(temp1[0]) > parseInt(temp1[1])) {
  90. $("#caption-window-_" + temp1[1]).remove();
  91. } else if (parseInt(temp1[0]) < parseInt(temp1[1])) {
  92. $("#caption-window-_" + temp1[0]).remove();
  93. }
  94. }
  95.  
  96.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址