NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name DCDNet HTML5 Player // @namespace http://tampermonkey.net/ // @version 0.3.1 // @description replaces flash audio player with a standard HTML5 audio player // @author siomi // @license MIT; https://spdx.org/licenses/MIT.html // @match http://dcdnet.ru/albums/* // @match http://www.dcdnet.ru/albums/* // @grant none // ==/UserScript== (function() { let tracks = document.querySelectorAll('#track_table object'); let current_player = null; let volume = 1.0; for(let i=0;i<tracks.length;i++){ let track = tracks[i]; let link = track.querySelector('param[name=movie]').value.split('&')[1]; let mp3 = 'http://dcdnet.ru'+link.substring(4, link.length); let player = document.createElement('audio'); player.setAttribute('controls', ''); player.setAttribute('preload', 'none'); player.setAttribute('style', 'width:300px;'); player.textContent = 'Your browser does not support the audio element.'; let source = document.createElement('source'); source.setAttribute('src', mp3); source.setAttribute('type', 'audio/mpeg'); player.appendChild(source); track.parentElement.replaceChild(player,track); player.onplay = function(e) { if((current_player !== player)&&(current_player !== null)) { volume = current_player.volume; current_player.pause(); } current_player = player; current_player.volume = volume; current_player.play(); }; player.onended = function(e) { let next = this.closest("tr").nextElementSibling; if (next === null) { next = document.querySelector('#track_table tbody>tr:first-child'); } let a = next.querySelector('audio'); a.currentTime = 0; a.play(); }; player.onvolumechange = function() { volume = player.volume; }; } })();