cousera Interactive Transcript modifier

a cousera Interactive Transcript modifier

目前為 2020-08-16 提交的版本,檢視 最新版本

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

QingJ © 2025

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