mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-23 14:53:01 +01:00
Add user option to re-format likes
fixes #543 This feature does not force-display likes when uploader has disabled like number display. Consult with other issues.
This commit is contained in:
1 parent
a99410ae13
commit
09b29d7cab
5 files changed
+70
No files matched your search
@@ -130,6 +130,9 @@ function storageChangeHandler(changes, area) {
|
||||
if (changes.numberDisplayFormat !== undefined) {
|
||||
handleNumberDisplayFormatChangeEvent(changes.numberDisplayFormat.newValue);
|
||||
}
|
||||
if (changes.numberDisplayReformatLikes !== undefined) {
|
||||
handleNumberDisplayReformatLikesChangeEvent(changes.numberDisplayReformatLikes.newValue);
|
||||
}
|
||||
}
|
||||
|
||||
function handleDisableVoteSubmissionChangeEvent(value) {
|
||||
@@ -157,6 +160,10 @@ function handleNumberDisplayRoundDownChangeEvent(value) {
|
||||
extConfig.numberDisplayRoundDown = value;
|
||||
}
|
||||
|
||||
function handleNumberDisplayReformatLikesChangeEvent(value) {
|
||||
extConfig.numberDisplayReformatLikes = value;
|
||||
}
|
||||
|
||||
export {
|
||||
sendVote,
|
||||
sendVideoIds,
|
||||
|
||||
@@ -24,6 +24,7 @@ let extConfig = {
|
||||
colorTheme: "classic",
|
||||
numberDisplayFormat: "compactShort",
|
||||
numberDisplayRoundDown: true,
|
||||
numberDisplayReformatLikes: false,
|
||||
};
|
||||
|
||||
let storedData = {
|
||||
@@ -115,6 +116,12 @@ function getLikeCountFromButton() {
|
||||
function processResponse(response, storedData) {
|
||||
const formattedDislike = numberFormat(response.dislikes);
|
||||
setDislikes(formattedDislike);
|
||||
if (extConfig.numberDisplayReformatLikes === true) {
|
||||
const nativeLikes = getLikeCountFromButton();
|
||||
if (nativeLikes !== false) {
|
||||
setLikes(numberFormat(nativeLikes));
|
||||
}
|
||||
}
|
||||
storedData.dislikes = parseInt(response.dislikes);
|
||||
storedData.likes = getLikeCountFromButton() || parseInt(response.likes);
|
||||
createRateBar(storedData.likes, storedData.dislikes);
|
||||
@@ -171,6 +178,7 @@ function initExtConfig() {
|
||||
initializeColorTheme();
|
||||
initializeNumberDisplayFormat();
|
||||
initializeNumberDisplayRoundDown();
|
||||
initializeNumberDisplayReformatLikes();
|
||||
}
|
||||
|
||||
function initializeDisableVoteSubmission() {
|
||||
@@ -233,6 +241,16 @@ function initializeNumberDisplayFormat() {
|
||||
});
|
||||
}
|
||||
|
||||
function initializeNumberDisplayReformatLikes() {
|
||||
getBrowser().storage.sync.get(["numberDisplayReformatLikes"], (res) => {
|
||||
if (res.numberDisplayReformatLikes === undefined) {
|
||||
getBrowser().storage.sync.set({ numberDisplayReformatLikes: false });
|
||||
} else {
|
||||
extConfig.numberDisplayReformatLikes = res.numberDisplayReformatLikes;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export {
|
||||
isMobile,
|
||||
isShorts,
|
||||
|
||||
Reference in new issue
Block a user