Coursera Translator

coursera课程翻译

  1. // ==UserScript==
  2. // @name Coursera Translator
  3. // @namespace jiaowobanxianer.com
  4. // @version 1.0
  5. // @description coursera课程翻译
  6. // @author JiaoWoBanXianEr
  7. // @match https://www.coursera.org/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=baidu.com
  9. // @grant none
  10. // ==/UserScript==
  11. //字幕颜色RGB
  12. let color = '#ffff22';
  13. //字幕背景颜色ARGB
  14. let bgColor = "#7f7f7f7f";
  15. //字幕大小PX
  16. let fontSize = 60
  17. //字幕距底部距离Percent
  18. let up = 10;
  19.  
  20.  
  21. let t;
  22.  
  23. function translate() {
  24. if (document.getElementById('sub_container') == null) {
  25. init();
  26. }
  27. if (t == null) {
  28. return;
  29. }
  30. let text = document.querySelector('.rc-Phrase.active.css-ugczj4');
  31. if (text == null) {
  32. return;
  33. }
  34. t.textContent = text.outerText;
  35. }
  36. var i = setInterval(function () { translate(); }, 100);
  37.  
  38. function init() {
  39. if (document.querySelector('.vjs-react.c-video.vjs-fluid.vjs-circle-play-centered') == null) { return; }
  40. t = document.createElement("div");
  41. t.id = "sub_container";
  42. t.style.position = 'absolute';
  43. t.style.margin = 'auto';
  44. t.style.textAlign = 'center';
  45. t.style.zIndex = 99;
  46. t.style.height = fontSize + 'px';
  47. t.style.left = 0;
  48. t.style.right = 0;
  49. t.style.top = up + '%';
  50. t.style.backgroundColor = bgColor;
  51. t.style.fontSize = fontSize + 'px';
  52. t.style.color = color;
  53. //t.innerHTML = '<div id="sub_container" style="z-index: 99; position: absolute; top: 10%; left: auto; right: auto; height: 60px; margin: auto; text-align: center; background-color: rgb(127, 127, 127); font-size: 60px; color: rgb(255, 255, 34);">初始化</div>'
  54. document.querySelector('.vjs-react.c-video.vjs-fluid.vjs-circle-play-centered').appendChild(t);
  55. }
  56. (function () {
  57. 'use strict';
  58.  
  59. // Your code here...
  60. })();

QingJ © 2025

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