mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-23 06:43:02 +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");
|
||||
}
|
||||
|
||||
function checkForUserAvatarButton() {
|
||||
if (document.querySelector('#avatar-btn')) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
function hasAvatarButton() {
|
||||
return document.querySelector('#avatar-btn') !== null
|
||||
}
|
||||
|
||||
function getState() {
|
||||
@@ -132,7 +128,7 @@ const NEUTRAL_STATE = "NEUTRAL_STATE";
|
||||
}
|
||||
|
||||
function likeClicked() {
|
||||
if (checkForUserAvatarButton() == true) {
|
||||
if (hasAvatarButton()) {
|
||||
if (storedData.previousState == DISLIKED_STATE) {
|
||||
storedData.dislikes--;
|
||||
storedData.likes++;
|
||||
@@ -152,7 +148,7 @@ const NEUTRAL_STATE = "NEUTRAL_STATE";
|
||||
}
|
||||
|
||||
function dislikeClicked() {
|
||||
if (checkForUserAvatarButton() == true) {
|
||||
if (hasAvatarButton()) {
|
||||
if (storedData.previousState == NEUTRAL_STATE) {
|
||||
storedData.dislikes++;
|
||||
setDislikes(numberFormat(storedData.dislikes));
|
||||
|
||||
Reference in new issue
Block a user