Skip to content

Instantly share code, notes, and snippets.

@alanhg
Created December 24, 2023 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanhg/1b204366502dfef03c7e4b5185499a8a to your computer and use it in GitHub Desktop.
Save alanhg/1b204366502dfef03c7e4b5185499a8a to your computer and use it in GitHub Desktop.
视频变速 for Tampermonkey
// ==UserScript==
// @name 视频变速
// @namespace http://tampermonkey.net/
// @version 2023-12-23
// @description try to take over the world!
// @author You
// @match https://www.youtube.com/watch*
// @match https://peixun.amac.org.cn/**
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @run-at document-start
// @grant GM_registerMenuCommand
// ==/UserScript==
(function () {
'use strict';
const setSpeed = (speed) => {
const el = document.querySelector('video');
if (el) {
el.playbackRate = speed;
}
};
GM_registerMenuCommand('1倍速', function () {
setSpeed(1);
});
GM_registerMenuCommand('8倍速', function () {
setSpeed(8);
});
GM_registerMenuCommand('16倍速', function () {
setSpeed(16);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment