()
| 224 | } |
| 225 | |
| 226 | function InitSidebarXConfig() { |
| 227 | // STICKY container |
| 228 | const YLXAppItems = document.querySelector(".main-yourLibraryX-navItems"); |
| 229 | const libraryItems = document.querySelector(".main-yourLibraryX-library"); |
| 230 | |
| 231 | if (!YLXAppItems || !libraryItems?.querySelector("ul")) { |
| 232 | setTimeout(InitSidebarXConfig, 300); |
| 233 | return; |
| 234 | } |
| 235 | |
| 236 | appItems = YLXAppItems; |
| 237 | buttons = []; |
| 238 | ordered = []; |
| 239 | |
| 240 | appItems.id = "spicetify-sticky-list"; |
| 241 | // SHOW container |
| 242 | list = document.createElement("ul"); |
| 243 | list.id = "spicetify-show-list"; |
| 244 | // HIDDEN container |
| 245 | hiddenList = document.createElement("ul"); |
| 246 | hiddenList.id = "spicetify-hidden-list"; |
| 247 | hiddenList.classList.add("hidden-visually"); |
| 248 | const playlistList = libraryItems.querySelector("ul"); |
| 249 | playlistList.id = "spicetify-playlist-list"; |
| 250 | libraryItems.prepend(list, hiddenList); |
| 251 | |
| 252 | for (const ele of appItems.children) { |
| 253 | ele.dataset.id = ele.querySelector("a").pathname; |
| 254 | buttons.push(ele); |
| 255 | } |
| 256 | |
| 257 | let storage = []; |
| 258 | try { |
| 259 | storage = JSON.parse(localStorage.getItem("spicetify-sidebar-config:ylx")); |
| 260 | if (!Array.isArray(storage)) throw ""; |
| 261 | } catch { |
| 262 | storage = buttons.map((el) => [el.dataset.id, STICKY]); |
| 263 | } |
| 264 | |
| 265 | const observer = new MutationObserver((mutations) => { |
| 266 | for (const mutation of mutations) { |
| 267 | if (mutation.type === "childList" && mutation.addedNodes.length) { |
| 268 | mutation.addedNodes[0].id = "spicetify-playlist-list"; |
| 269 | } |
| 270 | } |
| 271 | }); |
| 272 | observer.observe(playlistList.parentElement, { childList: true }); |
| 273 | |
| 274 | arrangeItems(storage); |
| 275 | appendItems(); |
| 276 | } |
| 277 | |
| 278 | initConfig(); |
| 279 |
no test coverage detected