Greasy Fork

来自缓存

Greasy Fork is available in English.

南方医科大学爱课平台自动二倍速静音播放全部视频/Auto Aike 2x Speed Muted Video Player

Automatically play videos at 2x speed and mute on Aike;add a switch for checking specific texts

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name 南方医科大学爱课平台自动二倍速静音播放全部视频/Auto Aike 2x Speed Muted Video Player
// @namespace https://aike.smu.edu.cn/
// @version 2.0
// @description Automatically play videos at 2x speed and mute on Aike;add a switch for checking specific texts
// @author Lily Yu
// @match https://aike.smu.edu.cn/*
// @grant none
// @license MIT
// ==/UserScript==

(function () {
  'use strict';

  // Add a switch for checking specific texts
  const checkText = true;

  // Define the elements to be manipulated
  var videos, nextPageButton;

  // Wait for the window to load completely
  window.onload = function () {
    // Find all the video elements on the page
    videos = document.querySelectorAll('video');

    // Find the next page button on the page
    nextPageButton = document.querySelector('#next-activity-link');

    function processVideos() {
      // Check if there are any videos on the page
      if (videos.length === 0) {
        // No videos, just click the next page button
        nextPageButton.click();
      } else {
        // Loop through all the video elements
        for (var i = 0; i < videos.length; i++) {
          // Get the current video element
          var video = videos[i];

          // Play the video at 2x speed and mute
          video.playbackRate = 2;
          video.muted = true;
          video.play();

          // Add an event listener to the video element to detect when it ends
          video.addEventListener('ended', function () {
            // Click the next page button to load a new video
            nextPageButton.click();
          });
        }
      }
    }

    // Check if either of the specific texts is present on the page
    if (checkText) {
      const targetTexts = [
        '授课视频,同学需浏览完视频,爱课平台才记录为完成学习任务。',
        '此内容为线上授课,同学们需浏览完视频,爱课平台才会记录为完成学习任务。',
      ];
      const targetElement = document.querySelector('#resourceintro p span');
      if (targetElement && targetTexts.some(text => targetElement.innerText === text)) {
        processVideos();
      } else {
        nextPageButton.click();
      }
    } else {
      processVideos();
    }
  };
})();