From 0e6d1862715a06311724d18b9661df86bf8b6571 Mon Sep 17 00:00:00 2001 From: Front <27463495+Frontesque@users.noreply.github.com> Date: Mon, 27 Dec 2021 19:05:44 -0500 Subject: [PATCH] add debug info --- Extensions/combined/debug.js | 8 ++ .../dist/chrome/bundled-content-script.js | 89 +++++++++++++------ Extensions/combined/dist/chrome/manifest.json | 4 + Extensions/combined/dist/chrome/popup.html | 15 ++-- Extensions/combined/dist/chrome/popup.js | 50 ++++++++++- .../combined/dist/chrome/ryd.background.js | 66 ++++++++++++-- .../dist/firefox/bundled-content-script.js | 89 +++++++++++++------ .../combined/dist/firefox/manifest.json | 5 ++ Extensions/combined/dist/firefox/popup.html | 15 ++-- Extensions/combined/dist/firefox/popup.js | 50 ++++++++++- .../combined/dist/firefox/ryd.background.js | 66 ++++++++++++-- Extensions/combined/manifest-chrome.json | 4 + Extensions/combined/manifest-firefox.json | 5 ++ Website/nuxt.config.js | 2 +- Website/pages/debug.vue | 5 +- 15 files changed, 383 insertions(+), 90 deletions(-) create mode 100644 Extensions/combined/debug.js diff --git a/Extensions/combined/debug.js b/Extensions/combined/debug.js new file mode 100644 index 0000000..4bff57f --- /dev/null +++ b/Extensions/combined/debug.js @@ -0,0 +1,8 @@ +//--- Get Extension Information ---// +const extension = chrome.runtime.getManifest(); + +//--- Get Debug Elements ---// +const ver = document.getElementById("extension-version"); + +//--- Set Debug Elements ---// +ver.innerHTML = extension.version; \ No newline at end of file diff --git a/Extensions/combined/dist/chrome/bundled-content-script.js b/Extensions/combined/dist/chrome/bundled-content-script.js index 4685457..f7da4cd 100644 --- a/Extensions/combined/dist/chrome/bundled-content-script.js +++ b/Extensions/combined/dist/chrome/bundled-content-script.js @@ -96,11 +96,13 @@ function cLog(message, writer) { function sendVote(vote) { - getBrowser().runtime.sendMessage({ - message: "send_vote", - vote: vote, - videoId: getVideoId(window.location.href) - }); + if (extConfig.disableVoteSubmission !== true) { + getBrowser().runtime.sendMessage({ + message: "send_vote", + vote: vote, + videoId: getVideoId(window.location.href) + }); + } } function sendVideoIds() { @@ -118,7 +120,7 @@ function sendVideoIds() { }); } -function likeClicked(storedData) { +function likeClicked() { if (checkForSignInButton() === false) { if (storedData.previousState === DISLIKED_STATE) { sendVote(1); @@ -141,7 +143,7 @@ function likeClicked(storedData) { } } -function dislikeClicked(storedData) { +function dislikeClicked() { if (checkForSignInButton() == false) { if (storedData.previousState === NEUTRAL_STATE) { sendVote(-1); @@ -166,6 +168,26 @@ function dislikeClicked(storedData) { } } +function addLikeDislikeEventListener() { + var buttons = buttons_getButtons(); + + if (!window.returnDislikeButtonlistenersSet) { + buttons.children[0].addEventListener("click", likeClicked); + buttons.children[1].addEventListener("click", dislikeClicked); + window.returnDislikeButtonlistenersSet = true; + } +} + +function storageChangeHandler(changes, area) { + if (changes.disableVoteSubmission !== undefined) { + handleDisableVoteSubmissionChangeEvent(changes.disableVoteSubmission.newValue); + } +} + +function handleDisableVoteSubmissionChangeEvent(value) { + extConfig.disableVoteSubmission = value; +} + ;// CONCATENATED MODULE: ./Extensions/combined/src/state.js @@ -175,6 +197,14 @@ function dislikeClicked(storedData) { var LIKED_STATE = "LIKED_STATE"; var DISLIKED_STATE = "DISLIKED_STATE"; var NEUTRAL_STATE = "NEUTRAL_STATE"; +var extConfig = { + disableVoteSubmission: false +}; +var storedData = { + likes: 0, + dislikes: 0, + previousState: NEUTRAL_STATE +}; function isMobile() { return location.hostname == "m.youtube.com"; @@ -262,13 +292,29 @@ function setState(storedData) { }); } -function setInitialState(storedData) { +function setInitialState() { setState(storedData); setTimeout(function () { sendVideoIds(); }, 1500); } +function initExtConfig() { + initializeDisableVoteSubmission(); +} + +function initializeDisableVoteSubmission() { + getBrowser().storage.sync.get(['disableVoteSubmission'], function (res) { + if (res.disableVoteSubmission === undefined) { + getBrowser().storage.sync.set({ + disableVoteSubmission: false + }); + } else { + extConfig.disableVoteSubmission = res.disableVoteSubmission; + } + }); +} + ;// CONCATENATED MODULE: ./Extensions/combined/src/buttons.js @@ -308,16 +354,15 @@ function checkForSignInButton() { ;// CONCATENATED MODULE: ./Extensions/combined/ryd.content-script.js +//--- Import Button Functions ---// + //--- Import State Functions ---// + + //--- Import Video & Browser Functions ---// - -var storedData = { - likes: 0, - dislikes: 0, - previousState: NEUTRAL_STATE -}; +initExtConfig(); var jsInitChecktimer = null; function setEventListeners(evt) { @@ -327,19 +372,9 @@ function setEventListeners(evt) { if ((_getButtons = buttons_getButtons()) !== null && _getButtons !== void 0 && _getButtons.offsetParent && isVideoLoaded()) { clearInterval(jsInitChecktimer); jsInitChecktimer = null; - var buttons = buttons_getButtons(); - - if (!window.returnDislikeButtonlistenersSet) { - buttons.children[0].addEventListener("click", function () { - return likeClicked(storedData); - }); - buttons.children[1].addEventListener("click", function () { - return dislikeClicked(storedData); - }); - window.returnDislikeButtonlistenersSet = true; - } - - setInitialState(storedData); + addLikeDislikeEventListener(); + setInitialState(); + getBrowser().storage.onChanged.addListener(storageChangeHandler); } } diff --git a/Extensions/combined/dist/chrome/manifest.json b/Extensions/combined/dist/chrome/manifest.json index bc00d83..d1cf586 100644 --- a/Extensions/combined/dist/chrome/manifest.json +++ b/Extensions/combined/dist/chrome/manifest.json @@ -27,6 +27,10 @@ "exclude_matches": ["*://*.music.youtube.com/*"], "js": ["bundled-content-script.js"], "css": ["content-style.css"] + }, + { + "matches": ["*://*.returnyoutubedislike.com/debug","http://localhost/debug"], + "js": ["debug.js"] } ], "externally_connectable": { diff --git a/Extensions/combined/dist/chrome/popup.html b/Extensions/combined/dist/chrome/popup.html index d97cd65..27910d2 100644 --- a/Extensions/combined/dist/chrome/popup.html +++ b/Extensions/combined/dist/chrome/popup.html @@ -13,17 +13,19 @@

Return YouTube Dislike

by Dmitrii Selivanov & Community

+



+

- +
@@ -32,16 +34,17 @@ Settings
+ Disable like/dislike submission + +
- +
-