1(() => { 2 'use strict'; 3 const config = window.RVMMembers; 4 const nativeFetch = window.fetch.bind(window); 5 window.rvmMemberFetch = async (input, init = {}) => { 6 const url = new URL(String(input), location.origin); 7 const target = Object.entries(config.targets).find(([, value]) => { 8 const known = new URL(value, location.origin); 9 return url.origin === known.origin && url.pathname === known.pathname; 10 }); 11 if (!target) return nativeFetch(input, init); 12 const gateway = new URL(config.root + target[0]); 13 gateway.search = url.search; 14 const headers = new Headers(init.headers || {}); 15 headers.set('X-WP-Nonce', config.nonce); 16 const result = await nativeFetch(gateway, {...init, credentials: 'same-origin', headers}); 17 const envelope = await result.json(); 18 if (!result.ok) throw new Error(envelope.message || 'Membership verification failed.'); 19 const responseHeaders = {'Content-Type': envelope.content_type || 'application/json'}; 20 if (envelope.retry_after) responseHeaders['Retry-After'] = envelope.retry_after; 21 return new Response(envelope.body, {status: envelope.status, headers: responseHeaders}); 22 }; 23 document.addEventListener('click', (event) => { 24 const button = event.target.closest('#getjuke-mail-btn'); 25 if (!button || config.canMail) return; 26 event.preventDefault(); 27 event.stopImmediatePropagation(); 28 const status = document.getElementById('getjuke-print-status'); 29 if (status) { 30 status.textContent = 'Sign in to email a playlist to your account.'; 31 status.className = 'getjuke-export-status is-error'; 32 } else { 33 window.alert('Sign in to email a playlist to your account.'); 34 } 35 }, true); 36 document.addEventListener('click', async (event) => { 37 const button = event.target.closest('.rvm-artist-follow'); 38 if (!button || button.disabled) return; 39 button.disabled = true; 40 const status = button.nextElementSibling; 41 try { 42 const body = new URLSearchParams({action:'rvm_m_artist_subscribe', artist_id:button.dataset.artist, nonce:button.dataset.nonce}); 43 const response = await nativeFetch(config.ajax, {method:'POST', credentials:'same-origin', body}); 44 const data = await response.json(); 45 status.textContent = data.data.message; 46 if (!data.success) throw new Error(data.data.message); 47 button.textContent = 'Following'; 48 } catch (error) { status.textContent = error.message; button.disabled = false; } 49 }); 50})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.