ik001xa智慧树/知到
// ==UserScript==
// @name ik001xa智慧树/知到
// @namespace http://tampermonkey.net/
// @version 0.2.0
// @description 智慧树自用版,本人很懒,不定时更新
// @author ik001xa智慧树/知到
// @match *://studyvideoh5.zhihuishu.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var box = document.createElement('div');
box.style.position = 'fixed';
box.style.top = '20px';
box.style.right = '380px';
box.style.padding = '15px';
box.style.backgroundColor = '#fff';
box.style.border = '5px solid #ccc';
box.style.zIndex = '9999';
box.style.transform = 'scale(1.2)';
document.body.appendChild(box);
var muteButton = document.createElement('button');
muteButton.textContent = '静音';
muteButton.className = 'button';
muteButton.style.transform = 'scale(0.9)';
muteButton.addEventListener('click', function() {
toggleMute();
});
box.appendChild(muteButton);
var playPauseButton = document.createElement('button');
playPauseButton.textContent = '播放视频';
playPauseButton.className = 'button';
playPauseButton.style.transform = 'scale(0.9)';
playPauseButton.addEventListener('click', function() {
togglePlayPause();
});
box.appendChild(playPauseButton);
var autoPlayButton = document.createElement('button');
autoPlayButton.textContent = '自动播放1';
autoPlayButton.className = 'button';
autoPlayButton.style.transform = 'scale(0.9)';
autoPlayButton.addEventListener('click', function() {
toggleAutoPlay();
});
box.appendChild(autoPlayButton);
var speedButton = document.createElement('button');
speedButton.textContent = '8倍速';
speedButton.className = 'button';
speedButton.style.transform = 'scale(0.9)';
speedButton.addEventListener('click', function() {
updateSpeedElement();
});
box.appendChild(speedButton);
var autoSelectButton = document.createElement('button');
autoSelectButton.textContent = '自动选择';
autoSelectButton.className = 'button';
autoSelectButton.style.transform = 'scale(0.9)';
autoSelectButton.addEventListener('click', function() {
toggleAutoSelect();
});
box.appendChild(autoSelectButton);
function toggleMute() {
var videoElement = document.querySelector('video');
if (videoElement) {
videoElement.muted = !videoElement.muted;
muteButton.textContent = videoElement.muted ? '取消静音' : '静音';
}
}
function togglePlayPause() {
var videoElement = document.querySelector('video');
if (videoElement) {
if (videoElement.paused) {
videoElement.play();
playPauseButton.textContent = '暂停视频';
} else {
videoElement.pause();
playPauseButton.textContent = '播放视频';
}
}
}
function toggleAutoPlay() {
var videoElement = document.querySelector('video');
if (videoElement) {
if (autoPlayButton.textContent === '自动播放1') {
videoElement.muted = true;
videoElement.play();
muteButton.textContent = '取消静音';
playPauseButton.textContent = '暂停视频';
autoPlayButton.textContent = '自动播放2';
} else {
videoElement.muted = false;
videoElement.pause();
muteButton.textContent = '静音';
playPauseButton.textContent = '播放视频';
autoPlayButton.textContent = '自动播放1';
}
}
}
function updateSpeedElement() {
var speedElement = document.querySelector('div.speedTab.speedTab15[rate="1.5"]');
if (speedElement) {
speedElement.setAttribute('rate', '8');
speedElement.textContent = 'X 8';
}
muteMediaElements();
}
function toggleAutoSelect() {
var optionElement = document.querySelector('li.topic-item');
if (optionElement) {
var iconElement = optionElement.querySelector('.icon.topic-option');
var isSelected = iconElement.classList.contains('selected');
if (isSelected) {
iconElement.classList.remove('selected');
autoSelectButton.textContent = '自动选择';
} else {
iconElement.classList.add('selected');
autoSelectButton.textContent = '取消自动选择';
selectOptionA();
}
}
}
function selectOptionA() {
var optionElement = document.querySelector('div.item-topic');
if (optionElement) {
optionElement.click();
}
}
var watermark = document.createElement('div');
watermark.textContent = 'ik001xa—智慧树';
watermark.style.position = 'absolute';
watermark.style.bottom = '1px';
watermark.style.right = '10px';
watermark.style.fontSize = '13px';
watermark.style.color = 'blue';
box.appendChild(watermark);
// 添加样式
var style = document.createElement('style');
style.textContent = '.button { margin-right: 12px; }';
document.head.appendChild(style);
})();