mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-28 17:07:55 +01:00
finish implementation
This commit is contained in:
1 parent
3cd5b93b56
commit
54e9267655
5 files changed
+111
-17
No files matched your search
@@ -1,6 +1,9 @@
|
||||
import { getButtons } from "./buttons";
|
||||
import { likesDisabledState, extConfig } from "./state";
|
||||
import { cLog } from "./utils";
|
||||
import {
|
||||
cLog,
|
||||
getColorFromTheme,
|
||||
} from "./utils";
|
||||
|
||||
function createRateBar(likes, dislikes) {
|
||||
if (!likesDisabledState) {
|
||||
@@ -15,6 +18,12 @@ function createRateBar(likes, dislikes) {
|
||||
likes + dislikes > 0 ? (likes / (likes + dislikes)) * 100 : 50;
|
||||
|
||||
if (!rateBar) {
|
||||
let colorLikeStyle = '';
|
||||
let colorDislikeStyle = '';
|
||||
if (extConfig.coloredBar) {
|
||||
colorLikeStyle = '; background-color: ' + getColorFromTheme(true);
|
||||
colorDislikeStyle = '; background-color: ' + getColorFromTheme(false);
|
||||
}
|
||||
(
|
||||
document.getElementById("menu-container") ||
|
||||
document.querySelector("ytm-slim-video-action-bar-renderer")
|
||||
@@ -25,11 +34,11 @@ function createRateBar(likes, dislikes) {
|
||||
<div class="ryd-tooltip-bar-container">
|
||||
<div
|
||||
id="ryd-bar-container"
|
||||
style="width: 100%; height: 2px;"
|
||||
style="width: 100%; height: 2px;${colorDislikeStyle}"
|
||||
>
|
||||
<div
|
||||
id="ryd-bar"
|
||||
style="width: ${widthPercent}%; height: 100%"
|
||||
style="width: ${widthPercent}%; height: 100%${colorLikeStyle}"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -45,12 +54,11 @@ function createRateBar(likes, dislikes) {
|
||||
document.querySelector(
|
||||
"#ryd-dislike-tooltip > #tooltip"
|
||||
).innerHTML = `${likes.toLocaleString()} / ${dislikes.toLocaleString()}`;
|
||||
if (extConfig.coloredBar) {
|
||||
document.getElementById("ryd-bar-container").style.backgroundColor = getColorFromTheme(true);
|
||||
document.getElementById("ryd-bar").style.backgroundColor = getColorFromTheme(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (extConfig.coloredBar) {
|
||||
// TODO: colorize bar
|
||||
}
|
||||
|
||||
} else {
|
||||
cLog("removing bar");
|
||||
let ratebar = document.getElementById("ryd-bar-container");
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { getLikeButton, getDislikeButton, getButtons } from "./buttons";
|
||||
import { createRateBar } from "./bar";
|
||||
import { getBrowser, getVideoId, cLog, numberFormat } from "./utils";
|
||||
import {
|
||||
getBrowser,
|
||||
getVideoId,
|
||||
cLog,
|
||||
numberFormat,
|
||||
getColorFromTheme,
|
||||
} from "./utils";
|
||||
import { sendVideoIds } from "./events";
|
||||
|
||||
//TODO: Do not duplicate here and in ryd.background.js
|
||||
@@ -102,7 +108,8 @@ function processResponse(response, storedData) {
|
||||
storedData.likes = getLikeCountFromButton() || parseInt(response.likes);
|
||||
createRateBar(storedData.likes, storedData.dislikes);
|
||||
if (extConfig.coloredThumbs === true) {
|
||||
// TODO: colorize thumbs
|
||||
getLikeButton().style.color = getColorFromTheme(true);
|
||||
getDislikeButton().style.color = getColorFromTheme(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +170,39 @@ function initializeDisableVoteSubmission() {
|
||||
});
|
||||
}
|
||||
|
||||
function initializeColoredThumbs() {
|
||||
getBrowser().storage.sync.get(['coloredThumbs'], (res) => {
|
||||
if (res.coloredThumbs === undefined) {
|
||||
getBrowser().storage.sync.set({coloredThumbs: false});
|
||||
}
|
||||
else {
|
||||
extConfig.coloredThumbs = res.coloredThumbs;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initializeColoredBar() {
|
||||
getBrowser().storage.sync.get(['coloredBar'], (res) => {
|
||||
if (res.coloredBar === undefined) {
|
||||
getBrowser().storage.sync.set({coloredBar: false});
|
||||
}
|
||||
else {
|
||||
extConfig.coloredBar = res.coloredBar;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initializeColorTheme() {
|
||||
getBrowser().storage.sync.get(['colorTheme'], (res) => {
|
||||
if (res.colorTheme === undefined) {
|
||||
getBrowser().storage.sync.set({colorTheme: false});
|
||||
}
|
||||
else {
|
||||
extConfig.colorTheme = res.colorTheme;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export {
|
||||
isMobile,
|
||||
isVideoDisliked,
|
||||
|
||||
@@ -99,4 +99,11 @@ function getColorFromTheme(voteIsLike) {
|
||||
return colorString;
|
||||
}
|
||||
|
||||
export { numberFormat, getBrowser, getVideoId, isVideoLoaded, cLog }
|
||||
export {
|
||||
numberFormat,
|
||||
getBrowser,
|
||||
getVideoId,
|
||||
isVideoLoaded,
|
||||
cLog,
|
||||
getColorFromTheme,
|
||||
}
|
||||
Reference in new issue
Block a user