braunbearded / YouFaster

// ==UserScript==
// @name         YouFaster
// @namespace    htttps://openuserjs.org/users/braunbearded
// @version      0.1
// @description  check https://bitbucket.org/braunbearded/youfaster/src/master/README.md
// @copyright    2018, braunbearded (https://openuserjs.org/users/braunbearded)
// @license      MIT
// @author       Stefan Matz
// @require      https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.2/babel.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.16.0/polyfill.js
// @match        https://www.youtube.com/watch?v=*

// @require      https://use.fontawesome.com/releases/v5.0.13/js/all.js
// @grant        GM_addStyle
// @grant        GM_getResourceText
// @resource     fontAwesome https://use.fontawesome.com/releases/v5.0.13/css/all.css

// ==/UserScript==

// ==OpenUserJS==
// @author braunbearded
// ==/OpenUserJS==

var inline_src = (<><![CDATA[

    let fontAwesome = GM_getResourceText("fontAwesome");
    GM_addStyle("body " + fontAwesome);

    let video = document.getElementsByTagName("video")[0];
    let controls = document.getElementsByClassName("ytp-left-controls")[0];
    let anchor = document.createElement("a");
    let fastForward = document.createElement("div");
    let icon = document.createElement("i");

    icon.className = "fa fa-fast-forward";
    icon.style.paddingTop = "5px";
    icon.style.fontSize = "25.5px";

    fastForward.className = "ytp-time-display notranslate";
    fastForward.innerHTML = icon.outerHTML + '  (1x)';
    fastForward.style.cursor = "pointer";

    let i = 2;
    fastForward.addEventListener("click", event => {
        if (i == 17) i = 1;
        video.playbackRate = i;
        fastForward.innerHTML = icon.outerHTML + "  (" + i + "x)";
        i++;
    });
    anchor.appendChild(fastForward);
    controls.appendChild(anchor);

]]></>).toString();
var c = Babel.transform(inline_src, { presets: [ "es2015", "es2016" ] });
eval(c.code);