nachokb / Playback Rate for Radiocut

// ==UserScript==
// @name         Playback Rate for Radiocut
// @namespace    https://openuserjs.org/users/nachokb
// @version      0.1
// @description  adds a slider for changing playback rate to radiocut.fm
// @author       Ignacio Carrera <ignacio@carrera.com.ar>
// @copyright    2019, nachokb (https://openuserjs.org/users/nachokb)
// @match        http*://radiocut.fm/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  'use strict';

  var slider = document.createElement('input');

  slider.setAttribute('type', 'range');
  slider.setAttribute('id', 'playback_rate');
  slider.setAttribute('min', '0.5');
  slider.setAttribute('max', '2.0');
  slider.setAttribute('step', '0.25');
  slider.setAttribute('value', '1.25');

  var mute_btn = document.querySelector('.btn.mute');
  mute_btn.parentElement.insertBefore(slider, mute_btn);

  var label = document.createElement('span');
  label.setAttribute('id', 'playback_rate_label');
  slider.parentElement.insertBefore(label, slider);

  var keep_rate = function () {
    var input = document.getElementById('playback_rate');
    var label = document.getElementById('playback_rate_label');
    var rate = input.value;
    label.textContent = rate;

    document.
      querySelectorAll('audio').
      forEach(function (elem) {
        elem.playbackRate = rate
      });
  }

  window.playback_rate_timer = setInterval(keep_rate, 1000);
})();