Greasy Fork

Greasy Fork is available in English.

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

Youtube caption overlap repair.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @require      http://code.jquery.com/jquery-3.4.1.min.js
// @require      http://greasyfork.icu/scripts/37236-monkeyconfig/code/MonkeyConfig.js
// @name         Youtube 字幕翻譯重疊修復、字幕字形改微軟正黑體
// @namespace    https://github.com/InterfaceGUI/
// @version      1.1
// @description  Youtube caption overlap repair.
// @author       LarsHagrid
// @grant        GM_addStyle
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_registerMenuCommand
// @include      http*://*.youtube.com/*
// @include      http*://youtube.com/*
// @include      http*://*.youtu.be/*
// @include      http*://youtu.be/*
// ==/UserScript==

var fsize = [];
for(var i = 2; i < 100; i+=2){
  fsize.push(i);
}

var cfg = new MonkeyConfig({
    title: 'Setting 設置',
    menuCommand: true,
    params: {
        font_size: {
            type: 'select',
            choices: fsize,
            default: '40'
        },
        font_weight: {
            type: 'select',
            choices: ['bold','bolder','normal','lighter'],
            default: 'bold'
        },
        font: {
            type: 'text',
            default: 'Microsoft JhengHei'
        }
    }
});

var fontSize = cfg.get('font_size');
var font = cfg.get('font');
var fontWeight = cfg.get('font_weight');

//字體更改
//font-family:字型清單
//font-weight:字型樣式
//webkit-text-stroke:字型外框
function setFont(){
    GM_addStyle(`
    .ytp-caption-segment{
            font-family: `+ font +`,"Monotype Corsiva", "URW Chancery L", "Apple Chancery", "Dancing Script", cursive !important;
            font-weight: `+ fontWeight +` !important;
            font-size: `+ fontSize +`pt !important;
            -webkit-text-stroke: 1.5px black !important;
    }
` )};

var $ = window.jQuery;
'use strict';


$(document).ready(function () {
    setFont();
    setInterval(CCFixs, 10); //檢查字幕重疊頻率(10ms)
    setInterval(CheckConfiguration, 1000);
});

function CheckConfiguration() {
    if (fontSize == cfg.get('font_size') && font == cfg.get('font') && fontWeight == cfg.get('font_weight')){
    }else{
        fontSize = cfg.get('font_size');
        font = cfg.get('font');
        fontWeight = cfg.get('font_weight');
        setFont();
    }

}
function CCFixs() {
    var temp1 = ["", ""];

    $(".caption-window").each(function (index, element) {
        temp1[index] = $(this).attr('id').replace("caption-window-_", "");
    })
    if (parseInt(temp1[0]) > parseInt(temp1[1])) {
        $("#caption-window-_" + temp1[1]).remove();
    } else if (parseInt(temp1[0]) < parseInt(temp1[1])) {
        $("#caption-window-_" + temp1[0]).remove();
    }
}