自建覆盖层显示双语:英文在上中文在下;零/负行距紧贴;独立背景;可调字号与垂直位置与行距;默认更大字号 130%。
A Tampermonkey userscript that enhances the Coursera video player by displaying dual-language subtitles in a highly customizable overlay. It replaces the native subtitle display to provide precise control over layout, font size, vertical position, and the spacing between subtitle lines.
一份油猴(Tampermonkey)脚本,它通过一个高度可定制的覆盖层(Overlay)来增强 Coursera 视频播放器的体验。脚本会接管并隐藏原生字幕,从而实现对字幕布局、字号、垂直位置、以及两行字幕间距的精确控制。
+ and - to adjust the size.↑ and ↓ to move the subtitles vertically.+ and - to control the space between the two subtitle lines.You can easily change the default settings by editing the script:
/********* 可配置默认 *********/
const PRIMARY_LANG = 'en'; // Default top language
const SECONDARY_LANG = 'zh-CN'; // Default bottom language
const DEFAULT_BOTTOM_PERCENT= 8; // Initial vertical position (percentage from bottom)
const DEFAULT_FONT_SIZE = 130; // Initial font size (percentage)
const DEFAULT_LINE_GAP_EM = -0.05; // Initial gap between lines (in 'em' units)
/********************************/
Change the language codes (e.g., 'fr' for French, 'es' for Spanish) or numerical values to fit your needs.
+ 和 - 按钮调整字体大小。↑ 和 ↓ 按钮来垂直移动字幕。+ 和 - 按钮来控制中英文字幕之间的间隙。你可以通过编辑脚本来轻松修改默认设置:
/********* 可配置默认 *********/
const PRIMARY_LANG = 'en'; // 默认上方语言
const SECONDARY_LANG = 'zh-CN'; // 默认下方语言
const DEFAULT_BOTTOM_PERCENT= 8; // 初始垂直位置 (距底部百分比)
const DEFAULT_FONT_SIZE = 130; // 初始字体大小 (百分比)
const DEFAULT_LINE_GAP_EM = -0.05; // 初始行距 (单位 'em', 可为负)
/********************************/
只需修改语言代码(例如,'fr' 代表法语, 'es' 代表西班牙语)或数字,即可满足你的个性化需求。
This script is released under the MIT License. 本脚本基于 MIT 许可证发布。