mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-30 01:47:54 +01:00
Merge pull request #594 from cyrildtm/fixLikeUpdated
Fix like numbers re-format
This commit is contained in:
4 files changed
+30
-5
No files matched your search
@@ -204,10 +204,10 @@ function getLikeCountFromButton() {
|
|||||||
if (isShorts()) {
|
if (isShorts()) {
|
||||||
//Youtube Shorts don't work with this query. It's not nessecary; we can skip it and still see the results.
|
//Youtube Shorts don't work with this query. It's not nessecary; we can skip it and still see the results.
|
||||||
//It should be possible to fix this function, but it's not critical to showing the dislike count.
|
//It should be possible to fix this function, but it's not critical to showing the dislike count.
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
let likesStr = getLikeButton()
|
let likesStr = getLikeButton()
|
||||||
.querySelector("button")
|
.querySelector("yt-formatted-string#text")
|
||||||
.getAttribute("aria-label")
|
.getAttribute("aria-label")
|
||||||
.replace(/\D/g, "");
|
.replace(/\D/g, "");
|
||||||
return likesStr.length > 0 ? parseInt(likesStr) : false;
|
return likesStr.length > 0 ? parseInt(likesStr) : false;
|
||||||
@@ -399,6 +399,12 @@ function likeClicked() {
|
|||||||
createRateBar(likesvalue, dislikesvalue);
|
createRateBar(likesvalue, dislikesvalue);
|
||||||
previousState = 1;
|
previousState = 1;
|
||||||
}
|
}
|
||||||
|
if (extConfig.numberDisplayReformatLikes === true) {
|
||||||
|
const nativeLikes = getLikeCountFromButton();
|
||||||
|
if (nativeLikes !== false) {
|
||||||
|
setLikes(numberFormat(nativeLikes));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -420,6 +426,12 @@ function dislikeClicked() {
|
|||||||
setDislikes(numberFormat(dislikesvalue));
|
setDislikes(numberFormat(dislikesvalue));
|
||||||
createRateBar(likesvalue, dislikesvalue);
|
createRateBar(likesvalue, dislikesvalue);
|
||||||
previousState = 2;
|
previousState = 2;
|
||||||
|
if (extConfig.numberDisplayReformatLikes === true) {
|
||||||
|
const nativeLikes = getLikeCountFromButton();
|
||||||
|
if (nativeLikes !== false) {
|
||||||
|
setLikes(numberFormat(nativeLikes));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
<span class="switchLabel">Show rounded down numbers</span>
|
<span class="switchLabel">Show rounded down numbers</span>
|
||||||
</label>
|
</label>
|
||||||
<br/>
|
<br/>
|
||||||
<label class="switch" data-hover="Make likes and dislikes format consistent">
|
<label class="switch" data-hover="Make likes and dislikes format consistent (does not work on Shorts)">
|
||||||
<input type="checkbox" id="number_reformat_likes"/>
|
<input type="checkbox" id="number_reformat_likes"/>
|
||||||
<span class="slider"/>
|
<span class="slider"/>
|
||||||
<span class="switchLabel">Re-format like numbers</span>
|
<span class="switchLabel">Re-format like numbers</span>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
extConfig,
|
extConfig,
|
||||||
storedData,
|
storedData,
|
||||||
setLikes,
|
setLikes,
|
||||||
|
getLikeCountFromButton,
|
||||||
} from "./state";
|
} from "./state";
|
||||||
import { createRateBar } from "./bar";
|
import { createRateBar } from "./bar";
|
||||||
|
|
||||||
@@ -41,6 +42,12 @@ function likeClicked() {
|
|||||||
createRateBar(storedData.likes, storedData.dislikes);
|
createRateBar(storedData.likes, storedData.dislikes);
|
||||||
storedData.previousState = NEUTRAL_STATE;
|
storedData.previousState = NEUTRAL_STATE;
|
||||||
}
|
}
|
||||||
|
if (extConfig.numberDisplayReformatLikes === true) {
|
||||||
|
const nativeLikes = getLikeCountFromButton();
|
||||||
|
if (nativeLikes !== false) {
|
||||||
|
setLikes(numberFormat(nativeLikes));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +72,12 @@ function dislikeClicked() {
|
|||||||
setDislikes(numberFormat(storedData.dislikes));
|
setDislikes(numberFormat(storedData.dislikes));
|
||||||
createRateBar(storedData.likes, storedData.dislikes);
|
createRateBar(storedData.likes, storedData.dislikes);
|
||||||
storedData.previousState = DISLIKED_STATE;
|
storedData.previousState = DISLIKED_STATE;
|
||||||
|
if (extConfig.numberDisplayReformatLikes === true) {
|
||||||
|
const nativeLikes = getLikeCountFromButton();
|
||||||
|
if (nativeLikes !== false) {
|
||||||
|
setLikes(numberFormat(nativeLikes));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,10 +153,10 @@ function getLikeCountFromButton() {
|
|||||||
if (isShorts()) {
|
if (isShorts()) {
|
||||||
//Youtube Shorts don't work with this query. It's not nessecary; we can skip it and still see the results.
|
//Youtube Shorts don't work with this query. It's not nessecary; we can skip it and still see the results.
|
||||||
//It should be possible to fix this function, but it's not critical to showing the dislike count.
|
//It should be possible to fix this function, but it's not critical to showing the dislike count.
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
let likesStr = getLikeButton()
|
let likesStr = getLikeButton()
|
||||||
.querySelector("button")
|
.querySelector("yt-formatted-string#text")
|
||||||
.getAttribute("aria-label")
|
.getAttribute("aria-label")
|
||||||
.replace(/\D/g, "");
|
.replace(/\D/g, "");
|
||||||
return likesStr.length > 0 ? parseInt(likesStr) : false;
|
return likesStr.length > 0 ? parseInt(likesStr) : false;
|
||||||
|
|||||||
Reference in new issue
Block a user