EnablePIP-icourse163

Enable Picture in Picture mode in icourse163 在icourse163(中国大学MOOC)中打开画中画模式,使chrome能够使用画中画。

安装此脚本?
作者推荐脚本

您可能也喜欢Icourse163_Auto_Full_Score_Review

安装此脚本
  1. // ==UserScript==
  2. // @name EnablePIP-icourse163
  3. // @namespace EnablePIP
  4. // @version 2.2.0
  5. // @description Enable Picture in Picture mode in icourse163 在icourse163(中国大学MOOC)中打开画中画模式,使chrome能够使用画中画。
  6. // @author LXG_Shadow & XenoAmess
  7. // @match https://www.icourse163.org/*
  8. // @run-at document-end
  9. // @grant none
  10. // @supportURL https://github.com/XenoAmess/EnablePIP.git
  11. // ==/UserScript==
  12.  
  13. var REFRESH_TIME = 500;
  14. var STRING_OPEN_PICTURE_IN_PICTURE = "显示画中画面板";
  15. var STRING_CLOSE_PICTURE_IN_PICTURE = "隐藏画中画面板";
  16. var STRING_ENTER_PICTURE_IN_PICTURE_DIRECT = "直接进入画中画";
  17. var STRING_EXIT_PICTURE_IN_PICTURE_DIRECT = "直接退出画中画";
  18.  
  19. var STRING_POPUP_MENU_SELECTOR = "div.u-edu-h5player-popmenu > ul";
  20. var STRING_CONTROL_BAR_SELECTOR = "div.m-controlbar.j-controlbar";
  21. var STRING_VIDEO_SELECTOR = "div.u-edu-h5player-mainvideo > video";
  22. var STRING_PIC_IN_PIC_SWITCH = "pictureInPictureSwitch";
  23. var STRING_PIC_IN_PIC_DIRECT_SWITCH = "pictureInPictureDirectSwitch";
  24.  
  25. var b_pipMode = false;
  26. var b_pipMode_direct = false;
  27.  
  28. function switchPictureInPictureMode() {
  29. if (b_pipMode) {
  30. $("video").removeAttr("controls");
  31. $(STRING_CONTROL_BAR_SELECTOR).css("z-index", "");
  32. $(STRING_VIDEO_SELECTOR).css("z-index", "");
  33. } else {
  34. $("video").attr("controls", "controls");
  35. $(STRING_CONTROL_BAR_SELECTOR).css("z-index", "-1");
  36. $(STRING_VIDEO_SELECTOR).css("z-index", "10");
  37. }
  38. b_pipMode = !b_pipMode;
  39. $("#" + STRING_PIC_IN_PIC_SWITCH).text(b_pipMode ? STRING_CLOSE_PICTURE_IN_PICTURE : STRING_OPEN_PICTURE_IN_PICTURE);
  40. }
  41.  
  42. function switchPictureInPictureModeDirect() {
  43. if (b_pipMode_direct) {
  44. document.exitPictureInPicture();
  45. } else {
  46. $(STRING_VIDEO_SELECTOR)[0].requestPictureInPicture();
  47. }
  48. b_pipMode_direct = !b_pipMode_direct;
  49. $("#" + STRING_PIC_IN_PIC_DIRECT_SWITCH).text(b_pipMode_direct ? STRING_EXIT_PICTURE_IN_PICTURE_DIRECT : STRING_ENTER_PICTURE_IN_PICTURE_DIRECT);
  50. }
  51.  
  52. function addToToolBar() {
  53. if ($(STRING_POPUP_MENU_SELECTOR) != null && document.getElementById(STRING_PIC_IN_PIC_SWITCH) === null) {
  54. var $il0 = $("<li></li>");
  55. $il0.addClass("u-edu-h5player-popmenu_item j-item");
  56. $il0.text(b_pipMode ? STRING_CLOSE_PICTURE_IN_PICTURE : STRING_OPEN_PICTURE_IN_PICTURE);
  57. $il0.attr("id", STRING_PIC_IN_PIC_SWITCH);
  58. $il0.click(switchPictureInPictureMode);
  59. $(STRING_POPUP_MENU_SELECTOR).append($il0);
  60.  
  61. var $il1 = $("<li></li>");
  62. $il1.addClass("u-edu-h5player-popmenu_item j-item");
  63. $il1.text(b_pipMode_direct ? STRING_EXIT_PICTURE_IN_PICTURE_DIRECT : STRING_ENTER_PICTURE_IN_PICTURE_DIRECT);
  64. $il1.attr("id", STRING_PIC_IN_PIC_DIRECT_SWITCH);
  65. $il1.click(switchPictureInPictureModeDirect);
  66. $(STRING_POPUP_MENU_SELECTOR).append($il1);
  67. }
  68. }
  69.  
  70. (function () {
  71. 'use strict';
  72. if (!window.jQuery) {
  73. var oScript = document.createElement('script');
  74. oScript.type = "text/javascript";
  75. oScript.src = "//s1.hdslb.com/bfs/static/jinkela/long/js/jquery/jquery1.7.2.min.js";
  76. document.head.appendChild(oScript);
  77. }
  78. window.onload = window.setInterval(addToToolBar, REFRESH_TIME);
  79. })();

QingJ © 2025

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