diff --git a/Extensions/chrome/background.js b/Extensions/chrome/background.js index 5a3d3ee..b208908 100644 --- a/Extensions/chrome/background.js +++ b/Extensions/chrome/background.js @@ -9,51 +9,50 @@ const apiUrl = "https://return-youtube-dislike-api.azurewebsites.net"; chrome.runtime.onMessageExternal.addListener( (request, sender, sendResponse) => { - if (request.message === "get_auth_token") { - // chrome.identity.getAuthToken({ interactive: true }, function (token) { - // console.log(token); - // chrome.identity.getProfileUserInfo(function (userInfo) { - // console.log(JSON.stringify(userInfo)); - // }); - // }); - } else if (request.message === "log_off") { - // console.log("logging off"); - // chrome.identity.clearAllCachedAuthTokens(() => console.log("logged off")); - } else if (request.message == "set_state") { - // console.log(request); - // chrome.identity.getAuthToken({ interactive: true }, function (token) { - let token = ""; - fetch(`${apiUrl}/votes?videoId=${request.videoId}`, { - method: "GET", - headers: { - Accept: "application/json", - Authorization: "Bearer " + token, - }, + if (request.message === "get_auth_token") { + // chrome.identity.getAuthToken({ interactive: true }, function (token) { + // console.log(token); + // chrome.identity.getProfileUserInfo(function (userInfo) { + // console.log(JSON.stringify(userInfo)); + // }); + // }); + } else if (request.message === "log_off") { + // console.log("logging off"); + // chrome.identity.clearAllCachedAuthTokens(() => console.log("logged off")); + } else if (request.message == "set_state") { + // console.log(request); + // chrome.identity.getAuthToken({ interactive: true }, function (token) { + let token = ""; + fetch(`${apiUrl}/votes?videoId=${request.videoId}`, { + method: "GET", + headers: { + Accept: "application/json", + Authorization: "Bearer " + token, + }, + }) + .then((response) => response.json()) + .then((response) => { + sendResponse(response); }) - .then((response) => response.json()) - .then((response) => { - sendResponse(response); - }) - .catch(); - //}); - return true; - } else if (request.message == "send_links") { - toSend = toSend.concat(request.videoIds.filter((x) => !sentIds.has(x))); - if (toSend.length >= 20) { - fetch(`${apiUrl}/votes`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(toSend), - }); - for (const toSendUrl of toSend) { - sentIds.add(toSendUrl); - } - toSend = []; + .catch(); + //}); + return true; + } else if (request.message == "send_links") { + toSend = toSend.concat(request.videoIds.filter((x) => !sentIds.has(x))); + if (toSend.length >= 20) { + fetch(`${apiUrl}/votes`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(toSend), + }); + for (const toSendUrl of toSend) { + sentIds.add(toSendUrl); } + toSend = []; } - + } } ); diff --git a/Extensions/chrome/content-script.js b/Extensions/chrome/content-script.js index b5bbd3d..1165c84 100644 --- a/Extensions/chrome/content-script.js +++ b/Extensions/chrome/content-script.js @@ -1,10 +1,10 @@ chrome.runtime.sendMessage({}, (securityToken) => { - var script = document.createElement('script'); - script.setAttribute("security-token", securityToken); - script.setAttribute("extension-id", chrome.runtime.id); - script.src = chrome.runtime.getURL('script.js'); - script.onload = function() { - this.remove(); - }; - (document.head || document.documentElement).appendChild(script); + var script = document.createElement("script"); + script.setAttribute("security-token", securityToken); + script.setAttribute("extension-id", chrome.runtime.id); + script.src = chrome.runtime.getURL("script.js"); + script.onload = function () { + this.remove(); + }; + (document.head || document.documentElement).appendChild(script); }); diff --git a/Extensions/chrome/content-style.css b/Extensions/chrome/content-style.css index c06e123..e1f3fa9 100644 --- a/Extensions/chrome/content-style.css +++ b/Extensions/chrome/content-style.css @@ -1,16 +1,14 @@ #return-youtube-dislike-bar-container { - background: #c6c6c6; + background: #c6c6c6; } #return-youtube-dislike-bar { - background: #5094c8; + background: #5094c8; } - [dark] #return-youtube-dislike-bar-container { - } [dark] #return-youtube-dislike-bar { - background: #3ea6ff; + background: #3ea6ff; } diff --git a/Extensions/chrome/manifest.json b/Extensions/chrome/manifest.json index aed3d45..1826122 100644 --- a/Extensions/chrome/manifest.json +++ b/Extensions/chrome/manifest.json @@ -26,9 +26,9 @@ "matches": ["*://*.youtube.com/*"] }, "web_accessible_resources": [ - { - "resources": ["script.js"], + { + "resources": ["script.js"], "matches": ["*://*.youtube.com/*"] - } + } ] }