Push MusicBrainz dist

This commit is contained in:
SuperSaltyGamer
2023-07-22 18:49:42 +03:00
parent e4121e26fa
commit 7dea149d3e

View File

@@ -1,7 +1,7 @@
// ==UserScript==
// @namespace ame-musicbrainz
// @name Ame (MusicBrainz)
// @version 1.1.0
// @version 1.2.0
// @author SuperSaltyGamer
// @run-at document-end
// @match https://musicbrainz.org/*
@@ -12,4 +12,4 @@
// @updateURL https://notabug.org/SuperSaltyGamer/ame/raw/main/dist/musicbrainz.user.js
// ==/UserScript==
(function(n){typeof define=="function"&&define.amd?define(n):n()})(function(){"use strict";const n=/(\d+) +\| +([0-9:.]+) +\| +([0-9:.]+) +\| +(\d+) +\| +(\d+)/g,a=document.querySelector("form[action='/search']"),s=document.querySelector("#headerid-query");s.placeholder="Enhanced search",a.addEventListener("submit",e=>{const r=new FormData(a).get("query").trim(),t=d(r);if(t!=="other")switch(e.preventDefault(),t){case"catalog":const o=r.split("~")[0];location.href=`https://musicbrainz.org/search?type=release&method=advanced&query=catno:${encodeURIComponent(o)}`;break;case"barcode":location.href=`https://musicbrainz.org/search?type=release&method=advanced&query=barcode:${encodeURIComponent(r)}`;break;case"isrc":location.href=`https://musicbrainz.org/search?type=recording&method=advanced&query=isrc:${encodeURIComponent(r)}`;break;case"log-eac":case"log-xld":let i=`?toc=${h(r)}`;location.pathname.startsWith("/release/")&&(i+=`&filter-release.query=${location.pathname.split("/")[2]}`),location.href=`https://musicbrainz.org/cdtoc/attach${i}`;break}});function d(e){return e.match(/^(\d{8}|\d{12}|\d{13}|\d{14})$/i)?"barcode":e.match(/^[a-z]{5}[0-9]{7}$/i)?"isrc":e===e.toUpperCase()&&e.match(/\d/i)&&e.match(/[a-z]/i)&&e.match(/[ ~-]/i)?"catalog":e.includes("TOC of the extracted CD")&&e.includes("EAC extraction logfile")?"log-eac":e.includes("TOC of the extracted CD")&&e.includes("XLD extraction logfile")?"log-xld":"other"}function h(e){const c=[];let r=0;for(const t of e.matchAll(n)){const o=Number(t[1]);if(r>o)break;r=o,c.push({no:o,start:t[2],length:t[3],startSector:Number(t[4]),endSector:Number(t[5])})}return[1,c.length,c[c.length-1].endSector+150+1].concat(c.map(t=>t.startSector+150)).join("%20")}const l="";GM.addStyle(l)});
(function(o){typeof define=="function"&&define.amd?define(o):o()})(function(){"use strict";const o=/(\d+) +\| +([0-9:.]+) +\| +([0-9:.]+) +\| +(\d+) +\| +(\d+)/g,a=document.querySelector("form[action='/search']"),d=document.querySelector("form[action='/search'] button"),s=document.querySelector("#headerid-query");s.focus(),s.placeholder="Enhanced search",a.addEventListener("dragover",e=>{e.preventDefault();const r=e.dataTransfer;r&&(r.dropEffect="link")}),a.addEventListener("drop",async e=>{e.preventDefault();const r=e.dataTransfer;if(!r)return;const t=r.files.item(0);t!=null&&t.name.match(/\.log$/)&&(s.value=await t.text(),d.click())}),a.addEventListener("submit",e=>{const t=new FormData(a).get("query").trim(),n=l(t);if(n!=="other")switch(e.preventDefault(),n){case"catalog":const c=t.split("~")[0];location.href=`https://musicbrainz.org/search?type=release&method=advanced&query=catno:${encodeURIComponent(c)}`;break;case"barcode":location.href=`https://musicbrainz.org/search?type=release&method=advanced&query=barcode:${encodeURIComponent(t)}`;break;case"isrc":location.href=`https://musicbrainz.org/search?type=recording&method=advanced&query=isrc:${encodeURIComponent(t)}`;break;case"log-eac":case"log-xld":let i=`?toc=${f(t)}`;location.pathname.startsWith("/release/")&&(i+=`&filter-release.query=${location.pathname.split("/")[2]}`),location.href=`https://musicbrainz.org/cdtoc/attach${i}`;break}});function l(e){return e.match(/^(\d{8}|\d{12}|\d{13}|\d{14})$/i)?"barcode":e.match(/^[a-z]{5}[0-9]{7}$/i)?"isrc":e===e.toUpperCase()&&e.match(/\d/i)&&e.match(/[a-z]/i)&&e.match(/[ ~-]/i)?"catalog":e.includes("TOC of the extracted CD")&&e.includes("EAC extraction logfile")?"log-eac":e.includes("TOC of the extracted CD")&&e.includes("XLD extraction logfile")?"log-xld":"other"}function f(e){const r=[];let t=0;for(const n of e.matchAll(o)){const c=Number(n[1]);if(t>c)break;t=c,r.push({no:c,start:n[2],length:n[3],startSector:Number(n[4]),endSector:Number(n[5])})}return[1,r.length,r[r.length-1].endSector+150+1].concat(r.map(n=>n.startSector+150)).join("%20")}const h="";GM.addStyle(h)});