MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / getVideoId

Function getVideoId

scripts/youtube_viewDislikes.js:165–176  ·  view source on GitHub ↗
(url = location.href)

Source from the content-addressed store, hash-verified

163}
164
165function getVideoId(url = location.href) {
166 const urlObject = new URL(url);
167 const pathname = urlObject.pathname;
168 if (pathname.startsWith("/clip")) {
169 return document.querySelector("meta[itemprop='videoId']").content;
170 } else {
171 if (pathname.startsWith("/shorts")) {
172 return pathname.slice(8);
173 }
174 return urlObject.searchParams.get("v");
175 }
176}
177
178function isInViewport(element) {
179 const rect = element.getBoundingClientRect();

Callers 4

listenShortFunction · 0.70
listenVideoFunction · 0.70
isVideoLoadedFunction · 0.70

Calls 1

getMethod · 0.80

Tested by

no test coverage detected