Skip to content

Commit

Permalink
A: logging
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnyP36 authored Feb 13, 2023
1 parent e1fdbb9 commit c340455
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions manifest_v3/js/autoplay+loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,20 @@ let YTNonstop = function YTNonstop(options) {
setAutoSkip: function(value){return Nonstop._autoSkip = value},
setAutoLoop: function(value){return Nonstop._autoLoop = value},
};


const tag = '[YT Nonstop]';
function log(message) {
console.log(`${tag}[${getTimestamp()}] ${message}`);
}
function getTimestamp() {
let dt = new Date();
let time = asDoubleDigit(dt.getHours()) + ':' + asDoubleDigit(dt.getMinutes()) + ':' + asDoubleDigit(dt.getSeconds());
return time;
}
function asDoubleDigit(value) {
return value < 10 ? '0' + value : value;
}

/**
* .getPlayerState():
* -1 – unstarted
Expand Down Expand Up @@ -164,9 +177,11 @@ let YTNonstop = function YTNonstop(options) {

if (Nonstop.getIsAutoSkip() == true && off) {
off.click();
log('Autoplay has been enabled');
} else
if (Nonstop.getIsAutoSkip() == false && on) {
on.click();
log('Autoplay has been disabled');
} else {
return;
}
Expand All @@ -190,12 +205,15 @@ let YTNonstop = function YTNonstop(options) {

if (get_YT.loop.button() && Nonstop.getIsAutoLoop() == true && off) {
get_YT.loop.button().click();
log('Playlist is been looped');
} else
if (get_YT.loop.button() && Nonstop.getIsAutoLoop() == false && on) {
get_YT.loop.button().click();
log('Looping of playlist has been stopped');
} else
if (get_YT.loop.button() && Nonstop.getIsAutoLoop() == false && o1f) {
get_YT.loop.button().click(); //this makes it impossible to loop a video if you turned 'loop playlist' off in the extension popup; you can only loop a video if 'loop playlist' is turned on
log('Loop Video has been disabled - you can only loop a video if Loop Playlist is turned on');
} else {
return
}
Expand Down Expand Up @@ -240,4 +258,4 @@ let YTNonstop = function YTNonstop(options) {
}));
return YTNonstop
};
injectScript(YTNonstop,"html"); //if you remove this line, the whole script will stop working
injectScript(YTNonstop,"html"); //if you remove this line, the whole script will stop working

0 comments on commit c340455

Please sign in to comment.