Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name audio pl
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description try to take over the world!
- // @author You
- // @match http://audio.pl/
- // @run-at document-start
- // @grant unsafeWindow
- // ==/UserScript==
- var listaGlowna = {};
- listaGlowna.name = "Lista Główna";
- listaGlowna.item1 = [ "Radio ZET", "https://n-15-3.dcs.redcdn.pl/sc/o2/Eurozet/live/audio.livx?audio=5" ];
- listaGlowna.item2 = [ "AntyRadio", "https://n-15-3.dcs.redcdn.pl/sc/o2/Eurozet/live/antyradio.livx?audio=5" ];
- listaGlowna.item3 = [ "RMF MAXXX", "http://31.192.216.6/RMFMAXXX48" ];
- listaGlowna.item4 = [ "Złote Przeboje", "http://stream.radioagora.pl/tuba8936-1.mp3" ];
- listaGlowna.item5 = [ "Radio WAWA", "http://pldm.ml/radio?url=https://www.eskago.pl/radio/wawa" ];
- listaGlowna.item6 = [ "VOX FM", "http://pldm.ml/radio?url=https://www.eskago.pl/radio/vox-fm" ];
- listaGlowna.item7 = [ "ESKA Szczecin", "http://pldm.ml/radio?url=https://www.eskago.pl/radio/eska-szczecin" ];
- var eskaGO = {};
- eskaGO.name = "Eska GO";
- eskaGO.item1 = [ "Hity na wiosne", "http://pldm.ml/radio?url=https://www.eskago.pl/radio/special-hity-na-wiosne" ];
- var openFM = {};
- openFM.name = "Open FM";
- openFM.item1 = [ "Reggae", "http://stream.open.fm/22" ];
- var main = {};
- main.item1 = listaGlowna;
- main.item2 = eskaGO;
- main.item3 = openFM;
- var playlistString = "";
- for (var mainKey in main) {
- var mainValue = main[mainKey];
- playlistString += "<br><h5>" + mainValue.name + ":</h5>";
- for (var playlistKey in mainValue) {
- if (playlistKey.includes("item")) {
- var playlistValue = mainValue[playlistKey];
- playlistString += '<li><a href="' + playlistValue[1] + '">' + playlistValue[0] + '</a></li>';
- }
- }
- }
- document.open();
- document.write(`
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Radio</title>
- <style>
- div {
- margin: 0;
- position: absolute;
- top: 50%;
- left: 50%;
- margin-right: -50%;
- transform: translate(-50%, -50%);
- }
- h5 {
- color:green;
- text-decoration: underline overline;
- padding: 0px;
- margin: 0px;
- }
- #playlist {
- list-style: none;
- }
- #playlist li a {
- color:black;
- text-decoration: none;
- }
- #playlist .current-song a {
- color:blue;
- }
- </style>
- </head>
- <body>
- <div>
- <audio src="" controls id="audioPlayer"></audio>
- <ul id="playlist">` + playlistString + `</ul>
- </div>
- <script src="https://code.jquery.com/jquery-2.2.0.js"></script>
- <script>
- (function audioPlayer(){
- // get audio
- var audioList = $("#playlist li a");
- var audioCount = audioList.length;
- var audioCurrent = 0;
- // play first audio
- $("#audioPlayer")[0].src = $("#playlist li a")[audioCurrent];
- $("#audioPlayer")[0].play();
- // on audio click
- $("#playlist li a").click(function(e){
- e.preventDefault();
- $("#audioPlayer")[0].src = this;
- $("#audioPlayer")[0].play();
- audioCurrent = $(this).parent().index();
- $("#playlist li").removeClass("current-song");
- $(this).parent().addClass("current-song");
- });
- // on audio end
- $("#audioPlayer")[0].addEventListener("ended", function(){
- audioCurrent++;if(audioCurrent == audioCount) audioCurrent = 0;
- $("#playlist li").removeClass("current-song");
- $("#playlist li:eq("+audioCurrent+")").addClass("current-song");
- $("#audioPlayer")[0].src = $("#playlist li a")[audioCurrent].href;
- $("#audioPlayer")[0].play();
- });
- })();
- </script>
- </body>
- </html>`);
- document.close();
- /*
- setInterval(function() {
- //document.getElementById("body").innerHTML="<p>LOL</p>";
- }, 100);
- function Exist(element){
- return typeof(element) != 'undefined' && element != null;
- }
- function Empty(array){
- return typeof(array) == 'undefined' || array.length == 0;
- }
- function IsPlaying(audioElement){
- return !audioElement.paused && audioElement.currentTime > 0;
- }
- function IsPlayingRadio(audioElement){
- return !audioElement.paused;
- }
- function LoadAudio(){
- var action = function(){
- var audioElements = document.getElementsByTagName("audio");
- if (!Empty(audioElements)){
- var audioElement = audioElements[0];
- */
- /*if (!IsPlaying(audioElement)) {
- try {
- console.log("start playing audio");
- audioElement.play();
- }
- catch(error) {
- console.error(error);
- }
- }
- else {
- audioElement.pause();
- audioElement.currentTime = 0;
- }
- */
- /*
- if (IsPlaying(audioElement)) {
- try {
- console.log("pause audio");
- audioElement.pause();
- audioElement.currentTime = 0;
- }
- catch(error) {
- console.error(error);
- }
- }
- var audioElement1 = audioElements[1];
- if (!IsPlayingRadio(audioElement1)) {
- try {
- console.log("start playing audio");
- audioElement1.play();
- }
- catch(error) {
- console.error(error);
- }
- }
- }
- };
- setInterval(action, 150);
- }
- function CreateAudioElement(){
- var intervalID;
- var action = function(){
- var audioElement = document.createElement('audio');
- audioElement.setAttribute('autoplay', 'autoplay');
- audioElement.loop=true;
- audioElement.addEventListener('ended', function() {
- this.currentTime = 0;
- this.play();
- }, false);
- var sourceElement = document.createElement('source');
- //sourceElement.setAttribute('src', 'music.mp3');
- //sourceElement.setAttribute('type', 'audio/mpeg');
- sourceElement.setAttribute('src', 'http://n-15-3.dcs.redcdn.pl/sc/o2/Eurozet/live/audio.livx?audio=5');
- sourceElement.setAttribute('type', 'audio/mpeg');
- audioElement.appendChild(sourceElement);
- document.body.appendChild(audioElement);
- clearInterval(intervalID);
- };
- intervalID = setInterval(action, 50);
- }
- (function() {
- 'use strict';
- document.addEventListener("DOMContentLoaded", function(event) {
- var audioElements = document.getElementsByTagName("audio");
- //if (Empty(audioElements)){
- CreateAudioElement();
- //}
- LoadAudio();
- });
- })();
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement