mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-25 07:43:01 +01:00
add debug info
This commit is contained in:
1 parent
7f82dba4b9
commit
0e6d186271
15 files changed
+383
-90
No files matched your search
@@ -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;
|
||||
+62
-27
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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": {
|
||||
|
||||
+9
-6
@@ -13,17 +13,19 @@
|
||||
<svg width="48" viewBox="0 0 24 24"><path d="M14.9 3H6c-.9 0-1.6.5-1.9 1.2l-3 7c-.1.3-.1.5-.1.7v2c0 1.1.9 2 2 2h6.3l-.9 4.5c-.1.5 0 1 .4 1.4l1.1 1.1 6.5-6.6c.4-.4.6-.9.6-1.4V5c-.1-1.1-1-2-2.1-2zm7.4 12.8h-2.9c-.4 0-.7-.3-.7-.7V3.9c0-.4.3-.7.7-.7h2.9c.4 0 .7.3.7.7V15c0 .4-.3.8-.7.8z" fill="red"/><path d="m8 12.5 5.1-2.9L8 6.7v5.8z" fill="#fff"/></svg>
|
||||
<h1>Return YouTube Dislike</h1>
|
||||
<p>by Dmitrii Selivanov & Community</p>
|
||||
<p id="ext-version"></p>
|
||||
|
||||
<button id="link_website">Website</button>
|
||||
<button id="link_github">GitHub</button>
|
||||
<button id="link_discord">Discord</button>
|
||||
|
||||
<br><br>
|
||||
<button id="link_faq">FAQ</button>
|
||||
<button id="link_donate">Donate</button>
|
||||
<br>
|
||||
|
||||
<br>
|
||||
<!-- <button id="advancedToggle">Show Settings</button>-->
|
||||
<button id="advancedToggle">Show Settings</button>
|
||||
<br>
|
||||
|
||||
</center>
|
||||
@@ -32,16 +34,17 @@
|
||||
<legend id="advancedLegend">Settings</legend>
|
||||
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="disable_ratio_bar" />
|
||||
<input type="checkbox" id="disable_vote_submission" />
|
||||
<span class="slider" />
|
||||
<span class="switchLabel">Lorem ipsum dolor sit amet</span> </label
|
||||
><br />
|
||||
<span class="switchLabel">Disable like/dislike submission</span>
|
||||
</label>
|
||||
<br/>
|
||||
|
||||
<label class="switch">
|
||||
<!-- <label class="switch">
|
||||
<input type="checkbox" id="disable_api_unlisted" />
|
||||
<span class="slider" />
|
||||
<span class="switchLabel">Lorem ipsum dolor sit amet</span> </label
|
||||
><br />
|
||||
><br /> -->
|
||||
</fieldset>
|
||||
</body>
|
||||
<script src="popup.js"></script>
|
||||
|
||||
+46
-4
@@ -3,12 +3,24 @@ const config = {
|
||||
advanced: false,
|
||||
showAdvancedMessage: "Show Settings",
|
||||
hideAdvancedMessage: "Hide Settings",
|
||||
disableVoteSubmission: false,
|
||||
}
|
||||
|
||||
function initConfig() {
|
||||
initializeVersionNumber();
|
||||
}
|
||||
|
||||
function initializeVersionNumber() {
|
||||
const version = chrome.runtime.getManifest().version;
|
||||
document.getElementById('ext-version').innerHTML = 'v' + version;
|
||||
}
|
||||
|
||||
links: {
|
||||
website: "https://returnyoutubedislike.com",
|
||||
github: "https://github.com/Anarios/return-youtube-dislike",
|
||||
discord: "https://discord.gg/mYnESY4Md5",
|
||||
donate: 'https://returnyoutubedislike.com/donate'
|
||||
donate: 'https://returnyoutubedislike.com/donate',
|
||||
faq: 'https://returnyoutubedislike.com/faq'
|
||||
},
|
||||
};
|
||||
|
||||
@@ -25,14 +37,20 @@ document.getElementById("link_discord").addEventListener("click", () => {
|
||||
chrome.tabs.create({ url: config.links.discord });
|
||||
});
|
||||
|
||||
document.getElementById("link_faq").addEventListener("click", () => {
|
||||
chrome.tabs.create({ url: config.links.faq });
|
||||
});
|
||||
|
||||
document.getElementById("link_donate").addEventListener("click", () => {
|
||||
chrome.tabs.create({ url: config.links.donate });
|
||||
});
|
||||
|
||||
|
||||
chrome.runtime.sendMessage({ message: 'get_auth_token' });
|
||||
document.getElementById("disable_vote_submission").addEventListener("click", (ev) => {
|
||||
chrome.storage.sync.set({ disableVoteSubmission: ev.target.checked });
|
||||
});
|
||||
|
||||
/* Advanced Toggle */
|
||||
/* Not currently used in this version
|
||||
const advancedToggle = document.getElementById("advancedToggle");
|
||||
advancedToggle.addEventListener("click", () => {
|
||||
const adv = document.getElementById("advancedSettings");
|
||||
@@ -46,7 +64,31 @@ advancedToggle.addEventListener("click", () => {
|
||||
config.advanced = true;
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
initConfig();
|
||||
|
||||
function initConfig() {
|
||||
initializeDisableVoteSubmission();
|
||||
}
|
||||
|
||||
function initializeDisableVoteSubmission() {
|
||||
chrome.storage.sync.get(['disableVoteSubmission'], (res) => {
|
||||
handleDisableVoteSubmissionChangeEvent(res.disableVoteSubmission);
|
||||
});
|
||||
}
|
||||
|
||||
chrome.storage.onChanged.addListener(storageChangeHandler);
|
||||
|
||||
function storageChangeHandler(changes, area) {
|
||||
if (changes.disableVoteSubmission !== undefined) {
|
||||
handleDisableVoteSubmissionChangeEvent(changes.disableVoteSubmission.newValue);
|
||||
}
|
||||
}
|
||||
|
||||
function handleDisableVoteSubmissionChangeEvent(value) {
|
||||
config.disableVoteSubmission = value;
|
||||
document.getElementById("disable_vote_submission").checked = value;
|
||||
}
|
||||
|
||||
/* popup-script.js
|
||||
document.querySelector('#login')
|
||||
|
||||
+59
-7
@@ -1,12 +1,17 @@
|
||||
const apiUrl = "https://returnyoutubedislikeapi.com";
|
||||
const voteDisabledIconName = 'icon_hold128.png';
|
||||
const defaultIconName = 'icon128.png';
|
||||
let api;
|
||||
if (typeof chrome !== "undefined" && typeof chrome.runtime !== "undefined")
|
||||
api = chrome;
|
||||
else if (
|
||||
typeof browser !== "undefined" &&
|
||||
typeof browser.runtime !== "undefined"
|
||||
)
|
||||
api = browser;
|
||||
|
||||
/** stores extension's global config */
|
||||
let extConfig = {
|
||||
disableVoteSubmission: false
|
||||
}
|
||||
|
||||
if (isChrome()) api = chrome;
|
||||
else if (isFirefox()) api = browser;
|
||||
|
||||
initExtConfig()
|
||||
|
||||
api.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||
if (request.message === "get_auth_token") {
|
||||
@@ -218,3 +223,50 @@ function generateUserID(length = 36) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
function storageChangeHandler(changes, area) {
|
||||
if (changes.disableVoteSubmission !== undefined) {
|
||||
handleDisableVoteSubmissionChangeEvent(changes.disableVoteSubmission.newValue);
|
||||
}
|
||||
}
|
||||
|
||||
function handleDisableVoteSubmissionChangeEvent(value) {
|
||||
extConfig.disableVoteSubmission = value;
|
||||
if (value === true) {
|
||||
changeIcon(voteDisabledIconName);
|
||||
} else {
|
||||
changeIcon(defaultIconName);
|
||||
}
|
||||
}
|
||||
|
||||
function changeIcon(iconName) {
|
||||
if (api.action !== undefined) api.action.setIcon({path: "/icons/" + iconName});
|
||||
else if (api.browserAction !== undefined) api.browserAction.setIcon({path: "/icons/" + iconName});
|
||||
else console.log('changing icon is not supported');
|
||||
}
|
||||
|
||||
api.storage.onChanged.addListener(storageChangeHandler);
|
||||
|
||||
function initExtConfig() {
|
||||
initializeDisableVoteSubmission();
|
||||
}
|
||||
|
||||
function initializeDisableVoteSubmission() {
|
||||
api.storage.sync.get(['disableVoteSubmission'], (res) => {
|
||||
if (res.disableVoteSubmission === undefined) {
|
||||
api.storage.sync.set({disableVoteSubmission: false});
|
||||
}
|
||||
else {
|
||||
extConfig.disableVoteSubmission = res.disableVoteSubmission;
|
||||
if (res.disableVoteSubmission) changeIcon(voteDisabledIconName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function isChrome() {
|
||||
return typeof chrome !== "undefined" && typeof chrome.runtime !== "undefined";
|
||||
}
|
||||
|
||||
function isFirefox() {
|
||||
return typeof browser !== "undefined" && typeof browser.runtime !== "undefined";
|
||||
}
|
||||
+62
-27
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
"run_at": "document_idle",
|
||||
"css": ["content-style.css"],
|
||||
"js": ["bundled-content-script.js"]
|
||||
},
|
||||
{
|
||||
"matches": ["*://*.returnyoutubedislike.com/debug","http://localhost/debug"],
|
||||
"run_at": "document_idle",
|
||||
"js": ["debug.js"]
|
||||
}
|
||||
]
|
||||
}
|
||||
+9
-6
@@ -13,17 +13,19 @@
|
||||
<svg width="48" viewBox="0 0 24 24"><path d="M14.9 3H6c-.9 0-1.6.5-1.9 1.2l-3 7c-.1.3-.1.5-.1.7v2c0 1.1.9 2 2 2h6.3l-.9 4.5c-.1.5 0 1 .4 1.4l1.1 1.1 6.5-6.6c.4-.4.6-.9.6-1.4V5c-.1-1.1-1-2-2.1-2zm7.4 12.8h-2.9c-.4 0-.7-.3-.7-.7V3.9c0-.4.3-.7.7-.7h2.9c.4 0 .7.3.7.7V15c0 .4-.3.8-.7.8z" fill="red"/><path d="m8 12.5 5.1-2.9L8 6.7v5.8z" fill="#fff"/></svg>
|
||||
<h1>Return YouTube Dislike</h1>
|
||||
<p>by Dmitrii Selivanov & Community</p>
|
||||
<p id="ext-version"></p>
|
||||
|
||||
<button id="link_website">Website</button>
|
||||
<button id="link_github">GitHub</button>
|
||||
<button id="link_discord">Discord</button>
|
||||
|
||||
<br><br>
|
||||
<button id="link_faq">FAQ</button>
|
||||
<button id="link_donate">Donate</button>
|
||||
<br>
|
||||
|
||||
<br>
|
||||
<!-- <button id="advancedToggle">Show Settings</button>-->
|
||||
<button id="advancedToggle">Show Settings</button>
|
||||
<br>
|
||||
|
||||
</center>
|
||||
@@ -32,16 +34,17 @@
|
||||
<legend id="advancedLegend">Settings</legend>
|
||||
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="disable_ratio_bar" />
|
||||
<input type="checkbox" id="disable_vote_submission" />
|
||||
<span class="slider" />
|
||||
<span class="switchLabel">Lorem ipsum dolor sit amet</span> </label
|
||||
><br />
|
||||
<span class="switchLabel">Disable like/dislike submission</span>
|
||||
</label>
|
||||
<br/>
|
||||
|
||||
<label class="switch">
|
||||
<!-- <label class="switch">
|
||||
<input type="checkbox" id="disable_api_unlisted" />
|
||||
<span class="slider" />
|
||||
<span class="switchLabel">Lorem ipsum dolor sit amet</span> </label
|
||||
><br />
|
||||
><br /> -->
|
||||
</fieldset>
|
||||
</body>
|
||||
<script src="popup.js"></script>
|
||||
|
||||
+46
-4
@@ -3,12 +3,24 @@ const config = {
|
||||
advanced: false,
|
||||
showAdvancedMessage: "Show Settings",
|
||||
hideAdvancedMessage: "Hide Settings",
|
||||
disableVoteSubmission: false,
|
||||
}
|
||||
|
||||
function initConfig() {
|
||||
initializeVersionNumber();
|
||||
}
|
||||
|
||||
function initializeVersionNumber() {
|
||||
const version = chrome.runtime.getManifest().version;
|
||||
document.getElementById('ext-version').innerHTML = 'v' + version;
|
||||
}
|
||||
|
||||
links: {
|
||||
website: "https://returnyoutubedislike.com",
|
||||
github: "https://github.com/Anarios/return-youtube-dislike",
|
||||
discord: "https://discord.gg/mYnESY4Md5",
|
||||
donate: 'https://returnyoutubedislike.com/donate'
|
||||
donate: 'https://returnyoutubedislike.com/donate',
|
||||
faq: 'https://returnyoutubedislike.com/faq'
|
||||
},
|
||||
};
|
||||
|
||||
@@ -25,14 +37,20 @@ document.getElementById("link_discord").addEventListener("click", () => {
|
||||
chrome.tabs.create({ url: config.links.discord });
|
||||
});
|
||||
|
||||
document.getElementById("link_faq").addEventListener("click", () => {
|
||||
chrome.tabs.create({ url: config.links.faq });
|
||||
});
|
||||
|
||||
document.getElementById("link_donate").addEventListener("click", () => {
|
||||
chrome.tabs.create({ url: config.links.donate });
|
||||
});
|
||||
|
||||
|
||||
chrome.runtime.sendMessage({ message: 'get_auth_token' });
|
||||
document.getElementById("disable_vote_submission").addEventListener("click", (ev) => {
|
||||
chrome.storage.sync.set({ disableVoteSubmission: ev.target.checked });
|
||||
});
|
||||
|
||||
/* Advanced Toggle */
|
||||
/* Not currently used in this version
|
||||
const advancedToggle = document.getElementById("advancedToggle");
|
||||
advancedToggle.addEventListener("click", () => {
|
||||
const adv = document.getElementById("advancedSettings");
|
||||
@@ -46,7 +64,31 @@ advancedToggle.addEventListener("click", () => {
|
||||
config.advanced = true;
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
initConfig();
|
||||
|
||||
function initConfig() {
|
||||
initializeDisableVoteSubmission();
|
||||
}
|
||||
|
||||
function initializeDisableVoteSubmission() {
|
||||
chrome.storage.sync.get(['disableVoteSubmission'], (res) => {
|
||||
handleDisableVoteSubmissionChangeEvent(res.disableVoteSubmission);
|
||||
});
|
||||
}
|
||||
|
||||
chrome.storage.onChanged.addListener(storageChangeHandler);
|
||||
|
||||
function storageChangeHandler(changes, area) {
|
||||
if (changes.disableVoteSubmission !== undefined) {
|
||||
handleDisableVoteSubmissionChangeEvent(changes.disableVoteSubmission.newValue);
|
||||
}
|
||||
}
|
||||
|
||||
function handleDisableVoteSubmissionChangeEvent(value) {
|
||||
config.disableVoteSubmission = value;
|
||||
document.getElementById("disable_vote_submission").checked = value;
|
||||
}
|
||||
|
||||
/* popup-script.js
|
||||
document.querySelector('#login')
|
||||
|
||||
+59
-7
@@ -1,12 +1,17 @@
|
||||
const apiUrl = "https://returnyoutubedislikeapi.com";
|
||||
const voteDisabledIconName = 'icon_hold128.png';
|
||||
const defaultIconName = 'icon128.png';
|
||||
let api;
|
||||
if (typeof chrome !== "undefined" && typeof chrome.runtime !== "undefined")
|
||||
api = chrome;
|
||||
else if (
|
||||
typeof browser !== "undefined" &&
|
||||
typeof browser.runtime !== "undefined"
|
||||
)
|
||||
api = browser;
|
||||
|
||||
/** stores extension's global config */
|
||||
let extConfig = {
|
||||
disableVoteSubmission: false
|
||||
}
|
||||
|
||||
if (isChrome()) api = chrome;
|
||||
else if (isFirefox()) api = browser;
|
||||
|
||||
initExtConfig()
|
||||
|
||||
api.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||
if (request.message === "get_auth_token") {
|
||||
@@ -218,3 +223,50 @@ function generateUserID(length = 36) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
function storageChangeHandler(changes, area) {
|
||||
if (changes.disableVoteSubmission !== undefined) {
|
||||
handleDisableVoteSubmissionChangeEvent(changes.disableVoteSubmission.newValue);
|
||||
}
|
||||
}
|
||||
|
||||
function handleDisableVoteSubmissionChangeEvent(value) {
|
||||
extConfig.disableVoteSubmission = value;
|
||||
if (value === true) {
|
||||
changeIcon(voteDisabledIconName);
|
||||
} else {
|
||||
changeIcon(defaultIconName);
|
||||
}
|
||||
}
|
||||
|
||||
function changeIcon(iconName) {
|
||||
if (api.action !== undefined) api.action.setIcon({path: "/icons/" + iconName});
|
||||
else if (api.browserAction !== undefined) api.browserAction.setIcon({path: "/icons/" + iconName});
|
||||
else console.log('changing icon is not supported');
|
||||
}
|
||||
|
||||
api.storage.onChanged.addListener(storageChangeHandler);
|
||||
|
||||
function initExtConfig() {
|
||||
initializeDisableVoteSubmission();
|
||||
}
|
||||
|
||||
function initializeDisableVoteSubmission() {
|
||||
api.storage.sync.get(['disableVoteSubmission'], (res) => {
|
||||
if (res.disableVoteSubmission === undefined) {
|
||||
api.storage.sync.set({disableVoteSubmission: false});
|
||||
}
|
||||
else {
|
||||
extConfig.disableVoteSubmission = res.disableVoteSubmission;
|
||||
if (res.disableVoteSubmission) changeIcon(voteDisabledIconName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function isChrome() {
|
||||
return typeof chrome !== "undefined" && typeof chrome.runtime !== "undefined";
|
||||
}
|
||||
|
||||
function isFirefox() {
|
||||
return typeof browser !== "undefined" && typeof browser.runtime !== "undefined";
|
||||
}
|
||||
@@ -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": {
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
"run_at": "document_idle",
|
||||
"css": ["content-style.css"],
|
||||
"js": ["bundled-content-script.js"]
|
||||
},
|
||||
{
|
||||
"matches": ["*://*.returnyoutubedislike.com/debug","http://localhost/debug"],
|
||||
"run_at": "document_idle",
|
||||
"js": ["debug.js"]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -31,7 +31,7 @@ export default {
|
||||
apiUrl: "https://returnyoutubedislikeapi.com",
|
||||
},
|
||||
|
||||
//server: { host: '0.0.0.0' }, //LINE FOR DEBUGGING ONLY
|
||||
//server: { host: '0.0.0.0', port: 80 }, //LINE FOR DEBUGGING ONLY
|
||||
|
||||
target: "static",
|
||||
css: [],
|
||||
|
||||
@@ -11,7 +11,10 @@
|
||||
<span>Version: {{ device._parsed.version }}</span><br>
|
||||
<span>Operating System: {{ device._parsed.os }}</span><br>
|
||||
<span>Operating System Version: {{ device._parsed.os_version }}</span><br>
|
||||
<span>Device Type: {{ device._parsed.category }}</span><br>
|
||||
<span>Device Type: {{ device._parsed.category }}</span><br><br>
|
||||
<!-- Gather Extension Information -->
|
||||
<span><b>Installed Extension Information:</b></span><br>
|
||||
<span>Extension Version: <span id="extension-version"/></span><br>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer />
|
||||
|
||||
Reference in new issue
Block a user