mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-12-04 11:51:20 +01:00
Reformated code in src
This commit is contained in:
1 parent
03da33736d
commit
6db73d26ba
4 files changed
+33
-25
No files matched your search
@@ -3,8 +3,7 @@ import { likesDisabledState } from "./state";
|
||||
import { cLog } from "./utils";
|
||||
|
||||
function createRateBar(likes, dislikes) {
|
||||
if (!likesDisabledState)
|
||||
{
|
||||
if (!likesDisabledState) {
|
||||
let rateBar = document.getElementById("ryd-bar-container");
|
||||
|
||||
const widthPx =
|
||||
@@ -43,13 +42,12 @@ function createRateBar(likes, dislikes) {
|
||||
} else {
|
||||
document.getElementById("ryd-bar-container").style.width = widthPx + "px";
|
||||
document.getElementById("ryd-bar").style.width = widthPercent + "%";
|
||||
|
||||
document.querySelector(
|
||||
"#ryd-dislike-tooltip > #tooltip"
|
||||
).innerHTML = `${likes.toLocaleString()} / ${dislikes.toLocaleString()}`;
|
||||
}
|
||||
} else {
|
||||
cLog('removing bar');
|
||||
cLog("removing bar");
|
||||
let ratebar = document.getElementById("ryd-bar-container");
|
||||
ratebar.parentNode.removeChild(ratebar);
|
||||
}
|
||||
|
||||
@@ -35,9 +35,4 @@ function checkForSignInButton() {
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
getButtons,
|
||||
getLikeButton,
|
||||
getDislikeButton,
|
||||
checkForSignInButton,
|
||||
};
|
||||
export { getButtons, getLikeButton, getDislikeButton, checkForSignInButton };
|
||||
@@ -1,7 +1,15 @@
|
||||
import { getBrowser, getVideoId, numberFormat, cLog } from "./utils"
|
||||
import { checkForSignInButton, getButtons } from "./buttons"
|
||||
import { NEUTRAL_STATE, LIKED_STATE, DISLIKED_STATE, setDislikes, extConfig, storedData, setLikes } from "./state"
|
||||
import { createRateBar } from "./bar"
|
||||
import { getBrowser, getVideoId, numberFormat, cLog } from "./utils";
|
||||
import { checkForSignInButton, getButtons } from "./buttons";
|
||||
import {
|
||||
NEUTRAL_STATE,
|
||||
LIKED_STATE,
|
||||
DISLIKED_STATE,
|
||||
setDislikes,
|
||||
extConfig,
|
||||
storedData,
|
||||
setLikes,
|
||||
} from "./state";
|
||||
import { createRateBar } from "./bar";
|
||||
|
||||
function sendVote(vote) {
|
||||
if (extConfig.disableVoteSubmission !== true) {
|
||||
@@ -98,7 +106,9 @@ function addLikeDislikeEventListener() {
|
||||
|
||||
function storageChangeHandler(changes, area) {
|
||||
if (changes.disableVoteSubmission !== undefined) {
|
||||
handleDisableVoteSubmissionChangeEvent(changes.disableVoteSubmission.newValue);
|
||||
handleDisableVoteSubmissionChangeEvent(
|
||||
changes.disableVoteSubmission.newValue
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ const LIKED_STATE = "LIKED_STATE";
|
||||
const DISLIKED_STATE = "DISLIKED_STATE";
|
||||
const NEUTRAL_STATE = "NEUTRAL_STATE";
|
||||
|
||||
const DISLIKES_DISABLED_TEXT = "DISLIKES DISABLED"
|
||||
const DISLIKES_DISABLED_TEXT = "DISLIKES DISABLED";
|
||||
|
||||
let extConfig = {
|
||||
disableVoteSubmission: false,
|
||||
@@ -63,19 +63,22 @@ function setLikes(likesCount) {
|
||||
function setDislikes(dislikesCount) {
|
||||
if (!likesDisabledState) {
|
||||
if (isMobile()) {
|
||||
getButtons().children[1].querySelector(".button-renderer-text").innerText =
|
||||
dislikesCount;
|
||||
getButtons().children[1].querySelector(
|
||||
".button-renderer-text"
|
||||
).innerText = dislikesCount;
|
||||
return;
|
||||
}
|
||||
getButtons().children[1].querySelector("#text").innerText = dislikesCount;
|
||||
} else {
|
||||
cLog("likes count diabled by creator");
|
||||
if (isMobile()) {
|
||||
getButtons().children[1].querySelector(".button-renderer-text").innerText =
|
||||
DISLIKES_DISABLED_TEXT;
|
||||
getButtons().children[1].querySelector(
|
||||
".button-renderer-text"
|
||||
).innerText = DISLIKES_DISABLED_TEXT;
|
||||
return;
|
||||
}
|
||||
getButtons().children[1].querySelector("#text").innerText = DISLIKES_DISABLED_TEXT;
|
||||
getButtons().children[1].querySelector("#text").innerText =
|
||||
DISLIKES_DISABLED_TEXT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +116,10 @@ function setState(storedData) {
|
||||
function (response) {
|
||||
cLog("response from api:");
|
||||
cLog(JSON.stringify(response));
|
||||
likesDisabledState = numberFormat(response.dislikes) == 0 && numberFormat(response.likes) == 0 && numberFormat(response.viewCount) == 0;
|
||||
likesDisabledState =
|
||||
numberFormat(response.dislikes) == 0 &&
|
||||
numberFormat(response.likes) == 0 &&
|
||||
numberFormat(response.viewCount) == 0;
|
||||
if (response !== undefined && !("traceId" in response) && !statsSet) {
|
||||
processResponse(response, storedData);
|
||||
}
|
||||
@@ -133,11 +139,10 @@ function initExtConfig() {
|
||||
}
|
||||
|
||||
function initializeDisableVoteSubmission() {
|
||||
getBrowser().storage.sync.get(['disableVoteSubmission'], (res) => {
|
||||
getBrowser().storage.sync.get(["disableVoteSubmission"], (res) => {
|
||||
if (res.disableVoteSubmission === undefined) {
|
||||
getBrowser().storage.sync.set({ disableVoteSubmission: false });
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
extConfig.disableVoteSubmission = res.disableVoteSubmission;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user