Greasy Fork

Greasy Fork is available in English.

CC字幕|查词翻译|

目前支持bilibili,后续加入Youtube。将CC字幕改变成可选择的文本,这样在看英文视频可以能够搭配谷歌翻译、沙拉查词的时候能快速查到不认识的单词。

当前为 2023-10-30 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         CC字幕|查词翻译|
// @namespace    indefined
// @version      0.1
// @description  目前支持bilibili,后续加入Youtube。将CC字幕改变成可选择的文本,这样在看英文视频可以能够搭配谷歌翻译、沙拉查词的时候能快速查到不认识的单词。
// @author       kenny
// @match        https://www.bilibili.com/*
// @license      MIT
// @grant        none
// ==/UserScript==
(function () {
	'use strict';
	let stopBilibiliTextPropagation = function stopBilibiliTextPropagation() {
		let text = document.getElementsByClassName('bpx-player-subtitle-panel-text');
		if (text.length > 0) {
			let wrap = text[0];
			wrap.style['user-select'] = 'text';
			wrap.addEventListener('mousedown', function (e) {
				e.stopPropagation();
				return;
			});

		} else {
			// Handle the case where no elements were found
			console.log("Bilibili: No elements found with the specified class name.");
		}
	}


	let registBilibili = function(){
		const targetNode = document.getElementsByClassName('bpx-player-control-wrap')[0];
		const callback = function (mutationsList, observer) {
			mutationsList.forEach(mutation => {
				stopBilibiliTextPropagation();
			});
		};

		const observer = new MutationObserver(callback);

		const config = { attributes: true, childList: true, subtree: true };

		if (targetNode) {
			observer.observe(targetNode, config);
		} else {
			console.error('Target node not found');
		}
	}
	
	setTimeout(registBilibili, 5000);
})();