diff --git a/README.md b/README.md index 41f62d4..d89f422 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,9 @@ Install [ViolentMonkey](https://violentmonkey.github.io) or [TamperMonkey](https ### References -Inspired by and used for reference: +Inspired by and/or used for reference: * https://github.com/lisonge/vite-plugin-monkey * https://github.com/chocolateboy/gm-compat * https://gist.github.com/bunnykek/7f099f55fc558f398cb4cedf6c02c794 +* https://github.com/ToadKing/apple-music-barcode-isrc diff --git a/dist/applemusic.user.js b/dist/applemusic.user.js index b327b0e..f12c558 100644 --- a/dist/applemusic.user.js +++ b/dist/applemusic.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @namespace ame-applemusic // @name Ame (Apple Music) -// @version 1.6.2 +// @version 1.7.0 // @author SuperSaltyGamer // @run-at document-start // @match https://music.apple.com/* @@ -12,15 +12,15 @@ // @updateURL https://notabug.org/SuperSaltyGamer/ame/raw/main/dist/applemusic.user.js // ==/UserScript== -(function(ca){typeof define=="function"&&define.amd?define(ca):ca()})(function(){"use strict";const ca=new Map;function ko(e,t){return new Promise((r,n)=>{const o=ca.get(e);if(o){r(o.clone());return}GM.xmlHttpRequest({method:(t==null?void 0:t.method)??"GET",url:e,headers:Object.fromEntries(new Headers(t==null?void 0:t.headers)),responseType:"blob",onload(i){if(i.status!==404&&(i.status<200||i.status>299)){n(new Error(`Fetching "${e}" responded with an erroneous status code.`));return}const a=i.responseHeaders.split(`\r -`).slice(0,-1).map(s=>s.split(": ")),l=new Response(i.response,{headers:Object.fromEntries(a),status:i.status,statusText:i.statusText});Object.defineProperty(l,"url",{value:e}),ca.set(e,l.clone()),r(l)},onerror(){n(new TypeError("Network request errored."))},ontimeout(){n(new TypeError("Network request timed out."))}})})}function $A(e){for(var t=[],r=0;r=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122||a===95){o+=e[i++];continue}break}if(!o)throw new TypeError("Missing parameter name at ".concat(r));t.push({type:"NAME",index:r,value:o}),r=i;continue}if(n==="("){var l=1,s="",i=r+1;if(e[i]==="?")throw new TypeError('Pattern cannot start with "?" at '.concat(i));for(;i)?(?!\?)/g,n=0,o=r.exec(e.source);o;)t.push({name:o[1]||n++,prefix:"",suffix:"",modifier:"",pattern:""}),o=r.exec(e.source);return e}function DA(e,t,r){var n=e.map(function(o){return dp(o,t,r).source});return new RegExp("(?:".concat(n.join("|"),")"),hp(r))}function HA(e,t,r){return LA(IA(e,r),t,r)}function LA(e,t,r){r===void 0&&(r={});for(var n=r.strict,o=n===void 0?!1:n,i=r.start,a=i===void 0?!0:i,l=r.end,s=l===void 0?!0:l,u=r.encode,c=u===void 0?function(_e){return _e}:u,f=r.delimiter,h=f===void 0?"/#?":f,d=r.endsWith,y=d===void 0?"":d,g="[".concat(Ao(y),"]|$"),b="[".concat(Ao(h),"]"),C=a?"^":"",T=0,A=e;T-1:Y===void 0;o||(C+="(?:".concat(b,"(?=").concat(g,"))?")),ue||(C+="(?=".concat(b,"|").concat(g,")"))}return new RegExp(C,hp(r))}function dp(e,t,r){return e instanceof RegExp?NA(e,t):Array.isArray(e)?DA(e,t,r):HA(e,t,r)}let Lr=unsafeWindow;Lr.wrappedJSObject&&(Lr=Lr.wrappedJSObject);const FA=typeof cloneInto=="function"?cloneInto:e=>e,jA=typeof exportFunction=="function"?exportFunction:e=>e;function VA(e){return FA(e,Lr,{cloneFunctions:!0,wrapReflectors:!0})}function BA(e){return jA(e,Lr)}function WA(e,t){return t??(t=Lr),function(...r){return e.call(t,...VA(r))}}const qf=[],zA=WA(Lr.history.pushState,Lr.history);Lr.history.pushState=BA(UA);function UA(e,t,r){zA(e,t,r),vp()}addEventListener("popstate",()=>{vp()});function vp(){for(const e of qf){const t=e.matcher(location.pathname)?e.onCallbacks:e.offCallbacks;for(const r of t)r()}}function mp(e){let t=qf.find(r=>r.pattern===e);return t||(t={pattern:e,matcher:xA(e),onCallbacks:[],offCallbacks:[]},qf.push(t),t)}function GA(e,t,r=!1){const n=mp(e),o=n.matcher(location.pathname);n.onCallbacks.push(t),o&&t()}function YA(e,t,r=!1){const n=mp(e),o=n.matcher(location.pathname);n.offCallbacks.push(t),o||t()}function Ws(e){return new Promise(t=>{setTimeout(t,e)})}function Nt(e){const t=document.createElement("div");return t.innerHTML=e,t.firstElementChild}function zs(e,t,r=5e3,n=document){return new Promise(o=>{let i=0,a=0;i=setTimeout(()=>{clearInterval(a),o(null)},r),a=setInterval(()=>{let l=n.querySelector(t??e);l&&(t&&(l=n.querySelector(e),!l)||(o(l),clearTimeout(i),clearInterval(a)))},10)})}function KA(e,t){new MutationObserver(n=>{for(const o of n)for(const i of Array.from(o.addedNodes))if(i instanceof Element&&i.matches(e)){t(i);return}}).observe(document.body,{childList:!0,subtree:!0})}const yp="/:country/album/:slug?/:id";function Po(e,t=!1){GA(yp,e,t)}function Us(e,t=!1){YA(yp,e,t)}let Gs=null;function fa(e,t){return Nt(` +(function(fa){typeof define=="function"&&define.amd?define(fa):fa()})(function(){"use strict";const fa=new Map;function Bn(e,t){return new Promise((r,n)=>{const i=fa.get(e);if(i){r(i.clone());return}GM.xmlHttpRequest({method:(t==null?void 0:t.method)??"GET",url:e,headers:Object.fromEntries(new Headers(t==null?void 0:t.headers)),responseType:"blob",onload(o){if(o.status!==404&&(o.status<200||o.status>299)){n(new Error(`Fetching "${e}" responded with an erroneous status code.`));return}const a=o.responseHeaders.split(`\r +`).slice(0,-1).map(l=>l.split(": ")),s=new Response(o.response,{headers:Object.fromEntries(a),status:o.status,statusText:o.statusText});Object.defineProperty(s,"url",{value:e}),fa.set(e,s.clone()),r(s)},onerror(){n(new TypeError("Network request errored."))},ontimeout(){n(new TypeError("Network request timed out."))}})})}function Bx(e){for(var t=[],r=0;r=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122||a===95){i+=e[o++];continue}break}if(!i)throw new TypeError("Missing parameter name at ".concat(r));t.push({type:"NAME",index:r,value:i}),r=o;continue}if(n==="("){var s=1,l="",o=r+1;if(e[o]==="?")throw new TypeError('Pattern cannot start with "?" at '.concat(o));for(;o)?(?!\?)/g,n=0,i=r.exec(e.source);i;)t.push({name:i[1]||n++,prefix:"",suffix:"",modifier:"",pattern:""}),i=r.exec(e.source);return e}function Ux(e,t,r){var n=e.map(function(i){return yg(i,t,r).source});return new RegExp("(?:".concat(n.join("|"),")"),pg(r))}function Gx(e,t,r){return Yx(jx(e,r),t,r)}function Yx(e,t,r){r===void 0&&(r={});for(var n=r.strict,i=n===void 0?!1:n,o=r.start,a=o===void 0?!0:o,s=r.end,l=s===void 0?!0:s,u=r.encode,c=u===void 0?function(q){return q}:u,h=r.delimiter,d=h===void 0?"/#?":h,f=r.endsWith,v=f===void 0?"":f,p="[".concat(xi(v),"]|$"),m="[".concat(xi(d),"]"),w=a?"^":"",_=0,O=e;_-1:W===void 0;i||(w+="(?:".concat(m,"(?=").concat(p,"))?")),L||(w+="(?=".concat(m,"|").concat(p,")"))}return new RegExp(w,pg(r))}function yg(e,t,r){return e instanceof RegExp?zx(e,t):Array.isArray(e)?Ux(e,t,r):Gx(e,t,r)}let jr=unsafeWindow;jr.wrappedJSObject&&(jr=jr.wrappedJSObject);const Kx=typeof cloneInto=="function"?cloneInto:e=>e,Zx=typeof exportFunction=="function"?exportFunction:e=>e;function qx(e){return Kx(e,jr,{cloneFunctions:!0,wrapReflectors:!0})}function Xx(e){return Zx(e,jr)}function Qx(e,t){return t??(t=jr),function(...r){return e.call(t,...qx(r))}}const eh=[],Jx=Qx(jr.history.pushState,jr.history);jr.history.pushState=Xx(eA);function eA(e,t,r){Jx(e,t,r),gg()}addEventListener("popstate",()=>{gg()});function gg(){for(const e of eh){const t=e.matcher(location.pathname)?e.onCallbacks:e.offCallbacks;for(const r of t)r()}}function bg(e){let t=eh.find(r=>r.pattern===e);return t||(t={pattern:e,matcher:Wx(e),onCallbacks:[],offCallbacks:[]},eh.push(t),t)}function tA(e,t,r=!1){const n=bg(e),i=n.matcher(location.pathname);n.onCallbacks.push(t),i&&t()}function rA(e,t,r=!1){const n=bg(e),i=n.matcher(location.pathname);n.offCallbacks.push(t),i||t()}function nA(){return Object.fromEntries(document.cookie.split("; ").map(e=>e.split("=",2)))}function ha(e){return new Promise(t=>{setTimeout(t,e)})}function iA(e,t){const r=URL.createObjectURL(e),n=document.createElement("a");n.style.display="none",n.download=t,n.href=r,document.body.appendChild(n),n.click(),URL.revokeObjectURL(r)}function Ut(e){const t=document.createElement("div");return t.innerHTML=e,t.firstElementChild}function Gl(e,t,r=5e3,n=document){return new Promise(i=>{let o=0,a=0;o=setTimeout(()=>{clearInterval(a),i(null)},r),a=setInterval(()=>{let s=n.querySelector(t??e);s&&(t&&(s=n.querySelector(e),!s)||(i(s),clearTimeout(o),clearInterval(a)))},10)})}function oA(e,t){new MutationObserver(n=>{for(const i of n)for(const o of Array.from(i.addedNodes))if(o instanceof Element&&o.matches(e)){t(o);return}}).observe(document.body,{childList:!0,subtree:!0})}const wg="/:country/album/:slug?/:id";function Ai(e,t=!1){tA(wg,e,t)}function Yl(e,t=!1){rA(wg,e,t)}let Kl=null;function da(e,t){return Ut(` - `)}async function ha(e,t){if(!Gs&&(Gs=await zs(".navigation__scrollable-container","amp-chrome-player"),!Gs))return;let r=document.querySelector("#ame-sidebar");r||(r=Nt(` + `)}async function va(e,t){if(!Kl&&(Kl=await Gl(".navigation__scrollable-container","amp-chrome-player"),!Kl))return;let r=document.querySelector("#ame-sidebar");r||(r=Ut(`