add setState, processResponse to state.js, getVideoId to utils.js

This commit is contained in:
Leon Bubova committed 2021-12-18 00:41:12 +01:00
1 parent d51a5a58b0
commit 689b0b7f8c
3 files changed
+51 -47

No files matched your search

+11 -1
View File
@@ -39,6 +39,16 @@ function getBrowser() {
}
}
function getVideoId(url) {
const urlObject = new URL(url);
const pathname = urlObject.pathname;
if (pathname.startsWith("/clip")) {
return document.querySelector("meta[itemprop='videoId']").content;
} else {
return urlObject.searchParams.get("v");
}
}
function cLog(message, writer) {
message = `[return youtube dislike]: ${message}`;
if (writer) {
@@ -48,4 +58,4 @@ function cLog(message, writer) {
}
}
export { numberFormat, getBrowser, cLog }
export { numberFormat, getBrowser, getVideoId, cLog }