(url = location.href)
| 163 | } |
| 164 | |
| 165 | function 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 | |
| 178 | function isInViewport(element) { |
| 179 | const rect = element.getBoundingClientRect(); |
no test coverage detected