Skip to content

Commit

Permalink
Added function to get specific page type
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkelM committed Nov 25, 2023
1 parent 4ff105e commit 11d8623
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ export function isVideoUrl(url) {
return urlParts[3]?.startsWith("watch?v=") ?? false;
}

export function getPageTypeFromURL(url) {
if (!url) return false;

const urlParts = url.split("/");
if (urlParts[3]?.startsWith("watch?v=")) {
return "video";
} else if (urlParts[3]?.startsWith("shorts")) {
return "short";
} else {
return "channel";
}
}

// ----- DOM -----
export function setDOMTextWithDelay(textElement, newText, delayMS, predicate = () => { return true; }) {
// Sets the innerHTML of a (text) DOM element after a delay, if a predicate evaluates to true
Expand Down

0 comments on commit 11d8623

Please sign in to comment.