Formatting

This commit is contained in:
Dmitrii Selivanov committed 2021-11-19 16:58:28 +03:00
1 parent 9df69d65dd
commit c8d759627b
4 files changed
+55 -58

No files matched your search

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