[READ-ONLY] Mirror of https://github.com/probablykasper/thumbnail-grabber. Chrome extension for grabbing thumbnails/covers
browser-extension chrome chrome-extension chrome-extention extension
0

Configure Feed

Select the types of activity you want to include in your feed.

Added support for Spotify

Kasper (Dec 11, 2020, 9:03 PM +0100) 6e80a3d9 75559536

+35 -7
+19
src/content-script.js
··· 168 168 const id = new URL(newUrl).searchParams.get('v'); 169 169 imgUrl = await getYouTubeThumbnail(id); 170 170 } 171 + } else if (site == 'spotify') { 172 + filename = 'Cover'; 173 + if (newUrl == location.href) { 174 + const coverEl = document.querySelector('._4c838ef3d2b6da1a61669046bbfae3d1-scss'); 175 + if (coverEl.srcset) { 176 + // For /album/ urls. 177 + const srcset = coverEl.srcset.split(','); 178 + // The last src in srcset is the highest res 179 + const srcItem = srcset[srcset.length-1].trim(); 180 + const srcUrl = srcItem.split(' ')[0] 181 + imgUrl = srcUrl 182 + } else { 183 + // For /playlist/ urls 184 + imgUrl = coverEl.src 185 + } 186 + } else { 187 + const id = new URL(newUrl).searchParams.get('v'); 188 + imgUrl = await getYouTubeThumbnail(id); 189 + } 171 190 } else { 172 191 throw 'Not supported on this URL'; 173 192 }
+16 -7
src/modules/url-util.js
··· 33 33 && url.pathname == '/watch' 34 34 && url.searchParams.has('v') 35 35 }, 36 - // { 37 - // name: 'spotify', 38 - // matchPattern: '*://open.spotify.com/album/*', 39 - // checkUrl: (url) => 40 - // url.hostname.endsWith('open.spotify.com') 41 - // && url.pathname.startsWith('/album') 42 - // }, 36 + { 37 + name: 'spotify', 38 + matchPattern: '*://open.spotify.com/album/*', 39 + checkUrl: (url) => 40 + // allow www 41 + url.hostname == 'open.spotify.com' 42 + && url.pathname.startsWith('/album') 43 + }, 44 + { 45 + name: 'spotify', 46 + matchPattern: '*://open.spotify.com/playlist/*', 47 + checkUrl: (url) => 48 + // allow www 49 + url.hostname == 'open.spotify.com' 50 + && url.pathname.startsWith('/playlist') 51 + }, 43 52 ]; 44 53 45 54 const matchPatterns = [];