mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-12-02 10:52:20 +01:00
refactor function checkForUserAvatarButton()
This commit is contained in:
1 parent
a22de0a28b
commit
0d73da29ca
1 file changed
+4
-8
@@ -56,12 +56,8 @@ const NEUTRAL_STATE = "NEUTRAL_STATE";
|
|||||||
return getDislikeButton().classList.contains("style-text");
|
return getDislikeButton().classList.contains("style-text");
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkForUserAvatarButton() {
|
function hasAvatarButton() {
|
||||||
if (document.querySelector('#avatar-btn')) {
|
return document.querySelector('#avatar-btn') !== null
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getState() {
|
function getState() {
|
||||||
@@ -132,7 +128,7 @@ const NEUTRAL_STATE = "NEUTRAL_STATE";
|
|||||||
}
|
}
|
||||||
|
|
||||||
function likeClicked() {
|
function likeClicked() {
|
||||||
if (checkForUserAvatarButton() == true) {
|
if (hasAvatarButton()) {
|
||||||
if (storedData.previousState == DISLIKED_STATE) {
|
if (storedData.previousState == DISLIKED_STATE) {
|
||||||
storedData.dislikes--;
|
storedData.dislikes--;
|
||||||
storedData.likes++;
|
storedData.likes++;
|
||||||
@@ -152,7 +148,7 @@ const NEUTRAL_STATE = "NEUTRAL_STATE";
|
|||||||
}
|
}
|
||||||
|
|
||||||
function dislikeClicked() {
|
function dislikeClicked() {
|
||||||
if (checkForUserAvatarButton() == true) {
|
if (hasAvatarButton()) {
|
||||||
if (storedData.previousState == NEUTRAL_STATE) {
|
if (storedData.previousState == NEUTRAL_STATE) {
|
||||||
storedData.dislikes++;
|
storedData.dislikes++;
|
||||||
setDislikes(numberFormat(storedData.dislikes));
|
setDislikes(numberFormat(storedData.dislikes));
|
||||||
|
|||||||
Reference in new issue
Block a user