mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-30 01:47:54 +01:00
add option to disable vote submission
also change the icon of the extension when voting is disabled popup.js, content-script, bg-script listenes to storage change event so that they can all stay in sync without passing messages icon_hold is addded advanced setting is enabled in popup.html add fallback for changing extension icon refactor stateData
This commit is contained in:
1 parent
96f063838d
commit
819c59c5b7
7 files changed
+170
-40
No files matched your search
@@ -18,16 +18,13 @@ import {
|
||||
LIKED_STATE,
|
||||
DISLIKED_STATE,
|
||||
NEUTRAL_STATE,
|
||||
initExtConfig,
|
||||
} from "./src/state";
|
||||
import { numberFormat, getBrowser, getVideoId, isVideoLoaded, cLog } from "./src/utils";
|
||||
import { createRateBar } from "./src/bar";
|
||||
import { sendVideoIds, sendVote, likeClicked, dislikeClicked } from "./src/events"
|
||||
import { sendVideoIds, sendVote, likeClicked, dislikeClicked, addLikeDislikeEventListener, storageChangeHandler } from "./src/events"
|
||||
|
||||
let storedData = {
|
||||
likes: 0,
|
||||
dislikes: 0,
|
||||
previousState: NEUTRAL_STATE,
|
||||
};
|
||||
initExtConfig()
|
||||
|
||||
let jsInitChecktimer = null;
|
||||
|
||||
@@ -36,13 +33,9 @@ function setEventListeners(evt) {
|
||||
if (getButtons()?.offsetParent && isVideoLoaded()) {
|
||||
clearInterval(jsInitChecktimer);
|
||||
jsInitChecktimer = null;
|
||||
const buttons = getButtons();
|
||||
if (!window.returnDislikeButtonlistenersSet) {
|
||||
buttons.children[0].addEventListener("click", () => likeClicked(storedData));
|
||||
buttons.children[1].addEventListener("click", () => dislikeClicked(storedData));
|
||||
window.returnDislikeButtonlistenersSet = true;
|
||||
}
|
||||
setInitialState(storedData);
|
||||
addLikeDislikeEventListener();
|
||||
setInitialState();
|
||||
getBrowser().storage.onChanged.addListener(storageChangeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user