Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Song{
- constructor(){};
- titleAndAuthor(){
- var item = document.getElementsByClassName("track-info__name ellipsis-one-line")[0];
- item=item.getElementsByClassName("react-contextmenu-wrapper")[0];
- item = item.querySelectorAll("span");
- item = item[0].querySelectorAll("a");
- return item;
- };
- songDurationInfo(){
- return document.getElementsByClassName("playback-bar__progress-time");
- };
- getSongTimerString(){
- return this.songDurationInfo()[0].innerText;
- };
- getSongDurationString(){
- return this.songDurationInfo()[1].innerText;
- }
- getSongTimeTotal(){
- var timeTotalStringSeconds = this.getSongDurationString()[this.getSongDurationString().length-2]+[this.getSongDurationString().length-1];
- var timeTotalStringMinutes = this.getSongDurationString().substring(0,this.getSongDurationString().length-3);
- var timeTotalInSec = parseInt(timeTotalStringMinutes) * 60 + parseInt(timeTotalStringSeconds)
- return timeTotalInSec;
- };
- getSongTimePassed(){
- var timePassedStringSeconds = this.getSongTimerString()[this.getSongTimerString().length-2] + [this.getSongTimerString().length-1];
- var timePassedStringMinutes = this.getSongTimerString().substring(0,this.getSongTimerString().length-3);
- var timePassedInSec = parseInt(timePassedStringMinutes) * 60 + parseInt(timePassedStringSeconds)
- return timePassedInSec;
- };
- getSongTimeLeft(){
- return this.getSongTimeTotal()-this.getSongTimePassed();
- };
- getTitle(){
- return this.titleAndAuthor()[0].innerText;
- };
- getTitleLink(){
- return this.titleAndAuthor()[0].href;
- };
- getArtistName(){
- var item = document.getElementsByClassName("track-info__artists link-subtle ellipsis-one-line")[0];
- item=item.getElementsByClassName("react-contextmenu-wrapper")[0];
- item = item.querySelectorAll("span");
- item = item[0].querySelectorAll("a");
- item = item[0].innerText;
- return item;
- };
- };
- var test = new Song();
- // console.log(test.getTitle());
- // console.log(test.getArtistName());
- // console.log(test.getTitleLink());
- //console.log(test.getSongTimerString());
- //console.log(test.getSongDurationString());
- console.log(test.getSongTimeTotal());
- console.log(test.getSongTimePassed());
- console.log(test.getSongTimeLeft());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement