[applemusic] Fix covers search for various artists

This commit is contained in:
SuperSaltyGamer
2023-08-06 11:46:01 +03:00
parent 039ae9dfbd
commit 0a70d01560
3 changed files with 10 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
// ==UserScript==
// @namespace ame-applemusic
// @name Ame (Apple Music)
// @version 1.9.0
// @version 1.9.1
// @author SuperSaltyGamer
// @run-at document-start
// @match https://music.apple.com/*
@@ -107,7 +107,7 @@
${y}">${u.attributes.name}</a>, </span>`)),await ua(250);continue}o.append(Qt(`<span data-storefront="${u.id}"><a target="_blank" href="https://music.apple.com/${u.id}/album/${r}" title="Fully available">${u.attributes.name}</a>, </span>`)),await ua(250)}}const eh=fa("Search Covers",`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" slot="app-icon">
<path d="M24 44q-4.1 0-7.75-1.575-3.65-1.575-6.375-4.3-2.725-2.725-4.3-6.375Q4 28.1 4 24q0-4.25 1.6-7.9 1.6-3.65 4.375-6.35 2.775-2.7 6.5-4.225Q20.2 4 24.45 4q3.95 0 7.5 1.325T38.175 9q2.675 2.35 4.25 5.575Q44 17.8 44 21.65q0 5.4-3.15 8.525T32.5 33.3h-3.75q-.9 0-1.55.7t-.65 1.55q0 1.35.725 2.3.725.95.725 2.2 0 1.9-1.05 2.925T24 44Zm0-20Zm-11.65 1.3q1 0 1.75-.75t.75-1.75q0-1-.75-1.75t-1.75-.75q-1 0-1.75.75t-.75 1.75q0 1 .75 1.75t1.75.75Zm6.3-8.5q1 0 1.75-.75t.75-1.75q0-1-.75-1.75t-1.75-.75q-1 0-1.75.75t-.75 1.75q0 1 .75 1.75t1.75.75Zm10.7 0q1 0 1.75-.75t.75-1.75q0-1-.75-1.75t-1.75-.75q-1 0-1.75.75t-.75 1.75q0 1 .75 1.75t1.75.75Zm6.55 8.5q1 0 1.75-.75t.75-1.75q0-1-.75-1.75t-1.75-.75q-1 0-1.75.75t-.75 1.75q0 1 .75 1.75t1.75.75ZM24 41q.55 0 .775-.225.225-.225.225-.725 0-.7-.725-1.3-.725-.6-.725-2.65 0-2.3 1.5-4.05t3.8-1.75h3.65q3.8 0 6.15-2.225Q41 25.85 41 21.65q0-6.6-5-10.625T24.45 7q-7.3 0-12.375 4.925T7 24q0 7.05 4.975 12.025Q16.95 41 24 41Z" />
</svg>
`);eh.addEventListener("click",()=>{const e=document.querySelector(".headings__title");if(!e)return;const t=document.querySelector(".headings__subtitles > a");if(!t)return;const r=t.innerText.trim(),n=e.innerText.trim().replace(/ - Single$/i,"").replace(/ - EP$/i,"");open(`https://covers.musichoarders.xyz?artist=${encodeURIComponent(r)}&album=${encodeURIComponent(n)}`,"_blank")}),Ei(()=>{ha(eh,300)}),Gl(()=>{Zl(eh)}),addEventListener("mousedown",async e=>{if(e.button!==2)return;const t=e.target;if(!t.matches(".artwork-component__image:not(.ame-full-sized)"))return;t.classList.add("ame-full-sized");const r=document.querySelector(".artwork__radiosity source");if(!r)return;const n=t.parentElement.querySelectorAll("source");for(const i of Array.from(n))i.srcset=ux(r.srcset)},{passive:!0});function ux(e){return e.split(" ",2)[0].replace(/is\d-ssl/,"a1").replace("image/thumb","r40").split("/").slice(0,-1).join("/")}const Cg=fa("Copy Authorization",`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" slot="app-icon">
`);eh.addEventListener("click",()=>{const e=document.querySelector(".headings__subtitles > a"),t=document.querySelector(".headings__title");if(!t)return;const r=e==null?void 0:e.innerText.trim(),n=t.innerText.trim().replace(/ - Single$/i,"").replace(/ - EP$/i,""),i=new URLSearchParams;r&&i.set("artist",r),i.set("album",n),open(`https://covers.musichoarders.xyz?${i}`,"_blank")}),Ei(()=>{ha(eh,300)}),Gl(()=>{Zl(eh)}),addEventListener("mousedown",async e=>{if(e.button!==2)return;const t=e.target;if(!t.matches(".artwork-component__image:not(.ame-full-sized)"))return;t.classList.add("ame-full-sized");const r=document.querySelector(".artwork__radiosity source");if(!r)return;const n=t.parentElement.querySelectorAll("source");for(const i of Array.from(n))i.srcset=ux(r.srcset)},{passive:!0});function ux(e){return e.split(" ",2)[0].replace(/is\d-ssl/,"a1").replace("image/thumb","r40").split("/").slice(0,-1).join("/")}const Cg=fa("Copy Authorization",`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" slot="app-icon">
<path d="M24 43.95q-7-1.75-11.5-8.125T8 21.85V9.95l16-6 16 6v11.9q0 7.6-4.5 13.975T24 43.95Zm0-3.1q5.75-1.9 9.375-7.175T37 21.85v-9.8l-13-4.9-13 4.9v9.8q0 6.55 3.625 11.825Q18.25 38.95 24 40.85ZM24 24Z" />
</svg>
`);Cg.addEventListener("click",async()=>{GM.setClipboard(await Kl())}),ha(Cg,0);const cx=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" slot="app-icon">

View File

@@ -1,7 +1,7 @@
// ==UserScript==
// @namespace ame-applemusic
// @name Ame (Apple Music)
// @version 1.9.0
// @version 1.9.1
// @author SuperSaltyGamer
// @run-at document-start
// @match https://music.apple.com/*

View File

@@ -5,16 +5,18 @@ import { createButtonElement, hideSidebarButton, showSidebarButton } from "../gl
export const searchCoversButtonEl = createButtonElement("Search Covers", paletteIcon);
searchCoversButtonEl.addEventListener("click", () => {
const artistEl = document.querySelector<HTMLElement>(".headings__subtitles > a");
const titleEl = document.querySelector<HTMLElement>(".headings__title");
if (!titleEl) return;
const artistEl = document.querySelector<HTMLElement>(".headings__subtitles > a");
if (!artistEl) return;
const artist = artistEl.innerText.trim();
const artist = artistEl?.innerText.trim();
const album = titleEl.innerText.trim().replace(/ - Single$/i, "").replace(/ - EP$/i, "");
open(`https://covers.musichoarders.xyz?artist=${encodeURIComponent(artist)}&album=${encodeURIComponent(album)}`, "_blank");
const params = new URLSearchParams();
if (artist) params.set("artist", artist);
params.set("album", album);
open(`https://covers.musichoarders.xyz?${params}`, "_blank");
});
onAlbumRoute(() => {