// ==UserScript== // @name 学外语视频外挂悬浮可点复制翻译字幕(google搜视频在线播-配合欧路词典),Learn-foreign-language-video-clickable-copying-subtitle // @description 电脑建议配合欧路词典划词翻译(查看图片展示设置) , 加减按钮调节字幕偏移时间(有的视频插入了广告导致字幕错位) , 显示按钮:电脑鼠标移动或者移动端触摸屏幕 , 字幕内鼠标滑轮滚动视频快进 , F全屏快捷键,(暂时不好用后期修复) , (alt + s) 快捷键隐藏字幕 , 移动端建议 (需要魔法-iphone下载stay应用长按视频免费下载MP4视频(safari插件),safari长按浏览器网络视频下载) , 地址 : https://translation-of-video-subtitles-by-extracting-words.vercel.app/ , iphone 建议使用快捷指令获取剪贴板翻译 , 安卓手机建议使用屏幕取词软件 // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js // @require https://cdn.bootcss.com/vConsole/3.3.0/vconsole.min.js // @require https://unpkg.com/default-passive-events // @include * // @match *://*/* // @namespace http://tampermonkey.net/ // @version 2024.4.5.14.00.22 // @icon https://www.google.com/s2/favicons?sz=64&domain=greasyfork.org // @author You // @downloadURL https://update.greasyfork.icu/scripts/482259/%E5%AD%A6%E5%A4%96%E8%AF%AD%E8%A7%86%E9%A2%91%E5%A4%96%E6%8C%82%E6%82%AC%E6%B5%AE%E5%8F%AF%E7%82%B9%E5%A4%8D%E5%88%B6%E7%BF%BB%E8%AF%91%E5%AD%97%E5%B9%95%28google%E6%90%9C%E8%A7%86%E9%A2%91%E5%9C%A8%E7%BA%BF%E6%92%AD-%E9%85%8D%E5%90%88%E6%AC%A7%E8%B7%AF%E8%AF%8D%E5%85%B8%29%2CLearn-foreign-language-video-clickable-copying-subtitle.user.js // @updateURL https://update.greasyfork.icu/scripts/482259/%E5%AD%A6%E5%A4%96%E8%AF%AD%E8%A7%86%E9%A2%91%E5%A4%96%E6%8C%82%E6%82%AC%E6%B5%AE%E5%8F%AF%E7%82%B9%E5%A4%8D%E5%88%B6%E7%BF%BB%E8%AF%91%E5%AD%97%E5%B9%95%28google%E6%90%9C%E8%A7%86%E9%A2%91%E5%9C%A8%E7%BA%BF%E6%92%AD-%E9%85%8D%E5%90%88%E6%AC%A7%E8%B7%AF%E8%AF%8D%E5%85%B8%29%2CLearn-foreign-language-video-clickable-copying-subtitle.meta.js // ==/UserScript== (()=>{"use strict";const z=e=>{console.log("%c"+e,` background-color: #811f21; color: white; line-height:1.5rem; padding:0 0.5rem; `)};function R(e){var t;t=e,!(document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement)||t!==document.fullscreenElement&&t!==document.mozFullScreenElement&&t!==document.webkitFullscreenElement&&t!==document.msFullscreenElement?(t=e,z("全屏视频"),t.requestFullscreen?t.requestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.msRequestFullscreen&&t.msRequestFullscreen(),void 0!==window.ActiveXObject&&null!=(e=new ActiveXObject("WScript.Shell"))&&e.SendKeys("{F11}")):(z("退出全屏视频"),document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen())}window.addEventListener("load",(function(){z("视频外挂西悬浮可点复制翻译字幕-floating-plug-in-for-clickable-subtitle-copying"),$("iframe").each((function(){$(this).attr("allowfullscreen","true")})),navigator.mediaSession.setActionHandler("previoustrack",(function(){document.querySelector("video").currentTime-=3})),navigator.mediaSession.setActionHandler("nexttrack",(function(){document.querySelector("video").currentTime+=3}));let i="",s=null;document.addEventListener("selectionchange",(()=>{const e=window?.getSelection()?.toString()||"";e&&/\s/.test(e)&&(s&&window?.clearTimeout(s),s=setTimeout((async()=>{await(navigator?.clipboard?.writeText(e)),window?.getSelection()?.removeAllRanges(),i="",z("1秒后清除剪贴板成功")}),1e3))}));const t=$("video");var e=t.parent(),n=(e=(e.addClass("videoWrapper"),e.css({position:"relative"}),t.append(""),t.attr("controls","true"),t.attr("playsInline","true"),t.attr("autopictureinpicture","true"),$("")),e.on("click",(function(e){e.stopPropagation(),z("全屏开关点击"),R(document.querySelector(".videoWrapper"))})),{"z-index":"2147483647",color:"#fff",position:"absolute",transition:"all 0.2s ease-in-out"}),o={margin:"1vw",display:"block",padding:"0.5vw","border-radius":".5vw","background-color":"#1118","font-size":"1.5vw",cursor:"pointer","user-select":"text","line-height":"2.5rem !important",color:"#fffb",transition:"all 0.2s ease-in-out","backdrop-filter":"blur(4px)"},a=(e.css({...o}),$(""));let r=!1;const l=$("
");a.css({...o});var c=$('意见反馈');c.css({...o});const u=()=>{r=!r,l.css({display:r?"block":"none"})};a.on("click",(function(e){e.stopPropagation(),z("字幕显示开关点击"),u()})),l.click((function(e){z("字幕外层点击"),e.stopPropagation()})),l.on("mousedown",(e=>{e.stopPropagation(),t?.[0].pause(),z("视频暂停")})),l.on("touchstart",(e=>{e.stopPropagation(),t?.[0].pause(),z("视频暂停")}));let p=!1;l.on("mouseup",(async e=>{e.stopPropagation();e=await(navigator?.clipboard?.readText());console.log("window?.getSelection()?.toString() :",i,"-||-",e),window?.getSelection()?.toString()||i===e?(t?.[0].pause(),z("视频暂停")):p||(t?.[0].play(),z("视频播放"))})),l.on("touchend",(async e=>{e.stopPropagation();e=await(navigator?.clipboard?.readText());console.log("window?.getSelection()?.toString() :",i,"-||-",e),window?.getSelection()?.toString()||i===e?(t?.[0].pause(),z("视频暂停")):p||(t?.[0].play(),z("视频播放"))})),l.css({...n,"backdrop-filter":"blur(8px)",mask:"linear-gradient(180deg, black 0%, rgba(0, 0, 0, 1) 80%,rgba(0, 0, 0, 0.0) 95%)",border:"2px solid #aaa8",transform:"translateX(-50%)","user-select":"text",width:"60vw",bottom:"0",left:"50%",padding:"3vw 3vw 10vh 3vw","font-size":" 3vw","text-align":" center","border-radius":"3vw 3vw 0 0"});var d=$(' '),m=(d=(t.prepend(d),d.on("loadeddata",(e=>{e.stopPropagation(),z("轨道数据缓存")})),$(`${o}
`),1<=e&&(o=(n?.[e-1])?.text?.split(/\s+/)?.map((e=>`${e} `)).join(""),l.append(`${o}
`)),(o=$(".clickable_subtitle_middle")).on("mousedown","span",f),o.on("touchstart","span",f),o.on("mouseenter","span",f),o.on("mousemove","span",(e=>{/\s/.test(window?.getSelection()?.toString())||(i=e?.target?.textContent.match(/\b[\w]+\b/)?.[0],navigator?.clipboard?.writeText(i)?.then((()=>{z("复制成功 "+i),clearTimeout(s),s=setTimeout((()=>{window?.getSelection()?.removeAllRanges(),i="",z("1秒后清除剪贴板成功")}),1e3)}))?.catch((()=>{z("复制失败 "+i)})))})),o.on("mouseleave","span",(function(){$(this).css({"background-color":"#fff0","border-radius":"1vw"})})),g=e);break}}b=parseInt(e?.currentTime)}));async function w(e){e.stopPropagation(),p=!1,l.css({height:"auto"}),$(".clickable_subtitle_middle").css({"margin-top":"0"}),e=await(navigator?.clipboard?.readText()),console.log("window?.getSelection()?.toString() :",i,"-||-",e),window?.getSelection()?.toString()||i===e?(window?.getSelection()?.removeAllRanges(),t?.[0].pause(),z("视频暂停")):(t?.[0].play(),z("视频播放"))}var h=$(" [射手字幕] "),y=$(" [subscene.com] "),k=(h.css({color:"#fff"}),y.css({color:"#fff"}),$("")),x=(k.css({"line-height":"6vw !important"}),$("