Skip to content

Commit

Permalink
3.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Taknok committed Apr 9, 2024
2 parents 9309525 + 8939939 commit 602fcc0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "__MSG_appName__",
"version": "3.8.2",
"version": "3.9.0",
"manifest_version": 2,
"description": "__MSG_appDesc__",
"icons": {
Expand Down
19 changes: 15 additions & 4 deletions app/scripts/modules/liker-paper.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ class PaperLiker {
return this.getUsedLikeFilledSVG() === null;
}

isLive() {
var liveBadge = document.querySelector('.ytp-live-badge');
return liveBadge && !liveBadge.getAttribute('disabled');
}

/**
* Detects when like/dislike buttons have loaded (so we can press them)
* and register element in the attributes
Expand Down Expand Up @@ -161,6 +166,11 @@ class PaperLiker {
waitForVideo(callback) {
if (this.video()) {
log("Get Video.")
if (this.isLive()) {
log("Video is live");
this.liveStartedAt = this.video().currentTime;
log("Start watching live at", this.liveStartedAt);
}
callback();
} else {
setTimeout(() => this.waitForVideo(callback), 1000);
Expand Down Expand Up @@ -207,7 +217,7 @@ class PaperLiker {
else {
let duration = this.video().duration;

if (this.options.percentage_timer) {
if (this.options.percentage_timer && !this.isLive()) {
log("waitTimer: percent")
let percentageAtLike = this.options.percentage_value;
let nowInPercent = this.video().currentTime / duration * 100;
Expand All @@ -219,18 +229,19 @@ class PaperLiker {
}
}

let currentT = this.isLive() ? (this.video().currentTime - this.liveStartedAt) : this.video().currentTime;
if (this.options.minute_timer) {
log("waitTimer: minute")
let timeAtLike = this.options.minute_value;
// change timeAtLike if vid shorter than time set by user
log(this.video().currentTime, this.video().duration, timeAtLike)
log(currentT, duration, timeAtLike)
if (this.video().duration < timeAtLike) {
timeAtLike = this.video().duration;
timeAtLike = duration;
} else {
// convert in second
timeAtLike *= 60;
}
if (this.video().currentTime >= timeAtLike) {
if (currentT >= timeAtLike) {
callback();
return;
}
Expand Down
5 changes: 1 addition & 4 deletions app/update_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ <h1 id="title"><strong>YouTube</strong> Auto Like</h1>
<h4>You can opt out of notification update from option menu !</h4>
<p>What's new :</p>
<ul>
<li>Update to new Youtube class layout. Thank you Fraeksn & MaeharaProjekt</li>
</ul>
<ul>
<li>Subs mobs is working again : update to new youtube hide attribute.</li>
<li>Minute timer for lives will start counting when you stared watching and not from the beginning of the live. Thank you XangelMusic.</li>
</ul>
<p>Feel free to report any bug on <a id="report-link" href="https://github.com/Taknok/youtube-auto-like">Github</a>.</p>
<div id="links">
Expand Down

0 comments on commit 602fcc0

Please sign in to comment.