coursera Interactive Transcript modifier

a coursera Interactive Transcript modifier

  1. // ==UserScript==
  2. // @name coursera Interactive Transcript modifier
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.5
  5. // @description a coursera Interactive Transcript modifier
  6. // @match https://www.coursera.org/learn/*
  7. // @grant none
  8. // @home-url https://gf.qytechs.cn/en/scripts/408858-cousera-interactive-transcript-modifier
  9. // @homepageURL https://gf.qytechs.cn/en/scripts/408858-cousera-interactive-transcript-modifier
  10. // @author LiAlbert
  11. // @license MIT
  12. // ==/UserScript==
  13. var flag = 0
  14.  
  15.  
  16. function changeSub() {
  17. if (flag == 0) {
  18. var activePhrase = document.querySelector('.rc-Phrase.active');
  19. if (activePhrase) {
  20. document.querySelector('.rc-Transcript').style.display = 'none';
  21. var header = document.querySelector(".rc-ItemHeader");
  22. if(header) header.parentElement.removeChild(header);
  23.  
  24. document.querySelector('.ItemPageLayout_container').style.top = 0;
  25. document.querySelector('.ItemPageLayout_container').style.height = "100%";
  26.  
  27. var div = document.createElement('div');
  28. div.id = 'currentsub'
  29. if (activePhrase) div.textContent = activePhrase.textContent
  30. var video = document.querySelector('.video-container');
  31. if (video == null) {
  32. video = document.querySelector('.video-main-player-container');
  33. document.querySelector('.video-name').style.display = 'none';
  34. }
  35. video.parentElement.insertBefore(div, video.nextSibling);
  36.  
  37. div.style.textAlign = "center";
  38. div.style.fontSize = "40px";
  39. div.style.marginTop = "10px";
  40. div.style.lineHeight = "41px";
  41. div.style.height = "82px";
  42. div.style.fontFamily = "Times New Roman";
  43. div.style.fontWeight = "bold";
  44. var player = document.querySelector('video');
  45. div.onmouseover = function () {
  46. player.pause();
  47. div.onmouseout = function () { player.play(); };
  48. };
  49. div.onmouseout = function () { player.play(); };
  50. div.onclick = function () {
  51. var text = window.getSelection().toString();
  52. navigator.clipboard.writeText(text).then(function () {
  53. console.log('Async: Copying ' + text + ' to clipboard was successful!');
  54. }, function (err) {
  55. console.error('Async: Could not copy text: ', err);
  56. });
  57. div.onmouseout = function () { };
  58. };
  59.  
  60. player.onkeypress = function (event) {
  61. var x = event.keyCode;
  62. if (x == 37) { player.pause(); player.currentTime = player.currentTime - 0.1; player.play(); }
  63. if (x == 39) { player.pause(); player.currentTime = player.currentTime + 0.1; player.play(); }
  64. }
  65. flag = 1;
  66. }
  67. }
  68. else {
  69. div = document.getElementById('currentsub');
  70. if (div) {
  71. if(div.textContent !== document.querySelector('.rc-Phrase.active').textContent)
  72. {
  73. div.textContent = document.querySelector('.rc-Phrase.active').textContent;
  74. if (document.querySelector('.rc-Transcript').style.display != 'none') document.querySelector('.rc-Transcript').style.display = 'none';
  75. }
  76. }
  77. else { flag = 0; }
  78.  
  79. }
  80.  
  81. }
  82. setInterval(changeSub, 30);

QingJ © 2025

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