()
| 234 | } |
| 235 | |
| 236 | async function storeThisPage() { |
| 237 | let title; |
| 238 | let description; |
| 239 | let contextUri; |
| 240 | |
| 241 | const context = Spicetify.Platform.History.location.pathname; |
| 242 | try { |
| 243 | contextUri = Spicetify.URI.fromString(context); |
| 244 | } catch (e) { |
| 245 | Spicetify.showNotification("Cannot bookmark this page", true); |
| 246 | return; |
| 247 | } |
| 248 | const uri = contextUri.toURI(); |
| 249 | |
| 250 | const titleElem = |
| 251 | document.querySelector(".Root__main-view h1") || |
| 252 | document.querySelector(".Root__main-view h2") || |
| 253 | document.querySelector(".Root__main-view h3") || |
| 254 | document.querySelector(".Root__main-view a"); |
| 255 | |
| 256 | if (titleElem) { |
| 257 | title = titleElem.innerText; |
| 258 | } |
| 259 | |
| 260 | if (!title && contextUri.type === URI.Type.APPLICATION) { |
| 261 | title = idToProperName(contextUri.id); |
| 262 | description = "Application"; |
| 263 | } else { |
| 264 | description = contextUri.type.replace(/-.+$/, ""); |
| 265 | const tail = context.split("/"); |
| 266 | if (tail.length > 3) { |
| 267 | description += ` ${tail[3]}`; |
| 268 | } |
| 269 | description = idToProperName(description); |
| 270 | } |
| 271 | |
| 272 | const headerElem = document.querySelector(".Root__main-view .main-entityHeader-background"); |
| 273 | let imageUrl = headerElem?.style.backgroundImage.replace('url("', "").replace('")', ""); |
| 274 | |
| 275 | if (!imageUrl) { |
| 276 | const firstImgElem = document.querySelector(".Root__main-view img"); |
| 277 | imageUrl = firstImgElem?.src; |
| 278 | } |
| 279 | |
| 280 | LIST.addToStorage({ |
| 281 | uri, |
| 282 | title, |
| 283 | description, |
| 284 | imageUrl, |
| 285 | context, |
| 286 | }); |
| 287 | } |
| 288 | |
| 289 | function getTrackMeta() { |
| 290 | const meta = { |
nothing calls this directly
no test coverage detected