NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name DCDNet Radio // @namespace http://tampermonkey.net/ // @version 0.1.0 // @description Bringing DCDNet Radio to life without Flash Player // @author siomi // @match http://fm.dcdnet.ru/ // @license MIT; https://spdx.org/licenses/MIT.html // @grant none // @run-at document-body // ==/UserScript== let player = document.createElement('audio'); player.setAttribute('controls', ''); player.setAttribute('preload', 'none'); player.setAttribute('style', 'visibility:hidden;'); player.textContent = 'Your browser does not support the audio element.'; document.getElementsByTagName('body')[0].appendChild(player); let source = document.createElement('source'); source.setAttribute('src', ''); source.setAttribute('type', 'audio/mpeg'); player.appendChild(source); HTMLElement.prototype.playNewTrack = function(track){ let track_path = track.split('/'); source.setAttribute('src', track); player.load(); this.play(); document.getElementById("crSongname").innerHTML = track_path[track_path.length-1]; let album = track_path[track_path.length-2].split("-"); document.getElementById("crAlbum").innerHTML = album.slice(1, album.length).join("-"); }; player.onended = function(e) { playerNext(); }; player.ontimeupdate = function(){ setTrackTime(this.duration*1000, this.currentTime*1000); }; HTMLElement.prototype.play = function(){ const playedPromise = player.play(); }; HTMLElement.prototype.stop = function(){ player.pause(); player.currentTime = 0; }; HTMLElement.prototype.pause = function(){ player.pause(); }; HTMLElement.prototype.setVolume = function(v){ player.volume = v/100; };