mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-12-03 19:31:20 +01:00
Revert "Merge pull request #11 from mynovelhost/main"
This reverts commit475106e25f, reversing changes made toeb1756cce9.
This commit is contained in:
1 parent
475106e25f
commit
0a30c0ee05
4 files changed
+19
-32
No files matched your search
@@ -1,12 +1,6 @@
|
|||||||
const apiUrl = "https://return-youtube-dislike-api.azurewebsites.net";
|
const apiUrl = "https://return-youtube-dislike-api.azurewebsites.net";
|
||||||
const securityToken = Math.random().toString(36).substring(2, 15);
|
|
||||||
|
|
||||||
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||||
sendResponse(securityToken);
|
|
||||||
});
|
|
||||||
|
|
||||||
chrome.runtime.onMessageExternal.addListener((request, sender, sendResponse) => {
|
|
||||||
if (request.securityToken === securityToken) {
|
|
||||||
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);
|
||||||
@@ -18,7 +12,7 @@ chrome.runtime.onMessageExternal.addListener((request, sender, sendResponse) =>
|
|||||||
// 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}`, {
|
||||||
@@ -37,5 +31,16 @@ chrome.runtime.onMessageExternal.addListener((request, sender, sendResponse) =>
|
|||||||
//});
|
//});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
|
||||||
|
if (changeInfo.status == "complete") {
|
||||||
|
if (tab.url && tab.url.indexOf("youtube.") < 0) return;
|
||||||
|
chrome.tabs.get(tabId, (tab) => {
|
||||||
|
chrome.scripting.executeScript({
|
||||||
|
target: { tabId: tab.id },
|
||||||
|
files: ["script.js"],
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
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);
|
|
||||||
});
|
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
"background": {
|
"background": {
|
||||||
"service_worker": "background.js"
|
"service_worker": "background.js"
|
||||||
},
|
},
|
||||||
|
"permissions": ["activeTab", "scripting"],
|
||||||
"host_permissions": ["*://*.youtube.com/*"],
|
"host_permissions": ["*://*.youtube.com/*"],
|
||||||
"action": {
|
"action": {
|
||||||
"default_popup": "popup.html"
|
"default_popup": "popup.html"
|
||||||
@@ -18,16 +19,7 @@
|
|||||||
{
|
{
|
||||||
"matches": ["*://*.youtube.com/*"],
|
"matches": ["*://*.youtube.com/*"],
|
||||||
"js": ["content-script.js"],
|
"js": ["content-script.js"],
|
||||||
"run_at": "document_start"
|
"run_at": "document_idle"
|
||||||
}
|
|
||||||
],
|
|
||||||
"externally_connectable": {
|
|
||||||
"matches": ["*://*.youtube.com/*"]
|
|
||||||
},
|
|
||||||
"web_accessible_resources": [
|
|
||||||
{
|
|
||||||
"resources": ["script.js"],
|
|
||||||
"matches": ["*://*.youtube.com/*"]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
(function(securityToken, extensionId) {
|
|
||||||
function getButtons() {
|
function getButtons() {
|
||||||
return document
|
return document
|
||||||
.getElementById("menu-container")
|
.getElementById("menu-container")
|
||||||
@@ -48,8 +47,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setState() {
|
function setState() {
|
||||||
chrome.runtime.sendMessage(extensionId, {
|
chrome.runtime.sendMessage(
|
||||||
securityToken: securityToken,
|
{
|
||||||
message: "set_state",
|
message: "set_state",
|
||||||
videoId: getVideoId(),
|
videoId: getVideoId(),
|
||||||
state: getState(),
|
state: getState(),
|
||||||
@@ -60,7 +59,8 @@
|
|||||||
// setLikes(response.likes);
|
// setLikes(response.likes);
|
||||||
console.log(response);
|
console.log(response);
|
||||||
setDislikes(formattedDislike);
|
setDislikes(formattedDislike);
|
||||||
} else {}
|
} else {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -119,4 +119,4 @@
|
|||||||
|
|
||||||
setEventListeners();
|
setEventListeners();
|
||||||
|
|
||||||
})(document.currentScript.getAttribute("security-token"), document.currentScript.getAttribute("extension-id"));
|
//window.addEventListener("hashchange", setEventListeners, false);
|
||||||
Reference in new issue
Block a user