Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save emindeniz99/297e0e12606e0b7d4372b94df2da2c4a to your computer and use it in GitHub Desktop.
Save emindeniz99/297e0e12606e0b7d4372b94df2da2c4a to your computer and use it in GitHub Desktop.
video speed for google drive
// ==UserScript==
// @name video google drive
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://youtube.googleapis.com/embed/*
// @icon https://www.google.com/s2/favicons?domain=youtube.googleapis.com
// @grant none
// ==/UserScript==
(function () {
"use strict";
const getTarget = (speed = "1.75") => {
return [
...document.querySelectorAll("div.ytp-panel-menu > div.ytp-menuitem"),
].find((s) => s.innerText.includes(speed));
};
const speedAdd = (speed = 3) => {
const superfast = getTarget().cloneNode(true);
superfast.onclick = () => {
document.getElementsByTagName("video")[0].playbackRate = speed;
// document.querySelector("#playSpeedMultiplier").innerText = `${speed}x`;
};
superfast.innerText = `${speed}`;
superfast.id = "ssuper" + speed;
getTarget().parentNode.appendChild(superfast);
};
// set up the mutation observer
var h1observer = new MutationObserver(function (mutations, me) {
// mutations is an array of mutations that occurred
// me is the MutationObserver instance
var option = getTarget();
if (option) {
if (!getTarget("2.25")) {
speedAdd(2.25);
speedAdd(2.5);
speedAdd(2.75);
speedAdd(3.0);
speedAdd(3.25);
speedAdd(3.5);
speedAdd(4);
speedAdd(4.5);
speedAdd(5);
speedAdd(5.5);
speedAdd(6);
speedAdd(7);
speedAdd(8);
speedAdd(16);
}
}
});
// start observing
h1observer.observe(document, {
childList: true,
subtree: true,
});
// Your code here...
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment