[musicbrainz] FIx cover type not being applied

This commit is contained in:
SuperSaltyGamer
2023-07-23 13:27:28 +03:00
parent c6da7481cf
commit d9668a4f53
2 changed files with 2 additions and 2 deletions

View File

@@ -18,5 +18,5 @@
<button type="button" onclick="${e}">Pick from MH Covers...</button>
`)}else if(ae){let e=function(r){r.preventDefault(),le(!1)};const t=document.querySelector("#medium-toolbox");t&&setTimeout(()=>{t.insertAdjacentElement("afterbegin",oe.node`
<button class="btn-link" type="button" onclick="${e}">Search MH Covers</button>
`)},100)}function le(e){var c,s;const t=new URLSearchParams,r=((c=document.querySelector(".subheader bdi"))==null?void 0:c.innerText)??"",n=((s=document.querySelector("h1"))==null?void 0:s.innerText)??"";t.set("artist",r),t.set("album",n),e&&(t.set("remote.port","browser"),t.set("remote.agent","Ame - MusicBrainz"),t.set("remote.text","Pick cover for MusicBrainz release."));const o=open(`${ct}?${t}`,"_blank");!o||!e||(addEventListener("beforeunload",()=>{o==null||o.close()}),addEventListener("message",async a=>{try{if(a.source!==o)return;const i=JSON.parse(a.data);switch(i.action){case"primary":case"secondary":o==null||o.close(),await lt(i);break}}catch{}},!1))}async function lt(e){var i;const r=await(await Ye(e.bigCoverUrl)).blob(),n=new DataTransfer;Object.defineProperty(n,"files",{value:[r]});const o=new DragEvent("drop",{dataTransfer:n});(i=document.querySelector("#drop-zone"))==null||i.dispatchEvent(o);const c=document.querySelector("#add-cover-art tr:last-of-type");if(!c)return;const s=c.querySelector('input[type="checkbox"]');s&&(s.checked=!0);const a=document.body.querySelector(".edit-note");if(a){let l="Seeded with Ame through https://covers.musichoarders.xyz";e.releaseInfo.url&&(l+=` for ${e.releaseInfo.url}`),l+=` from ${e.bigCoverUrl}`,a.value=l}}const ft=`span.fileinput-button.buttons{display:inline-flex;flex-direction:column;gap:.5rem}
`)},100)}function le(e){var c,s;const t=new URLSearchParams,r=((c=document.querySelector(".subheader bdi"))==null?void 0:c.innerText)??"",n=((s=document.querySelector("h1"))==null?void 0:s.innerText)??"";t.set("artist",r),t.set("album",n),e&&(t.set("remote.port","browser"),t.set("remote.agent","Ame - MusicBrainz"),t.set("remote.text","Pick cover for MusicBrainz release."));const o=open(`${ct}?${t}`,"_blank");!o||!e||(addEventListener("beforeunload",()=>{o==null||o.close()}),addEventListener("message",async a=>{try{if(a.source!==o)return;const i=JSON.parse(a.data);switch(i.action){case"primary":case"secondary":o==null||o.close(),await lt(i);break}}catch{}},!1))}async function lt(e){var i;const r=await(await Ye(e.bigCoverUrl)).blob(),n=new DataTransfer;Object.defineProperty(n,"files",{value:[r]});const o=new DragEvent("drop",{dataTransfer:n});(i=document.querySelector("#drop-zone"))==null||i.dispatchEvent(o);const c=document.querySelector("#add-cover-art tr:last-of-type");if(!c)return;const s=c.querySelector('input[type="checkbox"]');s&&s.click();const a=document.body.querySelector(".edit-note");if(a){let l="Seeded with Ame through https://covers.musichoarders.xyz";e.releaseInfo.url&&(l+=` for ${e.releaseInfo.url}`),l+=` from ${e.bigCoverUrl}`,a.value=l}}const ft=`span.fileinput-button.buttons{display:inline-flex;flex-direction:column;gap:.5rem}
`;GM.addStyle(ft)});

View File

@@ -93,7 +93,7 @@ async function pickCover(data: CoverData) {
// Add front type.
const frontTypeEl = newDetailEl.querySelector<HTMLInputElement>('input[type="checkbox"]');
if (frontTypeEl) frontTypeEl.checked = true;
if (frontTypeEl) frontTypeEl.click();
// Add edit note.
const noteEl = document.body.querySelector<HTMLInputElement>('.edit-note');