// ==UserScript== // @name String Theory // @namespace https://github.com/majkinetor/musicbrainz-userscripts // @version 2026.11.23.021753 // @description Unified bundle of 13 MusicBrainz userscripts (apollo_editor 2026.11.23, art_station 2026.11.23, credit_hoarder 2026.11.23, event_horizon 2026.11.23, falcon 2026.11.23, first_contact 2026.11.23, fusion 2026.11.23, group_therapy 2026.11.23, isrc_scout 2026.11.23, mammoth 2026.11.23, mission_control 2026.11.23, fuzzy_logic 2026.11.23, platform_check 2026.11.23). Built by userscripts/string_theory/build.mjs — do not hand-edit. // @author majkinetor // @icon data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjggMTI4IiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+Cjx0aXRsZT5TdHJpbmcgVGhlb3J5PC90aXRsZT4KPHBhdGggZD0iTTY0IDEwIEw2Ni40IDEwLjIgTDY4LjcgMTAuNiBMNzAuOSAxMS40IEw3My4xIDEyLjQgTDc1LjIgMTMuNyBMNzcuMSAxNS4yIEw3OC44IDE3IEw4MC40IDE4LjkgTDgxLjggMjEgTDgzLjEgMjMuMSBMODQuMSAyNS40IEw4NSAyNy42IEw4NS43IDI5LjkgTDg2LjMgMzIuMSBMODYuOCAzNC4zIEw4Ny4xIDM2LjQgTDg3LjQgMzguNCBMODcuNyA0MC4zIEw4Ny45IDQyLjEgTDg4LjIgNDMuNyBMODguNSA0NS4yIEw4OC45IDQ2LjYgTDg5LjQgNDcuOCBMOTAgNDkgTDkwLjcgNTAuMSBMOTEuNiA1MS4xIEw5Mi42IDUyLjIgTDkzLjcgNTMuMiBMOTUgNTQuMiBMOTYuNCA1NS4zIEw5Ny45IDU2LjUgTDk5LjUgNTcuNyBMMTAxLjEgNTkuMSBMMTAyLjcgNjAuNiBMMTA0LjQgNjIuMiBMMTA2IDY0IEwxMDcuNSA2NS45IEwxMDguOSA2Ny45IEwxMTAuMiA3MC4xIEwxMTEu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Y4LjkgTDI1LjMgNjcuNCBMMjMuNiA2NS44IEwyMiA2NCBMMjAuNSA2Mi4xIEwxOS4xIDYwLjEgTDE3LjggNTcuOSBMMTYuNyA1NS43IEwxNS45IDUzLjMgTDE1LjIgNTAuOSBMMTQuOSA0OC41IEwxNC44IDQ2LjEgTDE1IDQzLjcgTDE1LjQgNDEuNCBMMTYuMiAzOS4xIEwxNy4yIDM3IEwxOC41IDM1IEwyMC4xIDMzLjMgTDIxLjkgMzEuNyBMMjMuOSAzMC4zIEwyNiAyOS4yIEwyOC4zIDI4LjMgTDMwLjcgMjcuNiBMMzMuMSAyNy4yIEwzNS42IDI3IEwzOC4xIDI3LjEgTDQwLjYgMjcuMyBMNDMgMjcuNiBMNDUuMyAyOC4xIEw0Ny42IDI4LjcgTDQ5LjcgMjkuNCBMNTEuNyAzMC4yIEw1My42IDMwLjkgTDU1LjMgMzEuNiBMNTcgMzIuMyBMNTguNSAzMi45IEw2MCAzMy40IEw2MS4zIDMzLjcgTDYyLjcgMzMuOVoiIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzZjNDdlMCIgc3Ryb2tlLXdpZHRoPSIxMyIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4K // @homepageURL https://github.com/majkinetor/musicbrainz-userscripts/tree/main/userscripts/string_theory // @run-at document-start // @match https://*.musicbrainz.org/release/add* // @match https://*.musicbrainz.org/release/*/edit // @match https://*.musicbrainz.org/*/edit_annotation // @match https://*.musicbrainz.org/artist/* // @match https://*.musicbrainz.org/label/* // @match https://*.musicbrainz.org/place/* // @match https://*.musicbrainz.org/release/* // @match https://*.musicbrainz.org/release-group/* // @match https://*.musicbrainz.org/cdtoc/attach* // @match https://*.musicbrainz.org/ // @match https://*.musicbrainz.org/recording/* // @match https://*.musicbrainz.org/work/* // @match https://*.musicbrainz.org/area/* // @match https://*.musicbrainz.org/instrument/* // @match https://*.musicbrainz.org/series/* // @match https://*.musicbrainz.org/collection/* // @match https://*.musicbrainz.org/event/* // @match https://*.musicbrainz.org/user/* // @match https://*.musicbrainz.org/tag/* // @match https://*.musicbrainz.org/search* // @match https://*.musicbrainz.org/edit/* // @match https://*.musicbrainz.org/cdtoc/* // @match https://*.musicbrainz.org/work/create* // @match https://*.musicbrainz.org/work/*/edit // @match https://*.musicbrainz.org/recording/create* // @match https://*.musicbrainz.org/recording/*/edit // @match https://*.musicbrainz.org/event/create* // @match https://*.musicbrainz.org/event/*/edit // @match https://*.musicbrainz.org/series/create* // @match https://*.musicbrainz.org/series/*/edit // @match https://*.musicbrainz.org/work/*/add-alias // @match https://*.musicbrainz.org/recording/*/add-alias // @match https://*.musicbrainz.org/event/*/add-alias // @match https://*.musicbrainz.org/series/*/add-alias // @match https://*.musicbrainz.org/area/*/add-alias // @match https://*.musicbrainz.org/instrument/*/add-alias // @match https://*.musicbrainz.org/genre/*/add-alias // @match https://*.musicbrainz.org/work/*/aliases // @match https://*.musicbrainz.org/recording/*/aliases // @match https://*.musicbrainz.org/event/*/aliases // @match https://*.musicbrainz.org/series/*/aliases // @match https://*.musicbrainz.org/area/*/aliases // @match https://*.musicbrainz.org/instrument/*/aliases // @match https://*.musicbrainz.org/genre/*/aliases // @grant GM_xmlhttpRequest // @grant GM_openInTab // @grant GM_getValue // @grant GM_setValue // @grant unsafeWindow // @connect * // @match *://*.musicbrainz.org/release/* // @match *://*.musicbrainz.org/release/*/cover-art* // @match *://*.musicbrainz.org/release/*/add-cover-art* // @match *://*.musicbrainz.org/event/*/event-art* // @match *://*.musicbrainz.org/event/*/add-event-art* // @match *://vgmdb.net/album/* // @match *://*.vgmdb.net/album/* // @grant GM.xmlHttpRequest // @match https://*.musicbrainz.org/* // @match https://tidal.com/album/* // @match https://listen.tidal.com/album/* // @match https://www.metal-archives.com/albums/* // @match https://vgmdb.net/album/* // @connect qobuz.com // @connect www.qobuz.com // @connect deezer.com // @connect www.deezer.com // @connect mora.jp // @connect cf.mora.jp // @connect www.melon.com // @connect m2.melon.com // @connect tivomusicapi-staging-elb.digitalsmiths.net // @connect music.apple.com // @connect amp-api.music.apple.com // @connect www.metal-archives.com // @connect music.youtube.com // @grant GM_deleteValue // @grant GM_addValueChangeListener // @grant GM_removeValueChangeListener // @connect musicbrainz.org // @match https://*.musicbrainz.org/account/edit // @match https://*.musicbrainz.org/account/preferences // @match https://*.musicbrainz.org/account/donation // @match https://*.musicbrainz.org/account/applications // @match https://bandcamp.com/EmbeddedPlayer/* // @match https://widget.deezer.com/widget/* // @connect api.discogs.com // @connect api.deezer.com // @connect tidal.com // @connect www.wikidata.org // @connect wikipedia.org // @connect soundcloud.com // @connect open.spotify.com // @connect bandcamp.com // @connect discogs.com // @connect dzcdn.net // @connect mzstatic.com // @connect bcbits.com // @connect googleusercontent.com // @connect ggpht.com // @connect scdn.co // @connect sndcdn.com // @connect resources.tidal.com // @connect wikimedia.org // @connect 127.0.0.1 // @connect api.listenbrainz.org // @connect archive.org // @match https://harmony.pulsewidth.org.uk/* // @match https://harmony.mybrainz.dev/* // @match https://www.deezer.com/* // @match https://*.bandcamp.com/album/* // @match https://*.bandcamp.com/track/* // @match https://www.discogs.com/* // @match https://music.apple.com/* // @match https://tidal.com/* // @match https://listen.tidal.com/* // @match https://www.qobuz.com/*/album/* // @match https://www.beatport.com/* // @match https://open.spotify.com/* // @match https://music.youtube.com/* // @match https://www.youtube.com/playlist* // @match https://volumo.com/* // @match https://www.hdtracks.com/* // @match https://soundcloud.com/* // @match https://audiomack.com/* // @match https://*.7digital.com/artist/* // @match https://ototoy.jp/_/default/p/* // @match https://mora.jp/package/* // @match https://www.traxsource.com/* // @match https://www.melon.com/album/detail.htm* // @match https://archive.org/details/* // @match https://music.bugs.co.kr/album/* // @match https://www.allmusic.com/album/release/* // @match https://rateyourmusic.com/release/* // @match https://www.albumoftheyear.org/album/* // @match https://www.amazon.com/* // @match https://www.amazon.co.uk/* // @match https://www.amazon.de/* // @match https://www.amazon.fr/* // @match https://www.amazon.it/* // @match https://www.amazon.es/* // @match https://www.amazon.ca/* // @match https://www.amazon.co.jp/* // @match https://www.amazon.com.au/* // @match https://www.amazon.com.br/* // @match https://www.amazon.com.mx/* // @match https://www.amazon.in/* // @match https://www.amazon.nl/* // @match https://www.amazon.se/* // @match https://www.amazon.pl/* // @match https://www.amazon.com.be/* // @match https://music.amazon.com/* // @match https://music.amazon.co.uk/* // @match https://music.amazon.de/* // @match https://music.amazon.fr/* // @match https://music.amazon.it/* // @match https://music.amazon.es/* // @match https://music.amazon.ca/* // @match https://music.amazon.co.jp/* // @match https://music.amazon.com.au/* // @match https://music.amazon.com.br/* // @match https://music.amazon.com.mx/* // @match https://www.prestomusic.com/classical/products/* // @match https://www.prestomusic.com/jazz/products/* // @match https://streaming.prestomusic.com/* // @match https://music.amazon.in/* // @grant GM.getValue // @grant GM_listValues // @grant window.close // @connect itunes.apple.com // @connect auth.tidal.com // @connect openapi.tidal.com // @connect api.beatport.com // @connect api-partner.spotify.com // @connect spclient.wg.spotify.com // @connect volumo.com // @connect hdtracks.azurewebsites.net // @connect a-v2.sndcdn.com // @connect api-v2.soundcloud.com // @connect api.audiomack.com // @connect api.7digital.com // @connect www.traxsource.com // @connect us.7digital.com // @connect js-cdn.7digital.com // @connect www.amazon.com // @connect www.amazon.co.uk // @connect www.amazon.de // @connect www.amazon.fr // @connect www.amazon.it // @connect www.amazon.es // @connect www.amazon.ca // @connect www.amazon.co.jp // @connect www.amazon.com.au // @connect www.amazon.com.br // @connect www.amazon.com.mx // @connect www.amazon.in // @connect www.amazon.nl // @connect www.amazon.se // @connect www.amazon.pl // @connect www.amazon.com.be // @connect music.amazon.com // @connect na.mesk.skill.music.a2z.com // @connect web.archive.org // @connect beta.musicbrainz.org // @connect test.musicbrainz.org // @connect music.bugs.co.kr // @connect api.acoustid.org // @match *://*.musicbrainz.org/release/*/edit-relationships // @match *://*.musicbrainz.org/artist/* // @match *://*.musicbrainz.org/label/* // @match *://*.musicbrainz.org/place/* // @match https://*.musicbrainz.org/oauth2/oob* // @match https://www.beatport.com/release/* // @connect isrc-api.soundexchange.com // @connect isrc.soundexchange.com // @connect harmony.pulsewidth.org.uk // @connect isrchunt.com // @connect isrc.mollamusicgroup.com // @connect ajax-www.prestomusic.com // @connect www.youtube.com // @match *://*.musicbrainz.org/release-group/* // @match *://*.musicbrainz.org/recording/* // @match *://rateyourmusic.com/release/* // @match *://www.albumoftheyear.org/album/* // @match *://rateyourmusic.com/artist/* // @match *://www.albumoftheyear.org/artist/* // @grant GM_registerMenuCommand // @connect www.allmusic.com // @connect www.beatport.com // @connect query.wikidata.org // @connect vocadb.net // @connect www.last.fm // @connect search.brave.com // @connect html.duckduckgo.com // @connect duckduckgo.com // @connect www.discogs.com // @connect tools.wallstream.com // @grant GM_setClipboard // @connect api.dropbox.com // @connect api.dropboxapi.com // @connect content.dropboxapi.com // @connect www.googleapis.com // @connect oauth2.googleapis.com // ==/UserScript== // Auto-generated by userscripts/string_theory/build.mjs — do NOT edit by hand. // Bundles (verbatim, each wrapped in a URL gate and a run-at gate): apollo_editor, art_station, credit_hoarder, event_horizon, falcon, first_contact, fusion, group_therapy, isrc_scout, mammoth, mission_control, fuzzy_logic, platform_check. // The shared blocks (// ) are written once, below, and each member calls them for its own copy (#786). try { console.log('%c String Theory %c v2026.11.23.021753 ', 'background:#7c5cff;color:#fff;font-weight:bold;border-radius:3px;padding:2px 6px', 'color:#7c5cff;font-weight:bold'); console.log("String Theory bundles:\n · Apollo Editor v2026.11.23\n · Art Station v2026.11.23\n · Credit Hoarder v2026.11.23\n · Event Horizon v2026.11.23\n · Falcon v2026.11.23\n · First Contact v2026.11.23\n · Fusion v2026.11.23\n · Group Therapy v2026.11.23\n · ISRC Scout v2026.11.23\n · Mammoth v2026.11.23\n · Mission Control v2026.11.23\n · Fuzzy Logic v2026.11.23\n · Platform Check v2026.11.23"); } catch (e) {} // #977: a page whose Content Security Policy refuses inline styles (MusicBrainz's /user//report: // style-src without 'unsafe-inline') drops every ' + part('Theme', what.theme) + (what.effect ? '·' + part('Effect', what.effect === '-' ? 'None' : what.effect) : ''); if (info.innerHTML !== html) info.innerHTML = html; if (!info.isConnected) document.documentElement.appendChild(info); } // a different one when there is a choice, so a continuous idle always changes function randomPick(list, not) { if (not != null && list.length > 1) list = list.filter(function (x) { return x !== not; }); return list.length ? list[Math.floor(Math.random() * list.length)] : ''; } function randomTheme(s, not) { var v = variant(s); idleChoice.variant = v; idleChoice.theme = randomPick(Object.keys(THEMES[v]), not); } // Idle changes cross-fade: a view transition snapshots the page and fades it into the new theme. // Without the API (or with reduced motion) the change is instant. Clicks land on the snapshot // while it runs, so waking up gets a short fade. var fadeStyle = null; function fade(ms) { var reduce = window.matchMedia && matchMedia('(prefers-reduced-motion: reduce)').matches; if (!document.startViewTransition || reduce || document.hidden) { apply(); return; } if (!fadeStyle) { fadeStyle = document.createElement('style'); fadeStyle.id = 'st-fade'; } fadeStyle.textContent = '::view-transition-group(root),::view-transition-old(root),::view-transition-new(root){animation-duration:' + ms + 'ms}'; if (!fadeStyle.isConnected) (document.head || document.documentElement).appendChild(fadeStyle); try { document.startViewTransition(apply); } catch (e) { apply(); } } function beginIdle() { var s = read(), was = idleChoice; idleChoice = { theme: s.idle.theme, effect: s.idle.effect }; if (s.idle.theme === '*') randomTheme(s, was && was.theme); if (s.idle.effect === '*') { var fx = []; try { fx = JSON.parse(localStorage.getItem('mbu.ehFxPresets')) || []; } catch (e) {} idleChoice.effect = randomPick(Array.isArray(fx) ? fx : [], was && was.effect); } idle = true; fade(1500); // Continuous: each further idle period picks the Random parts again if (s.idle.cont && (s.idle.theme === '*' || s.idle.effect === '*')) idleTimer = setTimeout(beginIdle, s.idle.minutes * 60000); } function activity() { clearTimeout(idleTimer); if (idle) { idle = false; idleChoice = null; fade(300); } var s = read().idle; if (!onMb || window.top !== window || !s.on || (!s.theme && !s.effect)) return; idleTimer = setTimeout(beginIdle, s.minutes * 60000); } var tc = onMb && tcRead(); if (tc) { over = read(); over.mode = tc.v; over[tc.v] = tc.n; if (tc.eh && typeof tc.eh === 'object') over.eh = tc.eh; } if (onMb) { apply(); activity(); // a mouse move fires many times a second: the timer, whole minutes long, is set again at most once a second var lastAct = Date.now(); var moved = function () { var t = Date.now(); if (!idle && t - lastAct < 1000) return; lastAct = t; activity(); }; ['pointermove', 'pointerdown', 'keydown', 'wheel', 'touchstart', 'scroll'].forEach(function (name) { window.addEventListener(name, moved, { capture: true, passive: true }); }); window.addEventListener('focus', activity); document.addEventListener('visibilitychange', function () { if (!document.hidden) activity(); }); // last in the page, or MusicBrainz's stylesheet, loaded after it, wins every tie var last = function () { if (style) document.documentElement.appendChild(style); apply(); }; if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', last, { once: true }); else last(); if (sys && sys.addEventListener) sys.addEventListener('change', apply); setInterval(function () { var m = read().mode; if (m === 'sun' || m === 'time') apply(); }, 60000); } function set(patch) { var s = read(); Object.keys(patch).forEach(function (k) { s[k] = patch[k]; }); over = null; save(s); activity(); apply(); } // shows the settings with patch on top, saving nothing; no patch goes back to what is saved function preview(patch) { over = null; if (patch) { over = read(); Object.keys(patch).forEach(function (k) { over[k] = patch[k]; }); } apply(); } return { read: read, set: set, preview: preview, variant: function () { return variant(read()); }, isDay: isDay, isDarkAt: isDarkAt, names: function (v) { return v ? Object.keys(THEMES[v]) : Object.keys(Object.assign({}, THEMES.light, THEMES.dark)).sort(); }, chooser: tcRead, chooserPut: tcPut, // the location mode asks the browser where we are, once, and keeps it coarse setMode: function (mode, done) { var s = read(); set({ mode: mode }); if (mode !== 'sun' || s.lat != null || !navigator.geolocation) return; navigator.geolocation.getCurrentPosition(function (p) { set({ lat: Math.round(p.coords.latitude * 10) / 10, lon: Math.round(p.coords.longitude * 10) / 10 }); if (done) done(); }, function () {}, { maximumAge: 864e5, timeout: 30000 }); } }; })(); var __stDefOff = []; function __stList(k) { try { var v = GM_getValue(k, []); return Array.isArray(v) ? v : []; } catch (e) { return []; } } function __stReadOff() { var on = __stList("string_theory.on"); return __stList("string_theory.off").concat(__stDefOff.filter(function (n) { return on.indexOf(n) < 0; })); } var __stOff = __stReadOff(); var __stStarters = {}; // #851: per member folder, how String Theory's settings start it only to open its settings (function () { try { if (window.top !== window.self) return; } catch (e) { return; } if (__stPlayerOnly) return; var stMembers = [["apollo_editor","Apollo Editor","2026.11.23","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjggMTI4IiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+Cjx0aXRsZT5BcG9sbG8gRWRpdG9yPC90aXRsZT4KPG1hc2sgaWQ9ImFwLW0iIG1hc2tVbml0cz0idXNlclNwYWNlT25Vc2UiIHg9IjAiIHk9IjAiIHdpZHRoPSIxMjgiIGhlaWdodD0iMTI4Ij48Zz48ZyBmaWxsPSIjZmZmIj48cGF0aCBkPSJNNDIgNjQgQzI4IDcyIDIyIDkwIDI0IDExMCBMNDIgOTggWiIvPjxwYXRoIGQ9Ik04NiA2NCBDMTAwIDcyIDEwNiA5MCAxMDQgMTEwIEw4NiA5OCBaIi8+PC9nPjxnIGZpbGw9IiNmZmYiPjxwYXRoIGQ9Ik02NCA4IEM4NCAyNCA5MCA1MiA4OCA5MCBMNDAgOTAgQzM4IDUyIDQ0IDI0IDY0IDggWiIvPjxwYXRoIGQ9Ik00OCA5MCBMODAgOTAgTDc2IDEwMCBMNTIgMTAwIFoiLz48L2c+PGcgc3Ryb2tlPSIjMDAwIiBzdHJva2Utd2lkdGg9IjMuNSI+PHBhdGggZD0iTTM2IDkwLjUgTDkyIDkwLjUiLz48L2c+PGNpcmNsZSBjeD0iNjQiIGN5PSI1MCIgcj0iOCIgZmlsbD0iIzAwMCIvPjwvZz48L21hc2s+PGc+PHBhdGggZD0iTTUyIDEwMCBDNTQgMTEyIDYwIDExOCA2NCAxMjYgQzY4IDExOCA3NCAxMTIgNzYgMTAwIFoiIGZpbGw9IiNlYjc0M2IiIHRyYW5zZm9ybT0idHJhb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IxMyIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4K", ST_HOME = "https://github.com/majkinetor/musicbrainz-userscripts/tree/main/userscripts/string_theory"; var ST_ON_MB = /(^|[.])musicbrainz[.]org$/.test(location.hostname); // on MusicBrainz String Theory's icon is the dock (mbuDock), Event Horizon or not; the mark goes up // before any member stacks its launcher if (ST_ON_MB) try { document.documentElement.setAttribute('data-mbu-st', ST_VERSION); } catch (e) {} function mbuShared(key, value) { var k = 'mbu.' + key; try { if (arguments.length < 2) { var v = localStorage.getItem(k); return v == null ? undefined : JSON.parse(v); } if (value == null) localStorage.removeItem(k); else localStorage.setItem(k, JSON.stringify(value)); } catch (e) { /* storage blocked */ } return value; } var MBU_DOCK_ICON = ' '; // String Theory's icon.svg var mbuDockBusyT, mbuDockFadeT; // the dock's busy-off delay and its fade-out, below var mbuPathRe = {}; // data-mb-corner-paths, compiled once each function mbuDock() { var root = document.documentElement, eh = root.hasAttribute('data-mbu-dock'); var on = eh || root.hasAttribute('data-mbu-st'); var btn = document.getElementById('mbu-dock'); var els = Array.prototype.slice.call(document.querySelectorAll('[data-mb-corner="br"]')) .filter(function (el) { return el.id !== 'mbu-dock' && el.dataset.mbCornerDock !== 'no'; }); if (!document.getElementById('mbu-dock-css')) { var css = document.createElement('style'); css.id = 'mbu-dock-css'; css.textContent = '[data-mbu-docked]{z-index:2147482990!important}[data-mbu-docked=hide],[data-mbu-docked=off],:root:not([data-mbu-dock]) [data-mb-corner-dock=only]{display:none!important}' // No transform on an entry, ever: its count badge is drawn inside it, and Chrome cut seams through the // badge's border under a fractional scale (a peek's .8, a hover's 1.08). The hover grows the icon only, a // folded entry is laid out smaller in whole pixels, and a bigger icon (mbuDockItem's scale) is its size // (--mbu-di, --mbu-di-p when folded) + '.mbu-dock-item{position:fixed;z-index:2147482990;width:40px;height:40px;box-sizing:border-box;border:0;border-radius:50%;padding:3px;background:none;box-shadow:none;cursor:pointer}' + '.mbu-dock-item img{width:var(--mbu-di,34px);height:var(--mbu-di,34px);max-width:none;margin:calc((34px - var(--mbu-di,34px))/2);display:block;pointer-events:none;opacity:.85;transition:opacity .12s,transform .12s}.mbu-dock-item:hover img{opacity:1;transform:scale(1.08)}' + '.mbu-dock-item[data-mbu-docked=peek]{width:32px;height:32px;padding:2px}.mbu-dock-item[data-mbu-docked=peek] img{width:var(--mbu-di-p,28px);height:var(--mbu-di-p,28px);margin:calc((28px - var(--mbu-di-p,28px))/2)}.mbu-dock-item[data-mbu-docked=peek]:hover img{transform:scale(1.125)}' // beside the dock's button, wherever the corner's size (--mbu-cs, set by the restack) puts it // under the dock's entries (2147482989-91): the dock, when it shows, is above every floating panel; windows still cover it + '.mbu-dock-win{position:fixed;z-index:2147482985;--mbu-dw-x:calc(22px + 40px*var(--mbu-cs,1));--mbu-dw-y:6px;right:var(--mbu-dw-x);bottom:var(--mbu-dw-y);width:max-content;max-width:calc(100vw - 90px);max-height:min(75vh,calc(100vh - 20px));overflow:auto;box-sizing:border-box;border-radius:10px;box-shadow:0 6px 24px rgba(0,0,0,.35)}' + '.mbu-dock-win>*{margin:0!important}:root[data-mbu-flow=row] .mbu-dock-win{--mbu-dw-x:6px;--mbu-dw-y:calc(20px + 40px*var(--mbu-cs,1));max-height:min(75vh,calc(100vh - 80px))}:root[data-mbu-side=left] .mbu-dock-win{right:auto;left:var(--mbu-dw-x)}' + '#mbu-dock{position:fixed;z-index:2147482991;width:40px;height:40px;border-radius:50%;border:0;padding:0;cursor:pointer;background:none;box-shadow:none}' + '#mbu-dock svg{width:34px;height:34px;display:block;margin:auto;pointer-events:none;opacity:.85;transition:opacity .12s,transform .12s}' + '#mbu-dock:hover svg{transform:scale(1.08)}:is(#mbu-dock:hover,:root[data-mbu-dock-open] #mbu-dock) svg{opacity:1}' + '#mbu-dock:focus-visible{outline:2px solid #ba478f;outline-offset:2px}' + '#mbu-dock b{position:absolute;top:-4px;right:-4px;min-width:18px;height:18px;padding:0 4px;box-sizing:border-box;border:1.5px solid #e05aa5;border-radius:9px;background:#fde6f2;color:#c93d8c;font:700 11px/15px system-ui,sans-serif;text-align:center}' // no names, only a short state (a count) as a badge on the entry's top-right corner // No background, and no dark userstyle's inverting filter on it (kellnerd's inverts every button) + '.mbu-dock-item,#mbu-dock,#mbu-dock-shelf,[data-mbu-docked=show],[data-mbu-docked=peek]{filter:none!important}' // The resting fade is on the icon, never the entry: the entry's opacity would fade its badge too, and the page showed through it // a launcher's own resting fade (Fusion's .85) is overruled; a peek's fade runs through --mbu-peek-o, which an // animation can move under the !important (it can't move opacity itself) + '@property --mbu-peek-o{syntax:"";inherits:false;initial-value:1}' + '[data-mbu-docked=show],[data-mbu-docked=peek]{opacity:var(--mbu-peek-o,1)!important}' + ':is([data-mbu-docked=show],[data-mbu-docked=peek])>:not(.mbu-dock-dots,.mbu-dock-n){opacity:.85;transition:opacity .12s,transform .12s}:is(:root[data-mbu-dock-over] [data-mbu-docked=show],[data-mbu-docked=show]:hover,[data-mbu-docked=peek]:hover)>*{opacity:1}' // while the pointer is over the dock, a frosted shelf behind its icons, so they read on any page + '#mbu-dock-shelf{position:fixed;z-index:2147482989;box-sizing:border-box;background:transparent;opacity:0;visibility:hidden;transition:opacity .15s,visibility .15s}' // catches the pointer between icons, so the page behind the dock's gaps doesn't react + ':root[data-mbu-dock-frost] #mbu-dock-shelf{background:rgba(255,255,255,.6);box-shadow:0 2px 10px rgba(0,0,0,.18),inset 0 0 0 1px rgba(0,0,0,.1);-webkit-backdrop-filter:blur(12px) saturate(1.6);backdrop-filter:blur(12px) saturate(1.6)}' // String Theory's Hover: Shelf + ':root[data-mbu-dock-frost] #mbu-dock-shelf[data-dark]{background:rgba(40,42,47,.6);box-shadow:0 2px 10px rgba(0,0,0,.5),inset 0 0 0 1px rgba(255,255,255,.12)}' + ':root[data-mbu-dock-over] #mbu-dock-shelf{opacity:1;visibility:visible}' // folded, an entry with something to do peeks beside the button, smaller // (a script's own launcher still shrinks by a transform: its insides are its own; a dock entry is sized above) + '[data-mbu-docked=peek]:not(.mbu-dock-item){transform:scale(.8)}[data-mbu-docked=peek]:not(.mbu-dock-item):hover{transform:scale(.9)}[data-mbu-peek-out]{pointer-events:none}' + ':is([data-mbu-docked=show],[data-mbu-docked=peek],.mbu-dock-item:not([data-mbu-docked]))[data-mb-corner-status]::after{content:attr(data-mb-corner-status);position:absolute;top:-4px;right:-4px;min-width:18px;height:18px;padding:0 4px;box-sizing:border-box;border:1.5px solid #e05aa5;border-radius:9px;background:#fde6f2;color:#c93d8c;font:700 11px/15px system-ui,sans-serif;text-align:center;white-space:nowrap;text-shadow:none;-webkit-font-smoothing:antialiased;pointer-events:none}' + '.mbu-dock-item[data-mbu-docked=peek][data-mb-corner-status]::after{top:-3px;right:-3px;min-width:16px;height:16px;padding:0 3px;border-radius:8px;font:700 10px/13px system-ui,sans-serif}' // a folded entry's, smaller in whole pixels + ':is([data-mbu-docked=show],[data-mbu-docked=peek],.mbu-dock-item:not([data-mbu-docked])):hover::after{opacity:1}' + ':is([data-mbu-docked=show],[data-mbu-docked=peek],.mbu-dock-item:not([data-mbu-docked]))[data-mb-corner-status^="✓"]::after{content:"";top:0;right:0;min-width:0;width:10px;height:10px;padding:0;border:2px solid #fff;border-radius:50%;background:#4cbf7a}' // all done: a quiet dot, so a count beside it stands out + '.mbu-dock-item[data-mbu-docked=peek][data-mb-corner-status^="✓"]::after{width:8px;height:8px}' + ':is([data-mbu-docked=show],[data-mbu-docked=peek],.mbu-dock-item:not([data-mbu-docked]))[data-mb-corner-status^="0,"]:not([data-mb-corner-status*="/"])::after{border:1.5px dashed #999;background:#f0f0f0;color:#888}' // "0,3": nothing to do, only held back + ':is([data-mbu-docked=show],[data-mbu-docked=peek],.mbu-dock-item:not([data-mbu-docked]))[data-mbu-busy]::after{background:#f3eff7;border-color:#d6cde2;color:#9a8fae;letter-spacing:1px;animation:mbu-dock-fade 1.2s ease-in-out infinite}' + '@keyframes mbu-dock-fade{50%{opacity:.25}}' // nothing counted yet: three small dots lighting in turn, no badge + ':is([data-mbu-docked=show],[data-mbu-docked=peek],.mbu-dock-item:not([data-mbu-docked]))[data-mbu-busy][data-mb-corner-status="···"]::after{content:none}' + '.mbu-dock-dots{display:none;position:absolute;top:0;right:-6px;gap:3px;pointer-events:none}:is([data-mbu-docked=show],[data-mbu-docked=peek],.mbu-dock-item:not([data-mbu-docked]))[data-mbu-busy][data-mb-corner-status="···"] .mbu-dock-dots{display:flex}' + '#mbu-dock .mbu-dock-run{visibility:hidden;opacity:0;stroke-dasharray:40 60;animation:mbu-dock-run 6s linear infinite paused;transition:opacity .8s,visibility 0s .8s}#mbu-dock[data-mbu-busy] .mbu-dock-run{visibility:visible;opacity:1;transition:opacity .8s}#mbu-dock:is([data-mbu-busy],[data-mbu-busy-out]) .mbu-dock-run{animation-play-state:running}@keyframes mbu-dock-run{to{stroke-dashoffset:-100}}' // while a member works, a faint long dash traces the string slowly, fading in and out; idle it pauses (after the fade-out, data-mbu-busy-out), never display:none, so it resumes where it stopped instead of restarting + '.mbu-dock-dots i{width:5px;height:5px;border-radius:50%;background:#e05aa5;animation:mbu-dock-dot 1.2s ease-in-out infinite}.mbu-dock-dots i:nth-child(2){animation-delay:.2s}.mbu-dock-dots i:nth-child(3){animation-delay:.4s}' + '@keyframes mbu-dock-dot{0%,80%,100%{opacity:.25}40%{opacity:1}}' + '@media (prefers-reduced-motion:reduce){[data-mbu-busy]::after,.mbu-dock-dots i{animation:none!important}#mbu-dock .mbu-dock-run{animation-duration:12s!important}}'; root.appendChild(css); } if (!on) { els.forEach(function (el) { el.removeAttribute('data-mbu-docked'); }); if (btn) btn.remove(); return; } if (!btn) { btn = document.createElement('button'); btn.type = 'button'; btn.id = 'mbu-dock'; btn.setAttribute('aria-label', 'String Theory'); btn.dataset.mbCorner = 'br'; btn.dataset.mbCornerOrder = '-1'; // nearest the corner btn.onclick = function () { // unrolled by hovering: the click keeps it open var open = root.hasAttribute('data-mbu-dock-hover') || !root.hasAttribute('data-mbu-dock-open'); root.removeAttribute('data-mbu-dock-hover'); root.toggleAttribute('data-mbu-dock-open', open); mbuShared('dockOpen', open || null); // remembered for the next page mbRestackCorner('br'); }; // with String Theory, a right-click opens its settings (#851) btn.addEventListener('contextmenu', function (e) { if (!root.hasAttribute('data-mbu-st')) return; e.preventDefault(); document.dispatchEvent(new CustomEvent('mbu-st-settings')); }); // hovering the folded button unrolls the dock until the pointer leaves it, not remembered var leaveT = 0, boxC = null, boxT = 0; var dockBox = function () { var boxes = Array.prototype.slice.call(document.querySelectorAll('#mbu-dock,[data-mbu-docked=show],[data-mbu-docked=peek]')) .map(function (el) { return el.getBoundingClientRect(); }).filter(function (r) { return r.width && r.height; }); boxT = Date.now(); boxC = !boxes.length ? null : { left: Math.min.apply(null, boxes.map(function (r) { return r.left; })), right: Math.max.apply(null, boxes.map(function (r) { return r.right; })), top: Math.min.apply(null, boxes.map(function (r) { return r.top; })), bottom: Math.max.apply(null, boxes.map(function (r) { return r.bottom; })) }; return boxC; }; var inBox = function (e, b, pad) { return !!b && e.clientX >= b.left - pad && e.clientX <= b.right + pad && e.clientY >= b.top - pad && e.clientY <= b.bottom + pad; }; var inDock = function (e) { if (e.target && e.target.closest && e.target.closest('#mbu-dock,[data-mbu-docked=show],.mbu-dock-win,#mbu-tip')) return true; return inBox(e, dockBox(), 0); }; // the shelf: shown while the pointer is over the dock, dark on a dark page (a dark userstyle) var shelf = document.createElement('div'); shelf.id = 'mbu-dock-shelf'; (document.body || root).appendChild(shelf); var pageDark = function () { // the dock block can ship without mbuThemeOf, so read the luminance here var lum = function (bg) { var m = /rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/.exec(bg || ''); if (!m || (m[4] !== undefined && +m[4] < 0.5)) return null; return (0.2126 * m[1] + 0.7152 * m[2] + 0.0722 * m[3]) / 255; }; var l = lum(document.body && getComputedStyle(document.body).backgroundColor); if (l === null) l = lum(getComputedStyle(root).backgroundColor); return l !== null && l < 0.5; }; var shelfOver = function (e) { // far from the dock, a box read a moment ago settles it: no page-wide query and layout on every move (#1095) if (!root.hasAttribute('data-mbu-dock-over') && Date.now() - boxT < 300 && !inBox(e, boxC, 80)) return; var b = dockBox(), over = inBox(e, b, 6); if (over) { if (document.body && shelf.parentNode !== document.body) document.body.appendChild(shelf); var pad = 4, w = b.right - b.left + 2 * pad, h = b.bottom - b.top + 2 * pad; shelf.style.left = (b.left - pad) + 'px'; shelf.style.top = (b.top - pad) + 'px'; shelf.style.width = w + 'px'; shelf.style.height = h + 'px'; shelf.style.borderRadius = (Math.min(w, h) / 2) + 'px'; if (!root.hasAttribute('data-mbu-dock-over')) shelf.toggleAttribute('data-dark', pageDark()); // The shelf shares the body's stacking layer with its launchers, while launchers on // remain above it. Only launchers inside another stacking layer need a cutout. var stacks = function (cs) { return (cs.zIndex !== 'auto' && cs.position !== 'static') || cs.isolation === 'isolate' || +cs.opacity < 1 || cs.transform !== 'none' || cs.filter !== 'none' || cs.mixBlendMode !== 'normal' || /paint|layout|strict|content/.test(cs.contain || ''); }; var rr = function (x, y, rw, rh, r) { r = Math.max(0, Math.min(r, rw / 2, rh / 2)); var a = function (dx, dy) { return 'a' + r + ' ' + r + ' 0 0 1 ' + dx + ' ' + dy; }; return 'M' + (x + r) + ' ' + y + 'h' + (rw - 2 * r) + a(r, r) + 'v' + (rh - 2 * r) + a(-r, r) + 'h' + (2 * r - rw) + a(-r, -r) + 'v' + (2 * r - rh) + a(r, -r) + 'z'; }; var ox = b.left - pad, oy = b.top - pad, d = rr(0, 0, w, h, Math.min(w, h) / 2); Array.prototype.forEach.call(document.querySelectorAll('[data-mbu-docked=show],[data-mbu-docked=peek]'), function (el) { var under = false; for (var p = el.parentElement; p && p !== document.body && p !== root; p = p.parentElement) if (stacks(getComputedStyle(p))) { under = true; break; } if (!under) return; var r = el.getBoundingClientRect(); if (r.width && r.height) d += rr(r.left - ox, r.top - oy, r.width, r.height, parseFloat(getComputedStyle(el).borderTopLeftRadius) || 0); }); shelf.style.clipPath = 'path(evenodd, "' + d + '")'; } root.toggleAttribute('data-mbu-dock-over', over); }; // a mouse move fires many times a frame and each measure lays the page out: one measure a frame, the last move's var shelfE = null, shelfF = 0; document.addEventListener('mousemove', function (e) { shelfE = e; if (shelfF) return; shelfF = requestAnimationFrame(function () { shelfF = 0; var m = shelfE; shelfE = null; if (m) shelfOver(m); }); }, true); root.addEventListener('mouseleave', function () { root.removeAttribute('data-mbu-dock-over'); }); btn.addEventListener('mouseenter', function () { clearTimeout(leaveT); if (root.hasAttribute('data-mbu-dock-open')) return; root.setAttribute('data-mbu-dock-hover', ''); root.setAttribute('data-mbu-dock-open', ''); mbRestackCorner('br'); }); document.addEventListener('mousemove', function (e) { if (!root.hasAttribute('data-mbu-dock-hover')) return; clearTimeout(leaveT); if (inDock(e)) return; leaveT = setTimeout(function () { if (!root.hasAttribute('data-mbu-dock-hover')) return; root.removeAttribute('data-mbu-dock-hover'); root.removeAttribute('data-mbu-dock-open'); mbRestackCorner('br'); }, 400); }, true); root.appendChild(btn); // outside the body, which Event Horizon swaps root.toggleAttribute('data-mbu-dock-open', !!mbuShared('dockOpen')); if (mbuShared('cornerOffset') !== undefined) mbuShared('cornerOffset', null); // dragging the launchers is gone (#851) } var open = root.hasAttribute('data-mbu-dock-open'), n = 0, busy = false; var rootAt = function (k, v) { if (v === null) root.removeAttribute(k); else if (root.getAttribute(k) !== v) root.setAttribute(k, v); }; rootAt('data-mbu-flow', mbuShared('cornerFlow') === 'row' ? 'row' : null); rootAt('data-mbu-side', mbuShared('cornerSide') === 'left' ? 'left' : null); root.toggleAttribute('data-mbu-dock-frost', mbuShared('dockHover') === 'shelf'); mbuDockCount(root); // Each launcher is measured as its script left it, so a hidden one's own hide comes off first. All of // them are read in one pass and written in the next: one off and one read per launcher in turn made // the browser restyle the page once per launcher, on every restack (#1095). Shown and peeking ones // keep their attribute, which only hide and off turn into display:none, and nothing is written // unchanged, since a write restyles too and wakes every observer of the page. var live = [], set = function (el, v) { if (el.getAttribute('data-mbu-docked') !== v) el.setAttribute('data-mbu-docked', v); }; els.forEach(function (el) { var p = el.dataset.mbCornerPaths; if ((eh && el.dataset.mbCornerDock === 'hide') || (p && !(mbuPathRe[p] || (mbuPathRe[p] = new RegExp(p))).test(location.pathname))) { set(el, 'off'); return; } live.push({ el: el, was: el.getAttribute('data-mbu-docked') }); }); live.forEach(function (x) { if (x.was === 'hide' || x.was === 'off') x.el.removeAttribute('data-mbu-docked'); }); live.forEach(function (x) { x.shown = getComputedStyle(x.el).display !== 'none'; }); live.forEach(function (x) { var el = x.el, was = x.was, shown = x.shown; if (shown) { n++; if (el.hasAttribute('data-mbu-busy')) busy = true; } var now = !shown ? 'hide' : open ? 'show' : /^[+]?[1-9]/.test(el.dataset.mbCornerStatus || '') || el.hasAttribute('data-mbu-actionable') ? 'peek' : 'hide'; var out = el.hasAttribute('data-mbu-peek-out'); // A peek that ends slides back into the dock button, so it stays drawn until it is there // (mbRestackCorner runs the slide, which knows the distance). This runs on every restack, // hence the attributes: a CSS animation would replay, and another script's copy can't see a property. if (now === 'hide' && shown && (was === 'peek' || out) && el.animate && !mbuStill()) { set(el, 'peek'); if (!out) el.setAttribute('data-mbu-peek-out', ''); return; } if (out) { el.removeAttribute('data-mbu-peek-out'); mbuPeekStop(el); } set(el, now); if (now === 'peek' && (was !== 'peek' || out)) el.setAttribute('data-mbu-peek-in', ''); }); mbuDockKnow(els); // Busy ends a moment late: members hand work on with short gaps, and each would blink the dash out. clearTimeout(mbuDockBusyT); if (busy) { clearTimeout(mbuDockFadeT); btn.removeAttribute('data-mbu-busy-out'); if (!btn.hasAttribute('data-mbu-busy')) btn.setAttribute('data-mbu-busy', ''); } else if (btn.hasAttribute('data-mbu-busy')) mbuDockBusyT = setTimeout(function () { btn.removeAttribute('data-mbu-busy'); btn.setAttribute('data-mbu-busy-out', ''); // the dash keeps moving while it fades out mbuDockFadeT = setTimeout(function () { btn.removeAttribute('data-mbu-busy-out'); }, 800); }, 600); // The icon is written once and only the count changes: a rewrite restarts the running dash. Read from // the DOM, not a property, which scripts in other sandboxes can't see. if (!btn.querySelector('svg .mbu-dock-run')) btn.innerHTML = MBU_DOCK_ICON; var cnt = btn.querySelector(':scope>b'); if (!n) { if (cnt) cnt.remove(); } else if (!cnt) btn.insertAdjacentHTML('beforeend', '' + n + ''); else if (cnt.textContent !== String(n)) cnt.textContent = n; } // String Theory's Counter: dockCount (seg | bare, null the pill) draws a count ("3", "0,8", "2,4/44") // as coloured cells or bare digits, pink to do, grey held back, violet after the slash, a zero // left out; dockCountPos (side, null on the icon) moves it beside the icon, away from the dock's // edge: left of a right column, right of a left one, above a row. Cells are a child span, kept in // step with data-mb-corner-status by one observer for every script's copy. Its CSS is its own // sheet, so a copy of the block older than this one that injected the dock's CSS first still // gets it. function mbuDockCount(root) { var style = mbuShared('dockCount'); style = style === 'seg' || style === 'bare' ? style : null; if (!style) root.removeAttribute('data-mbu-count'); else if (root.getAttribute('data-mbu-count') !== style) root.setAttribute('data-mbu-count', style); root.toggleAttribute('data-mbu-count-side', mbuShared('dockCountPos') === 'side'); if (!document.getElementById('mbu-dock-count-css')) { var S = ':is([data-mbu-docked=show],[data-mbu-docked=peek],.mbu-dock-item:not([data-mbu-docked]))'; var col = ':root[data-mbu-count-side]:not([data-mbu-flow=row])', row = ':root[data-mbu-count-side][data-mbu-flow=row]'; var at = function (sel) { return [S + '[data-mb-corner-status]:not([data-mb-corner-status^="✓"])::after', S + '>.mbu-dock-n', '#mbu-dock>b'].map(function (x) { return sel + ' ' + x; }).join(','); }; var css = document.createElement('style'); css.id = 'mbu-dock-count-css'; css.textContent = '.mbu-dock-n{display:none}.mbu-dock-n s{text-decoration:none}' + ':root[data-mbu-count] ' + S + '[data-mbu-count-cells]::after{content:none}' + ':root[data-mbu-count] ' + S + '[data-mbu-count-cells]>.mbu-dock-n{display:flex;position:absolute;top:-4px;right:-4px;font:700 11px/1 system-ui,sans-serif;white-space:nowrap;font-variant-numeric:tabular-nums;text-shadow:none;-webkit-font-smoothing:antialiased;pointer-events:none;opacity:1}' + ':root[data-mbu-count] ' + S + '[data-mbu-busy]>.mbu-dock-n,:root[data-mbu-count] #mbu-dock[data-mbu-busy]>b{animation:mbu-dock-fade 1.2s ease-in-out infinite}' // Segmented: one pill of solid cells, ringed in the page's colour + ':root[data-mbu-count=seg] .mbu-dock-n{height:18px;border-radius:9px;overflow:hidden;box-shadow:0 0 0 1.5px var(--mbu-count-halo,#fff)}' + ':root[data-mbu-count=seg] .mbu-dock-n s{min-width:18px;padding:0 5px;box-sizing:border-box;display:grid;place-items:center}' + ':root[data-mbu-count=seg] .mbu-dock-n s+s{box-shadow:inset 1px 0 0 rgba(255,255,255,.55)}' + ':root[data-mbu-count=seg] .mbu-dock-n-t{background:#e05aa5;color:#fff}:root[data-mbu-count=seg] .mbu-dock-n-h{background:#e6e3ea;color:#6d6777}:root[data-mbu-count=seg] .mbu-dock-n-a{background:#6f42c1;color:#fff}' + ':root[data-mbu-count=seg] #mbu-dock>b{border:0;padding:0 5px;background:#e05aa5;color:#fff;line-height:18px;box-shadow:0 0 0 1.5px var(--mbu-count-halo,#fff)}' // Bare: digits haloed in the page's colour, to do large + ':root[data-mbu-count=bare] .mbu-dock-n{top:-7px;right:-8px;align-items:baseline;gap:0}' + ':root[data-mbu-count=bare] :is(.mbu-dock-n,#mbu-dock>b){font-size:14px;paint-order:stroke;-webkit-text-stroke:4px var(--mbu-count-halo,#fff)}' + ':root[data-mbu-count=bare] .mbu-dock-n-t{color:#e05aa5}:root[data-mbu-count=bare] .mbu-dock-n-h{color:#8a8494}:root[data-mbu-count=bare] .mbu-dock-n-a{color:#6f42c1}' + ':root[data-mbu-count=bare][data-mbu-count-dark] .mbu-dock-n-h{color:#9a94a3}:root[data-mbu-count=bare][data-mbu-count-dark] .mbu-dock-n-a{color:#9d7ae0}' + ':root[data-mbu-count=bare] #mbu-dock>b{top:-7px;right:-6px;min-width:0;height:auto;padding:0;border:0;background:none;color:#e05aa5;font-weight:700;line-height:1}' // Beside: centred on the icon's side away from the edge, or above it in a row + at(col + ':not([data-mbu-side=left])') + '{top:50%;right:calc(100% + 3px);left:auto;bottom:auto;transform:translateY(-50%)}' + at(col + '[data-mbu-side=left]') + '{top:50%;left:calc(100% + 3px);right:auto;bottom:auto;transform:translateY(-50%)}' + at(row) + '{top:auto;bottom:calc(100% + 3px);right:50%;left:auto;transform:translateX(50%)}'; root.appendChild(css); } if (style) mbuDockHalo(root); Array.prototype.forEach.call(document.querySelectorAll('[data-mb-corner-status],[data-mbu-count-cells]'), mbuDockCells); if (!root.hasAttribute('data-mbu-count-obs') && window.MutationObserver) { root.setAttribute('data-mbu-count-obs', ''); new MutationObserver(function (ms) { ms.forEach(function (r) { mbuDockCells(r.target); }); }) .observe(root, { subtree: true, attributes: true, attributeFilter: ['data-mb-corner-status'] }); } } // The count's halo: the page's own background, a dark userstyle's included. Read again by // mbuTheme whenever the page may have changed theme, so switching themes doesn't leave the // old background's halo around the digits; written only when it changes, since the root's // style attribute is what wakes mbuTheme. function mbuDockHalo(root) { var bg = function (el) { var c = el && getComputedStyle(el).backgroundColor, m = /rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/.exec(c || ''); return m && !(m[4] !== undefined && +m[4] < 0.5) ? m : null; }; var m = bg(document.body) || bg(root); var halo = m ? 'rgb(' + m[1] + ', ' + m[2] + ', ' + m[3] + ')' : '#fff'; if (root.style.getPropertyValue('--mbu-count-halo') !== halo) root.style.setProperty('--mbu-count-halo', halo); var dark = !!m && (0.2126 * m[1] + 0.7152 * m[2] + 0.0722 * m[3]) / 255 < 0.5; if (root.hasAttribute('data-mbu-count-dark') !== dark) root.toggleAttribute('data-mbu-count-dark', dark); } function mbuDockCells(el) { var m = document.documentElement.hasAttribute('data-mbu-count') && /^(\d+)(?:,(\d+))?(?:\/(\d+))?$/.exec(el.getAttribute('data-mb-corner-status') || ''); var html = '', span = el.querySelector(':scope>.mbu-dock-n'); if (m && document.documentElement.getAttribute('data-mbu-count') === 'bare') { // Bare lists the status as the pill does, zeros and separators included, each part in its colour [['t', '', m[1]], ['h', ',', m[2]], ['a', '/', m[3]]].forEach(function (c) { if (c[2] != null) html += '' + c[1] + c[2] + ''; }); } else if (m) { [['t', m[1]], ['h', m[2]], ['a', m[3]]].forEach(function (c) { if (+c[1]) html += '' + +c[1] + ''; }); if (!html) html = '0'; } if (!html) { if (span) span.remove(); el.removeAttribute('data-mbu-count-cells'); return; } if (!span) { span = document.createElement('span'); span.className = 'mbu-dock-n'; el.appendChild(span); } if (span.innerHTML !== html) span.innerHTML = html; if (!el.hasAttribute('data-mbu-count-cells')) el.setAttribute('data-mbu-count-cells', ''); } // Records each named bottom-right launcher's icon in dockKnown, for String Theory's settings to list // the ones not on this page too; written only when something changed. function mbuDockKnow(els) { var known = mbuShared('dockKnown') || {}, changed = false, seen = {}; els.forEach(function (el) { var name = el.dataset.mbCornerLabel, ic = name && !seen[name] && el.querySelector('img,svg'); if (!ic) return; seen[name] = true; // one icon a name: Art Station has two launchers var icon = ic.tagName.toLowerCase() === 'img' ? '' : ic.outerHTML; if (icon.length > 40000 || known[name] === icon) return; known[name] = icon; changed = true; }); if (changed) mbuShared('dockKnown', known); } // A launcher's place in the bottom-right corner: the dock's button first, then dockOrder's names, then // the rest by data-mb-corner-order function mbuCornerRank(el, order) { if (el.id === 'mbu-dock') return -1e6; var i = order ? order.indexOf(el.dataset.mbCornerLabel) : -1; return i >= 0 ? i - 1e5 : Number(el.dataset.mbCornerOrder) || 0; } // one restack of the dock's corner once the code running now is done, for any number of asks meanwhile var mbuRestackQueued = false; function mbuRestackSoon() { if (mbuRestackQueued) return; mbuRestackQueued = true; var go = function () { mbuRestackQueued = false; mbRestackCorner('br'); }; if (typeof queueMicrotask === 'function') queueMicrotask(go); else Promise.resolve().then(go); } // A script's entry that lives in the dock only (#847): for a script whose own controls sit in // MusicBrainz's page, which Event Horizon replaces. o: id, label, icon (an image URL), order, // paths (as data-mb-corner-paths), click. Outside the dock it is never shown, unless the script clears its // data-mb-corner-dock (the Interface setting's Dock icon, #851): then it is a launcher of its own. Returns the button, // with .status(text) to show a short state (a count) beside it. o.busyIcon: an animated image shown in place of // the icon while busy with nothing counted yet, instead of the "···" dots. o.busySpin: seconds a turn, for a busy icon // that turns round its centre (a radar sweep): the dock turns the image itself, so when the work ends it eases to rest // upright before the icon comes back, where an SVG's own animation can only snap function mbuDockItem(o) { var b = document.getElementById(o.id); if (!b) { b = document.createElement('button'); b.type = 'button'; b.id = o.id; b.className = 'mbu-dock-item'; b.dataset.mbCorner = 'br'; b.dataset.mbCornerOrder = String(o.order || 60); b.dataset.mbCornerDock = 'only'; if (o.paths) b.dataset.mbCornerPaths = o.paths; var img = document.createElement('img'); img.src = o.icon; img.alt = ''; b.appendChild(img); var dots = document.createElement('span'); dots.className = 'mbu-dock-dots'; dots.innerHTML = ''; b.appendChild(dots); // while nothing is counted yet b.onclick = o.click; document.documentElement.appendChild(b); // outside the body, which Event Horizon swaps } if (b.dataset.mbCornerLabel !== o.label) b.dataset.mbCornerLabel = o.label; b.mbuIcon = o.icon; b.mbuBusyIcon = o.busyIcon || ''; b.mbuSpin = o.busySpin || 0; // .status(t): the count beside it; .busy(on): while it works, a faint "···" where the count goes, // or the count so far, fading; .card(fn): a hover card, fn() → its HTML (mbuTipCard) // A member sets its count from inside another script's render (Fuzzy Logic's in Event Horizon's), mostly to the // count already there. Only a change restacks, and after that render is done: a restack reads every launcher's // style, which in the middle of a render costs the whole page's restyle there and then (157ms, #1095). var drawn = null; var show = function () { var busy = b.hasAttribute('data-mbu-busy'), t = b.mbuSt || (busy && !b.mbuBusyIcon ? '···' : ''); var im = b.querySelector('img'), src = busy && !b.mbuSt && b.mbuBusyIcon || b.mbuIcon; if (im && src) spin(im, src); var key = t + '|' + busy; if (key === drawn) return; drawn = key; if (t) { if (b.dataset.mbCornerStatus !== t) b.dataset.mbCornerStatus = t; } else if (b.hasAttribute('data-mb-corner-status')) delete b.dataset.mbCornerStatus; var r = document.documentElement; if (r.hasAttribute('data-mbu-dock') && b.isConnected) mbuRestackSoon(); }; // update the dock's loading state and any peek // The busy icon turns by its rotate (never transform, which the hover's scale has), and on its way out it finishes // the turn decelerating evenly from full speed, a whole extra turn when it is nearly up, so it never stops short var spin = function (im, src) { var on = src === b.mbuBusyIcon, deg = function () { return (parseFloat(getComputedStyle(im).rotate) || 0) % 360; }; if (!b.mbuSpin || !im.animate) { if (im.getAttribute('src') !== src) im.src = src; return; } if (on) { if (b.mbuSpinA) return; var a = deg(); if (b.mbuSettleA) { b.mbuSettleA.cancel(); b.mbuSettleA = null; } // back at work mid-settle: on from there if (im.getAttribute('src') !== src) im.src = src; b.mbuSpinA = im.animate([{ rotate: a + 'deg' }, { rotate: a + 360 + 'deg' }], { duration: b.mbuSpin * 1000, iterations: Infinity }); return; } if (b.mbuSettleA) return; if (!b.mbuSpinA) { if (im.getAttribute('src') !== src) im.src = src; return; } var from = deg(), left = 360 - from; if (left < 90) left += 360; b.mbuSpinA.cancel(); b.mbuSpinA = null; // even deceleration from full speed covers the rest in twice the time it would take at that speed b.mbuSettleA = im.animate([{ rotate: from + 'deg' }, { rotate: from + left + 'deg' }], { duration: 2 * left / 360 * b.mbuSpin * 1000, easing: 'cubic-bezier(.333,.667,.667,1)' }); b.mbuSettleA.onfinish = function () { b.mbuSettleA = null; show(); }; }; b.status = function (t) { b.mbuSt = t || ''; show(); }; b.busy = function (on) { if (!on !== !b.hasAttribute('data-mbu-busy')) { if (on) b.dataset.mbuBusy = ''; else delete b.dataset.mbuBusy; } show(); }; b.card = function (fn) { if (typeof mbuTip === 'function') mbuTip(b, fn || null, { card: true }); }; // a bigger icon gets its size, even whole pixels, never a transform (the dock's CSS has why), folded too if (o.scale) { b.style.setProperty('--mbu-di', Math.round(17 * o.scale) * 2 + 'px'); b.style.setProperty('--mbu-di-p', Math.round(14 * o.scale) * 2 + 'px'); } b.status(''); mbRestackCorner('br'); return b; } // The folded dock's peeks move out of its button and back into it: fast at first, slowing to a stop // at the end. Reduced motion keeps only a fade in. function mbuStill() { return !!(window.matchMedia && matchMedia('(prefers-reduced-motion: reduce)').matches); } function mbuPeekStop(el) { if (el.getAnimations) el.getAnimations().forEach(function (a) { if (/^mbu-peek/.test(a.id)) a.cancel(); }); } function mbuPeekMove(el, dx, dy) { var away = dx + 'px ' + dy + 'px', ease = 'cubic-bezier(.16,1,.3,1)'; if (el.hasAttribute('data-mbu-peek-in')) { el.removeAttribute('data-mbu-peek-in'); if (!el.animate) return; mbuPeekStop(el); var a = mbuStill() ? el.animate([{ '--mbu-peek-o': 0 }, { '--mbu-peek-o': 1 }], { duration: 250, easing: 'ease-out' }) : el.animate([{ translate: away, '--mbu-peek-o': 0 }, { translate: '0px 0px', '--mbu-peek-o': 1 }], { duration: 450, easing: ease }); a.id = 'mbu-peek-in'; } if (el.hasAttribute('data-mbu-peek-out') && el.getAnimations && !el.getAnimations().some(function (a) { return a.id === 'mbu-peek-out'; })) { mbuPeekStop(el); var b = el.animate([{ translate: '0px 0px', '--mbu-peek-o': 1 }, { translate: away, '--mbu-peek-o': 0 }], { duration: 350, easing: ease, fill: 'forwards' }); b.id = 'mbu-peek-out'; b.onfinish = function () { if (!el.hasAttribute('data-mbu-peek-out')) return; el.removeAttribute('data-mbu-peek-out'); el.setAttribute('data-mbu-docked', 'hide'); b.cancel(); mbRestackCorner('br'); // the peeks after it close up }; } } function mbRestackCorner(corner) { var html = document.documentElement; var q = html.getAttribute('data-mbu-restack'); if (q !== null) { if (q.indexOf(corner) < 0) html.setAttribute('data-mbu-restack', q + ' ' + corner); return; } // another copy runs it html.setAttribute('data-mbu-restack', corner); requestAnimationFrame(function () { var all = (html.getAttribute('data-mbu-restack') || '').split(' '); html.removeAttribute('data-mbu-restack'); all.forEach(function (c) { if (c) mbRestackCornerNow(c); }); }); } function mbRestackCornerNow(corner) { if (!document.getElementById('mbu-quiet-css')) { var quiet = document.createElement('style'); quiet.id = 'mbu-quiet-css'; quiet.textContent = ':root[data-mbu-quiet] :is([data-mb-corner],#mbu-dock-shelf){visibility:hidden!important;pointer-events:none!important}'; document.documentElement.appendChild(quiet); } if (corner === 'br') mbuDock(); var bottom = corner[0] === 'b', right = (corner[1] === 'r') !== (mbuShared('cornerSide') === 'left'); var row = mbuShared('cornerFlow') === 'row'; var vv = window.visualViewport, gapX = 0, gapY = 0, html = document.documentElement; var size = Math.min(1.6, Math.max(0.6, Number(mbuShared('cornerSize')) || 1)), scaled = size !== 1; // All reads come first and all writes after them. A write between two reads makes the browser lay the // page out again, once per launcher, and a write of the value already there still costs a restyle (#1095). var put = function (el, k, v) { if (el.style[k] !== v) el.style[k] = v; }; var px = function (x) { return Math.round(x * 100) / 100 + 'px'; }; if (corner === 'br' && html.style.getPropertyValue('--mbu-cs') !== String(size)) html.style.setProperty('--mbu-cs', String(size)); var peek = function (el) { return el.getAttribute('data-mbu-docked') === 'peek'; }; // what a fixed element is placed against, measured: clientWidth leaves out a scrollbar but is the screen's width on a phone, where the page is wider (360 of 780), and innerWidth is the reverse var probe = null; if (vv) { probe = document.createElement('div'); probe.style.cssText = 'position:fixed;left:0;right:0;height:0;visibility:hidden;pointer-events:none'; html.appendChild(probe); } var edge = html.hasAttribute('data-mbu-dock') ? 6 : 14; // docked (Event Horizon), nearer the edge: the page keeps a column clear for them var peeks = [], order = corner === 'br' && mbuShared('dockOrder'); order = Array.isArray(order) ? order : null; var byRank = function (a, b) { return mbuCornerRank(a, order) - mbuCornerRank(b, order); }; var els = Array.prototype.slice.call(document.querySelectorAll('[data-mb-corner="' + corner + '"]')) // offsetParent is always null for position:fixed, so it can't tell visibility here .filter(function (el) { return !el.hidden && getComputedStyle(el).display !== 'none'; }) .filter(function (el) { if (el.getAttribute('data-mbu-docked') !== 'peek') return true; peeks.push(el); return false; }) .sort(byRank); // every size in one layout; offsetWidth and offsetHeight leave scale and position out, so they hold through the writes below var dim = new Map(); els.concat(peeks).forEach(function (el) { dim.set(el, { w: el.offsetWidth, h: el.offsetHeight }); }); var fixedW = probe ? probe.offsetWidth : 0; if (probe) probe.remove(); // a launcher, not a panel: only those scale (First Contact's open card isn't one) var small = function (el) { var d = dim.get(el); return d.h <= 64 && d.w <= 240; }; var grown = function (el) { return scaled && small(el); }; var origin = (right ? 'right ' : 'left ') + (bottom ? 'bottom' : 'top'); // the order the browser reads it back in var fit = function (el) { var on = grown(el); if (on) { put(el, 'scale', String(size)); if (!el.hasAttribute('data-mb-corner-scaled')) el.setAttribute('data-mb-corner-scaled', ''); } else if (el.hasAttribute('data-mb-corner-scaled')) { el.style.scale = ''; el.removeAttribute('data-mb-corner-scaled'); } // a launcher's peek scale(.8) shrinks it toward the corner too, so the stack below can centre what is drawn put(el, 'transformOrigin', on || peek(el) ? origin : ''); }; if (vv) { gapX = Math.max(0, right ? fixedW - vv.offsetLeft - vv.width : vv.offsetLeft); gapY = Math.max(0, bottom ? window.innerHeight - vv.offsetTop - vv.height : vv.offsetTop); if (!html.hasAttribute('data-mb-corner-vv')) { // one listener for every script's copy html.setAttribute('data-mb-corner-vv', ''); var queued = false; var again = function () { if (queued) return; queued = true; requestAnimationFrame(function () { queued = false; ['br', 'bl', 'tr', 'tl'].forEach(function (c) { if (document.querySelector('[data-mb-corner="' + c + '"]')) mbRestackCornerNow(c); }); }); }; vv.addEventListener('resize', again); vv.addEventListener('scroll', again); // the layout viewport can change alone, with no event: a full-screen view pins the page's body // (780px → the screen's width); the body's width is what moves then. Its height grows with the // page as it loads, which moves no launcher, so a change of height alone restacks nothing (#1095). if (window.ResizeObserver && document.body) { var bodyW = -1; new window.ResizeObserver(function (es) { var w = es[0] && es[0].contentRect.width; if (w === bodyW) return; bodyW = w; again(); }).observe(document.body); } window.addEventListener('resize', again); } } // launchers share one centre line across the flow: a 34px one beside the 40px dock button sat // flush to the edge instead, off centre by half the difference, times the corner's size // what is drawn across: the corner's size, and a peeking launcher's scale(.8) as well (a dock entry is laid out smaller) var across = function (el) { var d = dim.get(el); return (row ? d.h : d.w) * (grown(el) ? size : 1) * (peek(el) && !el.classList.contains('mbu-dock-item') ? 0.8 : 1); }; els.concat(peeks).forEach(fit); var lane = 0; els.concat(peeks).forEach(function (el) { if (small(el)) lane = Math.max(lane, across(el)); }); var inset = function (el) { return small(el) ? Math.round((lane - across(el)) / 2) : 0; }; var place = function (el, along) { put(el, bottom ? 'bottom' : 'top', px(gapY + (row ? edge + inset(el) : along))); put(el, right ? 'right' : 'left', px(gapX + (row ? along : edge + inset(el)))); put(el, right ? 'left' : 'right', 'auto'); }; var pos = edge; els.forEach(function (el) { place(el, pos); var d = dim.get(el); pos += (row ? d.w : d.h) * (grown(el) ? size : 1) + 8; }); // the folded dock's peeking entries: in a line from its button, along the stack's flow var side = edge + 44 * size; peeks.sort(byRank).forEach(function (el) { place(el, side); var d = Math.round(side - edge); // its way to the dock button, along the flow mbuPeekMove(el, row ? (right ? d : -d) : 0, row ? 0 : (bottom ? d : -d)); side += 36 * size; }); } function stFlip(key) { var k = __stDefOff.indexOf(key) < 0 ? "string_theory.off" : "string_theory.on"; var list = __stList(k); var i = list.indexOf(key); if (i < 0) list.push(key); else list.splice(i, 1); GM_setValue(k, list); } var stUIBlock = null, stTokensBlock = null; function stUI() { return stUIBlock || (stUIBlock = __st_UI(typeof GM_info !== 'undefined' ? GM_info : undefined)); } function stTokens() { return stTokensBlock || (stTokensBlock = __st_TOKENS(typeof GM_info !== 'undefined' ? GM_info : undefined)); } // Generated by build-providers.mjs; do not edit. Pinned versions: package.json. /*! @usync/drive ISC License Copyright (c) 2026 gera2ld Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /*! @usync/oauth2 ISC License Copyright (c) 2026 gera2ld Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /*! @usync/util ISC License Copyright (c) 2026 gera2ld Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /*! nanoid The MIT License (MIT) Copyright 2017 Andrey Sitnik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ var stSyncProviders = (function (fetch) { var __stProviders=(()=>{var I=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var Ee=Object.prototype.hasOwnProperty;var Ue=(e,t)=>{for(var r in t)I(e,r,{get:t[r],enumerable:!0})},Oe=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Pe(t))!Ee.call(e,n)&&n!==r&&I(e,n,{get:()=>t[n],enumerable:!(s=xe(t,n))||s.enumerable});return e};var $e=e=>Oe(I({},"__esModule",{value:!0}),e);var at={};Ue(at,{AuthenticatedDriveBase:()=>g,DriveBase:()=>B,Dropbox:()=>ue,DropboxAuthorizer:()=>oe,GithubContents:()=>me,GoogleAuthorizer:()=>ae,GoogleDrive:()=>ye,MicrosoftAuthorizer:()=>ce,OAUTH2_AUTH_ERROR:()=>Ce,OAUTH2_NEED_REFRESH:()=>R,OAUTH2_UNAUTHORIZED:()=>z,OAuth2Authorizer:()=>S,OAuth2Authorizers:()=>L,OAuth2Error:()=>p,OneDrive:()=>we,RepoNotFoundError:()=>fe,S3:()=>be,SimpleRequestError:()=>w,WebDav:()=>Te,connectDrive:()=>ot,ensureAccessToken:()=>F,simpleRequest:()=>m,withDelay:()=>_,withToken:()=>N});var Z="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var $=(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=Z[r[e]&63];return t};function Se(e){return e.toBase64?.()}function je(e){return btoa(re(e))}function D(e){return Se(e)??je(e)}function Ie(e){return Uint8Array.fromBase64?.(e)}function Y(e){let t=atob(e.replace(/\s+/g,"")),r=new Uint8Array(t.length);for(let s=0;s{i&&s.searchParams.set(n,i)}),s.href}async finishAuth(t){if(!this.session||this.session.state!==t.searchParams.get("state"))throw new p(2,"state doesn't match");let r=t.searchParams.get("code");if(!r)throw new p(2,"Invalid code");let s=new URLSearchParams;Object.entries({client_id:this.options.clientId,client_secret:this.options.clientSecret,code:r,code_verifier:this.session.codeVerifier,grant_type:"authorization_code",redirect_uri:this.options.redirectUrl}).forEach(([o,a])=>{a!=null&&s.append(o,a)});let n=await fetch(se,{method:"POST",body:s}),i=await n.json();if(!n.ok)throw{status:n.status,data:i};return i.refresh_token&&this._updateRefreshToken({token:i.refresh_token,scope:i.scope}),this._updateAccessToken({token:i.access_token,expiresAt:Date.now()+i.expires_in*1e3}),i.access_token}async refreshToken(){let t=new URLSearchParams,r=this.getRefreshToken();Object.entries({client_id:this.options.clientId,client_secret:this.options.clientSecret,grant_type:"refresh_token",refresh_token:r}).forEach(([i,o])=>{o!=null&&t.append(i,o)});let s=await fetch(se,{method:"POST",body:t}),n=await s.json();if(!s.ok)throw{status:s.status,data:n};return this._updateAccessToken({token:n.access_token,expiresAt:Date.now()+n.expires_in*1e3}),n.access_token}getClaims(){throw new p(2,"OIDC not supported by Dropbox")}},T.Scopes={account:"account_info.read"},T),Fe="https://accounts.google.com/o/oauth2/v2/auth",ne="https://oauth2.googleapis.com/token",k,ae=(k=class extends S{get isOidc(){return this.options.scope?.split(/\s+/).includes("openid")??!1}async buildAuthUrl(){this.session={state:q(),codeVerifier:C(),...this.isOidc?{nonce:ie()}:{}};let{codeChallenge:t,codeChallengeMethod:r}=await K(this.session.codeVerifier),s=new URL(Fe);return Object.entries({access_type:this.options.provider?.google?.accessType,client_id:this.options.clientId,code_challenge:t,code_challenge_method:r,include_granted_scopes:"true",nonce:this.session.nonce,prompt:this.options.provider?.google?.prompt,redirect_uri:this.options.redirectUrl,response_type:"code",scope:this.options.scope,state:this.session.state}).forEach(([n,i])=>{i&&s.searchParams.set(n,i)}),s.href}async finishAuth(t){if(!this.session||this.session.state!==t.searchParams.get("state"))throw new p(2,"state doesn't match");let r=t.searchParams.get("code");if(!r)throw new p(2,"Invalid code");let s=new URLSearchParams;Object.entries({client_id:this.options.clientId,client_secret:this.options.clientSecret,code:r,code_verifier:this.session.codeVerifier,grant_type:"authorization_code",redirect_uri:this.options.redirectUrl}).forEach(([o,a])=>{a!=null&&s.append(o,a)});let n=await fetch(ne,{method:"POST",body:s}),i=await n.json();if(!n.ok)throw{status:n.status,data:i};if(i.refresh_token&&this._updateRefreshToken({token:i.refresh_token,scope:i.scope}),this._updateAccessToken({token:i.access_token,expiresAt:Date.now()+i.expires_in*1e3}),this.isOidc){if(!i.id_token)throw new p(2,"OIDC enabled but no id_token returned");this._idToken=i.id_token}return i.access_token}async refreshToken(){let t=new URLSearchParams,r=this.getRefreshToken();Object.entries({client_id:this.options.clientId,client_secret:this.options.clientSecret,grant_type:"refresh_token",refresh_token:r,scope:this.options.scope}).forEach(([i,o])=>{o!=null&&t.append(i,o)});let s=await fetch(ne,{method:"POST",body:t}),n=await s.json();if(!s.ok)throw{status:s.status,data:n};return this._updateAccessToken({token:n.access_token,expiresAt:Date.now()+n.expires_in*1e3}),n.access_token}},k.Scopes={account:"https://www.googleapis.com/auth/userinfo.profile","drive.appdata":"https://www.googleapis.com/auth/drive.appdata",imap:"https://mail.google.com/"},k),v,ce=(v=class extends S{get isOidc(){return this.options.scope?.split(/\s+/).includes("openid")??!1}oauth2Url(t){return`https://login.microsoftonline.com/${this.options.provider?.microsoft?.accountType??"common"}/oauth2/v2.0/${t}`}async buildAuthUrl(){this.session={state:q(),codeVerifier:C(),...this.isOidc?{nonce:ie()}:{}};let{codeChallenge:t,codeChallengeMethod:r}=await K(this.session.codeVerifier),s=new URL(this.oauth2Url("authorize"));return Object.entries({client_id:this.options.clientId,code_challenge:t,code_challenge_method:r,nonce:this.session.nonce,redirect_uri:this.options.redirectUrl,response_mode:"query",response_type:"code",scope:this.options.scope,state:this.session.state}).forEach(([n,i])=>{i&&s.searchParams.set(n,i)}),s.href}async finishAuth(t){if(!this.session||this.session.state!==t.searchParams.get("state"))throw new p(2,"state doesn't match");let r=t.searchParams.get("code");if(!r)throw new p(2,"Invalid code");let s=new URLSearchParams;Object.entries({client_id:this.options.clientId,client_secret:this.options.clientSecret,code:r,code_verifier:this.session.codeVerifier,grant_type:"authorization_code",redirect_uri:this.options.redirectUrl,scope:this.options.scope}).forEach(([o,a])=>{a!=null&&s.append(o,a)});let n=await fetch(this.oauth2Url("token"),{method:"POST",body:s}),i=await n.json();if(!n.ok)throw{status:n.status,data:i};if(i.refresh_token||this._updateRefreshToken({token:i.refresh_token,scope:i.scope}),this._updateAccessToken({token:i.access_token,expiresAt:Date.now()+i.expires_in*1e3}),this.isOidc){if(!i.id_token)throw new p(2,"OIDC enabled but no id_token returned");this._idToken=i.id_token}return i.access_token}async refreshToken(){let t=new URLSearchParams,r=this.getRefreshToken();Object.entries({client_id:this.options.clientId,client_secret:this.options.clientSecret,grant_type:"refresh_token",refresh_token:r,scope:this.options.scope}).forEach(([i,o])=>{o!=null&&t.append(i,o)});let s=await fetch(this.oauth2Url("token"),{method:"POST",body:t}),n=await s.json();if(!s.ok)throw{status:s.status,data:n};return this._updateAccessToken({token:n.access_token,expiresAt:Date.now()+n.expires_in*1e3}),n.access_token}},v.Scopes={imap:"offline_access https://outlook.office.com/IMAP.AccessAsUser.All",onedrive:"openid profile Files.ReadWrite.AppFolder offline_access"},v),L={dropbox:oe,google:ae,microsoft:ce};async function F(e,t){let r;try{r=e.getAccessToken()}catch(s){if(!(s instanceof p))throw s;switch(s.code){case 3:{if(!t)throw s;let n=await t(await e.buildAuthUrl());r=await e.finishAuth(new URL(n));break}case 1:r=await e.refreshToken();break;default:throw s}}return r}function Ne(e){return new Promise(t=>setTimeout(t,e))}function x(e){return e?Array.isArray(e)?e:[e]:[]}var w=class extends Error{constructor(e,t,r,s){super(e),this.request=t,this.response=r,this.cause=s}};function m(e,t,r=fetch){let{json:s,...n}=t||{},i=n.method||"GET",o={url:e.toString(),method:i},a=new Headers(n.headers);s!=null&&(n.body=JSON.stringify(s),a.set("content-type","application/json"));async function c(h){let d;try{d=await r(e,{...n,headers:a});let l=await h(d);if(!d.ok)throw new w(d.statusText,o,d,l);return l}catch(l){throw l instanceof w?l:new w(l?.message||`${l}`,o,d,l)}}return{blob:()=>c(h=>h.blob()),json:()=>c(h=>h.json()),text:()=>c(h=>h.text())}}function _(e){let t=0;return async(r,s)=>{let n=t,i;for(let o=5;o>0;--o){await Ne(n);try{let a=await e(r,s);return t>>=1,a}catch(a){if(i=a,a instanceof w&&a.response?.status===429){let c=a.response.headers.get("retry-after"),h=c&&(isNaN(+c)?new Date(c).getTime()-Date.now():c*1e3);h?n=h:(n=Math.max(1e3,n*2),t=n)}else break}}throw i}}function N(e,t){if(!e)throw Error("Invalid authorizer");return r=>async(s,n)=>{let{headers:i,...o}=n,a=new Headers(i),c=await F(e,t);return a.set("authorization",`Bearer ${c}`),await r(s,{...o,headers:a})}}var B=class{},g=class extends B{constructor(e,t){super(),this.authConfig=e,this.context=t,this.request=this.initRequest()}initRequest(){let e=async(r,s)=>{let{responseType:n,...i}=s;return await m(new URL(r,this.baseUrl),i,this.context?.fetch)[n]()},t=this.context?.authorizer;if(!t)throw Error("OAuth2 authorizer is not available");return e=N(t)(e),e=_(e),e}};var de=class{constructor(e={}){this.ignoreAttributes=e.ignoreAttributes??!1,this.removeNSPrefix=e.removeNSPrefix??!0}parse(e){let t=new DOMParser().parseFromString(e,"text/xml").documentElement;return{[this.removeNSPrefix?t.localName:t.tagName]:this.node(t)}}node(e){let t={};if(!this.ignoreAttributes)for(let n of e.attributes)n.name==="xmlns"||n.name.startsWith("xmlns:")||(t[`@${n.name}`]=n.value);let r=[];for(let n of e.childNodes)n.nodeType===1&&r.push(n);if(r.length===0){let n=e.textContent?.trim()??"";if(Object.keys(t).length===0){if(!n)return{};let i=Number(n);return isNaN(i)||n===""?n:i}return n?{...t,"#text":n}:t}let s={};for(let n of r){let i=this.removeNSPrefix?n.localName:n.tagName;(s[i]??(s[i]=[])).push(n)}for(let[n,i]of Object.entries(s))t[n]=i.length===1?this.node(i[0]):i.map(o=>this.node(o));return t}},Be=/[\u007f-\uffff]/g,He=e=>`\\u${(e.charCodeAt(0)+65536).toString(16).slice(1)}`;function he(e){return JSON.stringify(e).replace(Be,He)}var ue=class extends g{normalizeEntry(e){return{kind:e[".tag"]==="file"?"file":"folder",id:e.id,name:e.name,size:e.size||0,modifiedTime:e.server_modified||""}}getDropboxPath(e,t){if(e?.id)return e.id;let r=e?.path||"";if(r[0]!=="/"&&(r=`/${r}`),r==="/"&&!t)throw Error("Invalid path");return r}async getAccount(){let e=await this.request("https://api.dropboxapi.com/2/users/get_current_account",{method:"POST",responseType:"json"});return this.account={id:e.account_id,name:e.name.display_name,avatar:e.profile_photo_url},this.account}async mkdir(e){let t=[this.getDropboxPath(e.parent,!0),e.name].filter(Boolean).join("/"),r=await this.request("https://api.dropboxapi.com/2/files/create_folder_v2",{method:"POST",json:{path:t},responseType:"json"});return this.normalizeEntry({...r.metadata,".tag":"folder"})}async find(e){let t=this.getDropboxPath(e,!1),r=await this.request("https://api.dropboxapi.com/2/files/get_metadata",{method:"POST",json:{path:t},responseType:"json"});return this.normalizeEntry(r)}async*list(e){let t=e?this.getDropboxPath(e,!0):"",r=await this.request("https://api.dropboxapi.com/2/files/list_folder",{method:"POST",json:{path:t},responseType:"json"});for(yield r.entries.map(s=>this.normalizeEntry(s));r.has_more;)r=await this.request("https://api.dropboxapi.com/2/files/list_folder/continue",{method:"POST",json:{cursor:r.cursor},responseType:"json"}),yield r.entries.map(s=>this.normalizeEntry(s))}async get(e){let t=this.getDropboxPath(e,!1);return this.request("https://content.dropboxapi.com/2/files/download",{method:"POST",headers:{"Dropbox-API-Arg":he({path:t})},responseType:"blob"})}async remove(e){let t=this.getDropboxPath(e,!1);await this.request("https://api.dropboxapi.com/2/files/delete",{method:"POST",json:{path:t},responseType:"json"})}async put(e,t){let r=e.parent?[this.getDropboxPath(e.parent,!0).replace(/\/$/,""),e.name].join("/"):this.getDropboxPath(e,!0);if(!r)throw Error("Invalid path");let s=await this.request("https://content.dropboxapi.com/2/files/upload",{method:"POST",headers:{"Dropbox-API-Arg":he({path:r,mode:"overwrite"}),"Content-Type":"application/octet-stream"},body:t,responseType:"json"});return this.normalizeEntry({...s,".tag":"file"})}},fe=class extends Error{constructor(e,t){super(`Repository "${e}/${t}" was not found, or the token does not have access to it. Create the repository first, then make sure the token can read and write its contents.`),this.name="RepoNotFoundError"}},We="https://api.github.com";function j(e){return e instanceof w&&e.response?.status===404}function le(e){return e instanceof w&&e.response?.status===409}var me=class extends g{constructor(e,t){super(e,t);let{owner:r,repo:s}=this.getOptions();if(!r||!s)throw Error("owner and repo are required")}getOptions(){let e=this.authConfig.serverOptions||{},t=(e.apiBase?.trim()||We).replace(/\/+$/,""),r=e.owner?.trim()||"",s=e.repo?.trim()||"";return{apiBase:t,owner:r,repo:s,branch:e.branch?.trim()||"main",pathPrefix:(e.pathPrefix||"").replace(/^\/+|\/+$/g,""),createMethod:e.createMethod==="post"?"post":"put",token:this.authConfig.password?.trim()||"",name:e.name?.trim()||(r&&s?`${r}/${s}`:"GitHub"),avatar:e.avatar?.trim()||""}}initRequest(){return _((e,t)=>{let{responseType:r,headers:s,...n}=t,{apiBase:i,token:o}=this.getOptions(),a=new Headers(s);return a.set("accept","application/json"),o&&a.set("authorization",`token ${o}`),m(new URL(e,`${i}/`),{cache:"no-store",...n,headers:a},this.context?.fetch)[r]()})}async getAccount(){let{owner:e,repo:t,name:r,avatar:s}=this.getOptions();return this.account={id:`${e}/${t}`,name:r,avatar:s||void 0},this.account}async mkdir(e){throw Error("Not supported")}joinPath(...e){return e.map(t=>(t||"").replace(/^\/+|\/+$/g,"")).filter(Boolean).join("/")}resolvePath(e){let{pathPrefix:t}=this.getOptions();return this.joinPath(t,e?.id??e?.path??"")}contentsUrl(e){let{owner:t,repo:r}=this.getOptions(),s=e.split("/").filter(Boolean).map(encodeURIComponent).join("/");return`repos/${t}/${r}/contents${s?`/${s}`:""}`}refQuery(){return`?ref=${encodeURIComponent(this.getOptions().branch)}`}normalizeItem(e){return{id:e.name,name:e.name,size:e.size,kind:e.type==="dir"?"folder":"file",modifiedTime:""}}async checkRepoExists(){let{owner:e,repo:t}=this.getOptions();try{await this.request(`repos/${e}/${t}`,{responseType:"json"})}catch(r){throw j(r)?new fe(e,t):r}}async find(e){let t=this.resolvePath(e);try{let r=await this.request(`${this.contentsUrl(t)}${this.refQuery()}`,{responseType:"json"});if(Array.isArray(r))throw Error("Item not found");return this.normalizeItem(r)}catch(r){throw j(r)&&await this.checkRepoExists(),r}}async*list(e){let t=this.resolvePath(e),r;try{r=await this.request(`${this.contentsUrl(t)}${this.refQuery()}`,{responseType:"json"})}catch(s){if(j(s)){await this.checkRepoExists(),yield[];return}throw s}yield(Array.isArray(r)?r:[r]).filter(s=>s.type==="file"||s.type==="dir").map(s=>this.normalizeItem(s))}async get(e){let t=this.resolvePath(e),r=await this.request(`${this.contentsUrl(t)}${this.refQuery()}`,{responseType:"json"});if(Array.isArray(r)||r.type!=="file"||r.content==null)throw Error("Not a file");return new Blob([X(r.content)])}async remove(e){let t=this.resolvePath(e),{branch:r}=this.getOptions();for(let s=0;;s++){let n=await this.request(`${this.contentsUrl(t)}${this.refQuery()}`,{responseType:"json"});if(Array.isArray(n))throw Error("Cannot remove a directory");try{await this.request(this.contentsUrl(t),{method:"DELETE",responseType:"json",json:{message:`Delete ${t}`,sha:n.sha,branch:r}});return}catch(i){if(s===0&&le(i))continue;throw i}}}async put(e,t){let{branch:r,createMethod:s}=this.getOptions(),n=e.parent?this.joinPath(this.resolvePath(e.parent),e.name):this.resolvePath(e);if(!n)throw Error("Invalid path");let i=D(new Uint8Array(await t.arrayBuffer()));for(let o=0;;o++){let a;try{let h=await this.request(`${this.contentsUrl(n)}${this.refQuery()}`,{responseType:"json"});Array.isArray(h)||(a=h.sha)}catch(h){if(!j(h))throw h}let c=a?"PUT":s.toUpperCase();try{let h=await this.request(this.contentsUrl(n),{method:c,responseType:"json",json:{message:`${a?"Update":"Add"} ${n}`,content:i,branch:r,...a?{sha:a}:{}}});return this.normalizeItem(h.content)}catch(h){if(o===0&&le(h))continue;throw h}}}},E="id,name,size,kind,mimeType,modifiedTime",Me=`files(${E}),nextPageToken`,ye=class extends g{constructor(...e){super(...e),this.baseUrl="https://www.googleapis.com/drive/v3/",this.rootId="appDataFolder"}async getAccount(){let e=await this.request("https://www.googleapis.com/oauth2/v1/userinfo?alt=json",{responseType:"json"});return this.account={id:e.id,name:e.name,avatar:e.picture},this.account}normalizeEntry(e){return{kind:e.kind.endsWith("#file")?"file":"folder",id:e.id,name:e.name,size:Number(e.size),modifiedTime:e.modifiedTime}}async stat(e){let t=await this.request(`files/${e}?fields=${E}`,{responseType:"json"});return this.normalizeEntry(t)}async listFiles(e,t,r,s){let n=[];e&&n.push(`'${e}' in parents`),t&&n.push(`name = '${t.replace(/'/g,"\\'")}'`);let i=new URLSearchParams({spaces:this.rootId,fields:r||"files(id),nextPageToken"});return n.length&&i.set("q",n.join(" and ")),s&&i.set("pageToken",s),this.request(`files?${i}`,{responseType:"json"})}async resolveId(e){return e.id?e.id:e.path?(await this.find(e)).id:this.rootId}async find(e){if(e.id)return this.stat(e.id);if(!e.path)throw Error("Invalid path");let t=e.path.split("/").filter(Boolean),r,s;for(let n of t){if(s=(await this.listFiles(r,n,`files(${E})`)).files[0],!s)throw Error("Item not found");r=s.id}if(!s)throw Error("Item not found");return this.normalizeEntry(s)}async mkdir(e){let t=e.parent&&await this.resolveId(e.parent),r=await this.request("files",{method:"POST",json:{name:e.name,parents:[t||this.rootId],mimeType:"application/vnd.google-apps.folder"},responseType:"json"});return this.normalizeEntry(r)}async*list(e){let t=e&&await this.resolveId(e),r="";for(;;){let s=await this.listFiles(t,void 0,Me,r);if(yield s.files.map(n=>this.normalizeEntry(n)),!s.nextPageToken)break;r=s.nextPageToken}}async get(e){let t=await this.resolveId(e);return await this.request(`files/${t}?alt=media`,{responseType:"blob"})}async remove(e){let t=await this.resolveId(e);await this.request(`files/${t}`,{method:"DELETE",responseType:"blob"})}async put(e,t){let r="",s={};if(e.parent){let a=await this.resolveId(e.parent),c=await this.listFiles(a,e.name,"files(id)");c.files.length?r=c.files[0].id:s={parents:[a],name:e.name}}else r=await this.resolveId(e);if(!r&&!s.name)throw Error("Invalid file name");let n=new FormData;n.append("metadata",new Blob([JSON.stringify(s)],{type:"application/json"})),n.append("file",t);let i=r?`https://www.googleapis.com/upload/drive/v3/files/${r}?uploadType=multipart&fields=${E}`:`https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart&fields=${E}`,o=await this.request(i,{body:n,method:r?"PATCH":"POST",responseType:"json"});return this.normalizeEntry(o)}},Ve=class{constructor(){this.components=[]}append(e,t){if(!e.length)throw Error("Invalid path component");if(t&&e[0]!=="/"&&(e=`/${e}`),this.components.length%2>0==!t){let r=this.components.pop();this.components.push(r+e)}else this.components.push(e)}toString(){return this.components.join(":")}},we=class extends g{constructor(...e){super(...e),this.baseUrl="https://graph.microsoft.com/v1.0/",this.root="me/drive/special/approot"}async getAccount(){let e=await this.request("/oidc/userinfo",{responseType:"json"});return this.account={id:e.sub,name:e.givenname+" "+e.familyname,avatar:e.picture},this.account}normalizeEntry(e){return{id:e.id,name:e.name,size:e.size,kind:"file",modifiedTime:e.lastModifiedDateTime}}getOneDrivePath(e,t){let r=new Ve;if(e.parent){e.parent.id?r.append(`me/drive/items/${e.parent.id}`,!1):(r.append(this.root,!1),e.parent.path&&r.append(e.parent.path,!0));let s=e.name;if(s&&r.append(s,!0),!s&&!t)throw Error("Invalid path: name is required")}else if(e.id)r.append(`me/drive/items/${e.id}`,!1);else{r.append(this.root,!1);let s=e.path?.replace(/^\//,"");s&&r.append(s,!0)}return r}async mkdir(e){let t=this.getOneDrivePath(e.parent,!0);t.append("/children",!1);let r=await this.request(t.toString(),{method:"POST",json:{name:e.name,folder:{},"@microsoft.graph.conflictBehavior":"fail"},responseType:"json"});return this.normalizeEntry(r)}async find(e){let t=this.getOneDrivePath(e,!1),r=await this.request(t.toString(),{responseType:"json"});return this.normalizeEntry(r)}async*list(e){let t=this.getOneDrivePath(e??{},!0);t.append("/children",!1);let r=t.toString();for(;r;){let s=await this.request(r,{responseType:"json"});r=s["@odata.nextLink"]||"",yield s.value.map(n=>this.normalizeEntry(n))}}async get(e){let t=this.getOneDrivePath(e,!1);return t.append("/content",!1),this.request(t.toString(),{responseType:"blob"})}async remove(e){let t=this.getOneDrivePath(e,!1);await this.request(t.toString(),{method:"DELETE",responseType:"blob"})}async put(e,t){let r=this.getOneDrivePath(e,!1);r.append("/content",!1);let s=await this.request(r.toString(),{method:"PUT",headers:{"Content-Type":"application/octet-stream"},body:t,responseType:"json"});return this.normalizeEntry(s)}},Ge="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",W=new TextEncoder;function H(e){return encodeURIComponent(e).replace(/[!'()*]/g,t=>`%${t.codePointAt(0).toString(16).toUpperCase()}`)}function ge(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function pe(e){let t;t=typeof e=="string"?W.encode(e).buffer:e instanceof Blob?await e.arrayBuffer():e instanceof Uint8Array?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e;let r=await crypto.subtle.digest("SHA-256",t);return ge(new Uint8Array(r))}async function U(e,t){let r=typeof e=="string"?W.encode(e):e,s=await crypto.subtle.importKey("raw",r,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return new Uint8Array(await crypto.subtle.sign("HMAC",s,W.encode(t)))}async function Je(e,t,r){let s=await U(`AWS4${e}`,t);return s=await U(s,r),s=await U(s,"s3"),U(s,"aws4_request")}function Qe(e){return e.includes("://")?e:`https://${e}`}function Ze(e){return e.replace(/^\/+|\/+$/g,"")}function A(e){return e.replace(/^\/+/,"").replace(/\/+$/,"")}function Ye(e){return A(e).split("/").filter(Boolean)}function Xe(e){return A(e).split("/").pop()||""}async function et(e,t){let r=(await e.parse(t)).ListBucketResult||{};return{contents:x(r.Contents).map(s=>({key:s.Key||"",lastModified:s.LastModified||"",size:Number(s.Size||0)})),commonPrefixes:x(r.CommonPrefixes).map(s=>s.Prefix||""),nextContinuationToken:r.NextContinuationToken||""}}async function P({method:e,endpoint:t,path:r,query:s,accessKeyId:n,secretAccessKey:i,region:o,body:a}){let c=new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),h=c.slice(0,8),d=`/${Ye(r).map(H).join("/")}`,l=[...s].sort(([b,O],[J,Q])=>b===J?OQ):b`${H(b)}=${H(O)}`).join("&"),u=`${t.replace(/\/$/,"")}${d}${l?`?${l}`:""}`,f=a?await pe(a):Ge,y={host:new URL(u).host,"x-amz-content-sha256":f,"x-amz-date":c},M=Object.keys(y).sort(),ke=M.map(b=>`${b}:${y[b]} `).join(""),V=M.join(";"),ve=[e,d,l,ke,V,f].join(` `),G=`${h}/${o}/s3/aws4_request`,_e=["AWS4-HMAC-SHA256",c,G,await pe(ve)].join(` `),Ae=ge(await U(await Je(i,h,o),_e));return{url:u,headers:{...y,Authorization:`AWS4-HMAC-SHA256 Credential=${n}/${G}, SignedHeaders=${V}, Signature=${Ae}`}}}var be=class extends g{getOptions(){let e=this.authConfig.serverOptions||{},t=e.bucket?.trim()||"";return{bucket:t,endpoint:Qe(e.endpoint?.trim()||""),prefix:Ze(e.prefix?.trim()||""),region:e.region?.trim()||"us-east-1",accessKeyId:this.authConfig.user?.trim()||"",secretAccessKey:this.authConfig.password?.trim()||"",name:e.name?.trim()||t||"S3",avatar:e.avatar?.trim()||""}}getRootPrefix(){let{prefix:e}=this.getOptions();return e?`${e}/`:""}resolveKey(e){return A(e?.id||e?.path||"")}resolveFullKey(e){return`${this.getRootPrefix()}${this.resolveKey(e)}`.replace(/\/+$/,"")}normalizeFile(e,t,r,s){return{id:A(e).replace(/\/+$/,""),name:Xe(e),size:t,kind:s,modifiedTime:r}}initRequest(){return _(async(e,t)=>{let{responseType:r,headers:s,body:n,...i}=t,o=this.getOptions();if(!o.bucket||!o.endpoint||!o.accessKeyId||!o.secretAccessKey)throw Error("Invalid S3 configuration");let a=new URL(e,o.endpoint),c=Array.from(a.searchParams.entries()),{url:h,headers:d}=await P({method:(i.method||"GET").toUpperCase(),endpoint:o.endpoint,path:a.pathname,query:c,accessKeyId:o.accessKeyId,secretAccessKey:o.secretAccessKey,region:o.region,body:n}),l=new Headers(s);for(let[u,f]of Object.entries(d))l.set(u,f);return await m(new URL(h),{...i,headers:l,body:n},this.context?.fetch)[r]()})}async getAccount(){let e=this.getOptions();return this.account={id:e.bucket,name:e.name,avatar:e.avatar||void 0},this.account}async mkdir(e){throw Error("Not supported")}async find(e){let t=this.resolveKey(e);if(!t)throw Error("Invalid path");let r,s=t.split("/").filter(Boolean);for(let n=0;nc.name===s[n]);if(a){r=a;break}}}if(!r)throw Error("Item not found");return r}async*list(e){let t=this.context?.xmlParser||new de,r=this.getOptions(),s=this.getRootPrefix(),n=e?this.resolveKey(e):"",i=`${s}${n?`${n}/`:""}`,o="";do{let a=new URLSearchParams({"list-type":"2",delimiter:"/",prefix:i});o&&a.set("continuation-token",o);let{url:c,headers:h}=await P({method:"GET",endpoint:r.endpoint,path:r.bucket,query:Array.from(a.entries()),accessKeyId:r.accessKeyId,secretAccessKey:r.secretAccessKey,region:r.region}),d=await et(t,await m(new URL(c),{headers:h},this.context?.fetch).text()),l=[];for(let u of d.contents){let f=A(u.key);if(!f.startsWith(i))continue;let y=f.slice(i.length);y&&l.push(this.normalizeFile(y,u.size,u.lastModified,"file"))}for(let u of d.commonPrefixes){let f=A(u);if(!f.startsWith(i))continue;let y=f.slice(i.length);y&&l.push(this.normalizeFile(y,0,"","folder"))}yield l,o=d.nextContinuationToken}while(o)}async get(e){let t=this.resolveFullKey(e),r=this.getOptions(),{url:s,headers:n}=await P({method:"GET",endpoint:r.endpoint,path:`${r.bucket}/${t}`,query:[],accessKeyId:r.accessKeyId,secretAccessKey:r.secretAccessKey,region:r.region});return m(new URL(s),{headers:n},this.context?.fetch).blob()}async remove(e){let t=this.resolveFullKey(e),r=this.getOptions(),{url:s,headers:n}=await P({method:"DELETE",endpoint:r.endpoint,path:`${r.bucket}/${t}`,query:[],accessKeyId:r.accessKeyId,secretAccessKey:r.secretAccessKey,region:r.region});await m(new URL(s),{method:"DELETE",headers:n},this.context?.fetch).blob()}async put(e,t){let r=this.resolveFullKey(e.parent),s=e.parent?`${r?`${r}/`:this.getRootPrefix()}${e.name}`:this.resolveFullKey(e);if(!s)throw Error("Invalid file name");let n=this.getOptions(),i=`${n.bucket}/${s}`,{url:o,headers:a}=await P({method:"PUT",endpoint:n.endpoint,path:i,query:[],accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey,region:n.region,body:t});return await m(new URL(o),{method:"PUT",headers:a,body:t},this.context?.fetch).blob(),this.normalizeFile(s,t.size,new Date().toISOString(),s.endsWith("/")?"folder":"file")}};function tt(e){try{return decodeURIComponent(e)}catch{return e}}function rt(e){let t=x(e?.propstat),r=t.filter(n=>String(n?.status??"").includes("200")),s=(r.length?r:t.slice(0,1)).map(n=>n?.prop??{});return Object.assign({},...s)}var Te=class extends g{constructor(e,t){super(e,t);let r=e.serverOptions?.baseUrl;if(!r)throw Error("baseUrl is required");r.endsWith("/")||(r+="/"),this.baseUrl=r}initRequest(){let e=(t,r)=>{let{responseType:s,headers:n,...i}=r,o=new Headers(n),{serverOptions:a={},user:c,password:h}=this.authConfig;if(a&&!a.anonymous){let d=D(new TextEncoder().encode(`${c}:${h}`));o.set("authorization",`Basic ${d}`)}return t.startsWith("/")&&(t=`.${t}`),m(new URL(t,this.baseUrl),{credentials:"omit",...i,headers:o},this.context?.fetch)[s]()};return e=_(e),e}async getAccount(){let{serverOptions:e={}}=this.authConfig;return this.account={id:`${e.id||"webdav"}`,name:`${e.name||"WebDav"}`,avatar:`${e.avatar||""}`},this.account}getWebDavPath(e,t){let r=e?.path||e?.id||"";if(r[0]==="/"&&(r=r.slice(1)),!r&&!t)throw Error("Invalid path");return r}getFullUrl(e){return new URL(e,this.baseUrl).href}normalizeUrl(e){return e.replace(/\/+$/,"")}async mkdir(e){let t=[this.getWebDavPath(e.parent,!0),e.name].filter(Boolean).join("/");return await this.request(t,{method:"MKCOL",responseType:"blob"}),{id:this.getFullUrl(t),name:e.name,size:0,kind:"folder",modifiedTime:new Date().toISOString()}}async propFind(e){let t=this.context?.xmlParser||new de,r=await this.request(e,{method:"PROPFIND",headers:{depth:"1"},responseType:"text"}),s=await t.parse(r);return x(s?.multistatus?.response).map(n=>{let i=rt(n),o=i.resourcetype?.collection!==void 0,a=n.href||"",c=new URL(a,this.baseUrl).pathname.split("/").filter(Boolean).pop()||"",h=i.getlastmodified;return{id:this.getFullUrl(a),name:i.displayname||tt(c),kind:o?"folder":"file",size:o?0:i.getcontentlength??0,modifiedTime:h?new Date(h).toISOString():""}})}async find(e){let t=this.getWebDavPath(e,!1),r=this.getFullUrl(t),s=(await this.propFind(t)).find(n=>this.normalizeUrl(n.id)===this.normalizeUrl(r));if(!s)throw Error("Item not found");return s}async*list(e){let t=this.getWebDavPath(e,!0),r=this.getFullUrl(t),s=await this.propFind(t);s=s.filter(n=>this.normalizeUrl(n.id)!==this.normalizeUrl(r)),yield s}async get(e){let t=this.getWebDavPath(e,!1);return this.request(t,{responseType:"blob"})}async remove(e){let t=this.getWebDavPath(e,!1);await this.request(t,{method:"DELETE",responseType:"blob"})}async put(e,t){let r=e.parent?[this.getWebDavPath(e.parent,!0),e.name].filter(Boolean).join("/"):this.getWebDavPath(e,!0);if(!r)throw Error("Invalid path");return await this.request(r,{method:"PUT",headers:{"Content-Type":"application/octet-stream"},body:t,responseType:"blob"}),{id:this.getFullUrl(r),name:r.slice(r.lastIndexOf("/")+1),size:t.size,kind:"file",modifiedTime:new Date().toISOString()}}},st={googledrive:ye,dropbox:ue,onedrive:we,s3:be,webdav:Te,"github-contents":me};function nt(e){if(e instanceof p)return e.code===z||e.code===R;if(typeof e=="object"&&e){let t=e.response?.status;return t===401||t===403}return!1}function it(e,t){let r=e;if(!r||!r.clientId||!r.redirectUrl)throw Error(`Invalid OAuth2 config for provider: ${t}`);return r}async function ot(e,t){let r={...t?.initialContext};if(e.auth.authProvider!=="password"){let i=e.auth.authProvider,o=it(e.auth.serverOptions,i),a=L[i];r.authorizer=new a({...o,onSetAccessToken:c=>{t?.onUpdateToken?.({accessToken:c??void 0})},onSetRefreshToken:c=>{t?.onUpdateToken?.({refreshToken:c??void 0})}},t?.initialData)}let s=t?.providers?.[e.driveProvider]??st[e.driveProvider];if(!s)throw Error(`Unknown drive provider: ${e.driveProvider}`);let n=new s(e.auth,r);if(e.auth.authProvider!=="password")try{await n.getAccount()}catch(i){if(!nt(i))throw i;n.account=void 0}return n}return $e(at);})(); return __stProviders; })(stSyncFetch); // External storage (#885). Provider IO is bundled; Dropbox and Google Drive use a redirect code flow with a refresh token, // WebDAV a user name and password (sync-webdav.js). var ST_DROPBOX_KEY = 'g73mzw3yp0xqgtd'; var ST_DROPBOX_REDIRECT = 'https://musicbrainz.org/?st-dropbox=callback'; var ST_SYNC_PATH = '/string-theory.json'; var ST_BACKUP_FOLDER = '/backups'; var stSyncBusy = false, stSyncTimer = null, stSyncActivity = ''; var stBackupSelected = null; var stBackupEntries = null, stBackupNotice = '', stBackupAccount = null; function stSyncFetch(url, options) { options = options || {}; var target = new URL(String(url)); // WebDAV reaches only the folder the user connected, and never follows its credentials elsewhere. var dav = options.webdav && stWebdavRoot(options.webdav); if (dav ? target.href.indexOf(dav) !== 0 : target.protocol !== 'https:' || !/^(?:api\.dropbox\.com|api\.dropboxapi\.com|content\.dropboxapi\.com|www\.googleapis\.com|oauth2\.googleapis\.com)$/.test(target.hostname)) return Promise.reject(new Error('Unexpected sync destination')); var headers = new Headers(options.headers || {}), body = options.body; if (body instanceof URLSearchParams) { headers.set('Content-Type', 'application/x-www-form-urlencoded'); body = body.toString(); } return Promise.resolve(body instanceof Blob ? body.arrayBuffer() : body).then(function (data) { return new Promise(function (resolve, reject) { GM_xmlhttpRequest({ method: options.method || 'GET', url: target.href, headers: Object.fromEntries(headers.entries()), data: data, anonymous: true, responseType: 'arraybuffer', timeout: 30000, onload: function (r) { if (!r.status) { reject(new Error('Storage connection failed')); return; } var h = new Headers(); String(r.responseHeaders || '').split(/\r?\n/).forEach(function (line) { var i = line.indexOf(':'); if (i > 0) try { h.append(line.slice(0, i).trim(), line.slice(i + 1).trim()); } catch (e) {} }); // 204 and 304 carry no body; a Response refuses one. resolve(new Response(/^(?:101|204|205|304)$/.test(r.status) ? null : r.response || r.responseText || '', { status: r.status, headers: h })); }, onerror: function () { reject(new Error('Storage connection failed')); }, ontimeout: function () { reject(new Error('Storage connection timed out')); }, onabort: function () { reject(new Error('Storage request cancelled')); }, }); }); }); } function stSyncSettings() { var v = GM_getValue('string_theory.sync.settings', {}) || {}; return { provider: v.provider === 'google' || v.provider === 'webdav' ? v.provider : 'dropbox', automatic: v.automatic === true, minutes: Math.max(5, Math.min(1440, Number(v.minutes) || 30)), conflict: v.conflict === 'local' ? 'local' : 'remote' }; } function stSyncSaveSettings(patch) { GM_setValue('string_theory.sync.settings', Object.assign(stSyncSettings(), patch)); stSyncSchedule(); stSyncPaint(); } function stSyncProvider() { return stSyncSettings().provider; } function stSyncName(provider) { provider = provider || stSyncProvider(); return provider === 'google' ? 'Google Drive' : provider === 'webdav' ? 'WebDAV' : 'Dropbox'; } function stSyncKey(part, provider) { provider = provider || stSyncProvider(); return 'string_theory.sync.' + (provider === 'dropbox' ? '' : provider + '.') + part; } function stSyncAuth(provider) { return GM_getValue(stSyncKey('auth', provider), {}) || {}; } function stSyncKeepNewAuth(provider) { var stage = GM_getValue('string_theory.sync.stage'); if (!stage) return; ['before', 'after'].forEach(function (side) { delete stage[side].gm[stSyncKey('auth', provider)]; }); GM_setValue('string_theory.sync.stage', stage); } function stSyncConnected(provider) { provider = provider || stSyncProvider(); var auth = stSyncAuth(provider); return provider === 'webdav' ? !!(auth.url && auth.user && auth.password) : !!auth.refreshToken; } function stSyncDrive(provider) { provider = provider || stSyncProvider(); return provider === 'webdav' ? stSyncWebdav(stSyncAuth(provider)) : provider === 'google' ? stSyncGoogle(stSyncAuthorizer(true, provider)) : stSyncDropbox(stSyncAuthorizer(true, provider)); } function stSyncState(patch, provider) { var s = GM_getValue(stSyncKey('state', provider), {}) || {}; if (patch) { s = Object.assign(s, patch); GM_setValue(stSyncKey('state', provider), s); } return s; } function stSyncAuthorizer(persist, provider) { provider = provider || 'dropbox'; var key = stSyncKey('auth', provider), auth = GM_getValue(key, {}) || {}; // A popup-era Google token has no refresh token; drop it so the library asks for a new connection. if (provider === 'google' && !auth.refreshToken) auth = {}; var tokens = Object.assign({}, auth); function save(k, v) { if (v) tokens[k] = v; else delete tokens[k]; if (persist !== false) GM_setValue(key, Object.assign({}, tokens)); } var hooks = { onSetAccessToken: function (v) { save('accessToken', v); }, onSetRefreshToken: function (v) { save('refreshToken', v); } }; var a = provider === 'google' ? new stSyncProviders.GoogleAuthorizer(Object.assign({ clientId: ST_GOOGLE_KEY, clientSecret: ST_GOOGLE_SECRET, redirectUrl: ST_GOOGLE_REDIRECT, scope: ST_GOOGLE_SCOPE, provider: { google: { accessType: 'offline', prompt: 'consent' } } }, hooks), auth) : new stSyncProviders.DropboxAuthorizer(Object.assign({ clientId: ST_DROPBOX_KEY, redirectUrl: ST_DROPBOX_REDIRECT, scope: 'account_info.read files.metadata.read files.content.read files.content.write' }, hooks), auth); a.stSyncTokens = tokens; return a; } // The provider's standard put() overwrites. Use its authenticated request layer with Dropbox's // revision precondition, and download the exact revision read from metadata, for a safe retry. function stSyncDropbox(authorizer) { var drive = new stSyncProviders.Dropbox({ authProvider: 'dropbox', user: '' }, { authorizer: authorizer, fetch: stSyncFetch }); async function request(url, options) { try { return await drive.request(url, options); } catch (e) { if (!e.response || e.response.status !== 401 || !GM_getValue('string_theory.sync.auth', {}).refreshToken) throw e; authorizer.setAccessToken({ token: 'expired', expiresAt: 1 }); return drive.request(url, options); } } function missing(e) { return e.response && e.response.status === 409 && /^path\/not_found(?:\/|$)/.test(e.cause && e.cause.error_summary || ''); } function backupEntry(entry) { if (!entry || entry['.tag'] !== 'file' || typeof entry.name !== 'string' || typeof entry.id !== 'string' || !entry.id || typeof entry.rev !== 'string' || !entry.rev || !/^\/backups\/string-theory-[\w.-]+\.json$/.test(entry.path_lower || '') || !Number.isFinite(entry.size) || entry.size < 0) throw new Error('Invalid remote backup'); return entry; } async function download(path, rev, size) { if (size > 10 * 1024 * 1024) throw new Error('Dropbox backup exceeds 10 MB'); var blob = await request('https://content.dropboxapi.com/2/files/download', { method: 'POST', headers: { 'Dropbox-API-Arg': JSON.stringify({ path: path, rev: rev }) }, responseType: 'blob', }); var info = {}, data = stSyncStorage.read(await blob.text(), info); return { rev: rev, data: data, filtered: info.filtered }; } function upload(data, path, rev) { var text = JSON.stringify(stSyncStorage.document(data)); if (new Blob([text]).size > 10 * 1024 * 1024) throw new Error('Backup exceeds 10 MB'); return request('https://content.dropboxapi.com/2/files/upload', { method: 'POST', headers: { 'Content-Type': 'application/octet-stream', 'Dropbox-API-Arg': JSON.stringify({ path: path, mode: rev ? { '.tag': 'update', update: rev } : { '.tag': 'add' }, autorename: false, strict_conflict: true, mute: true }) }, body: new Blob([text], { type: 'application/octet-stream' }), responseType: 'json', }); } return { account: function () { return drive.getAccount(); }, read: async function () { var meta; try { meta = await request('https://api.dropboxapi.com/2/files/get_metadata', { method: 'POST', json: { path: ST_SYNC_PATH }, responseType: 'json' }); } catch (e) { if (missing(e)) return { rev: null, data: null }; throw e; } if (typeof meta.rev !== 'string' || !meta.rev) throw new Error('Dropbox returned no file revision'); return download(ST_SYNC_PATH, meta.rev, meta.size); }, write: function (data, rev) { return upload(data, ST_SYNC_PATH, rev); }, backup: async function (data) { try { await request('https://api.dropboxapi.com/2/files/create_folder_v2', { method: 'POST', json: { path: ST_BACKUP_FOLDER, autorename: false }, responseType: 'json' }); } catch (e) { if (!(e.response && e.response.status === 409 && /^path\/conflict\/folder(?:\/|$)/.test(e.cause && e.cause.error_summary || ''))) throw e; } // Each save is a new immutable snapshot, independent of the live sync file. var path = ST_BACKUP_FOLDER + '/string-theory-' + new Date().toISOString().replace(/:/g, '-') + '-' + crypto.randomUUID() + '.json'; return backupEntry(Object.assign({ '.tag': 'file' }, await upload(data, path, null))); }, listBackups: async function () { var page; try { page = await request('https://api.dropboxapi.com/2/files/list_folder', { method: 'POST', json: { path: ST_BACKUP_FOLDER, recursive: false, include_deleted: false, limit: 1000 }, responseType: 'json' }); } catch (e) { if (missing(e)) return []; throw e; } var entries = [], cursors = Object.create(null); for (;;) { if (!page || !Array.isArray(page.entries)) throw new Error('Invalid Dropbox backup list'); page.entries.forEach(function (entry) { try { entries.push(backupEntry(entry)); } catch (e) { /* unrelated files and folders */ } }); if (!page.has_more) break; if (!page.cursor || cursors[page.cursor]) throw new Error('Invalid Dropbox backup cursor'); cursors[page.cursor] = true; page = await request('https://api.dropboxapi.com/2/files/list_folder/continue', { method: 'POST', json: { cursor: page.cursor }, responseType: 'json' }); } return entries.sort(function (a, b) { return String(b.server_modified).localeCompare(String(a.server_modified)) || b.name.localeCompare(a.name); }); }, readBackup: async function (entry) { backupEntry(entry); try { return await download(entry.id, entry.rev, entry.size); } catch (e) { if (e.response && e.response.status === 409) throw new Error('Backup is unavailable. Refresh the list.'); throw e; } }, deleteBackup: async function (entry) { backupEntry(entry); try { return await request('https://api.dropboxapi.com/2/files/delete_v2', { method: 'POST', json: { path: entry.id, parent_rev: entry.rev }, responseType: 'json' }); } catch (e) { if (e.response && e.response.status === 409) throw new Error('Backup changed or is unavailable. Refresh the list.'); throw e; } }, }; } async function stBackupRun(mode, entry) { if (stSyncBusy) return; var provider = stSyncProvider(), name = stSyncName(provider); if (!stSyncConnected(provider)) throw new Error('Connect ' + name + ' first'); if (entry && (entry.provider || 'dropbox') !== provider) throw new Error('Provider changed. Refresh the backup list.'); stSyncBusy = true; stSyncActivity = 'backup'; stBackupNotice = ''; stSyncPaint(); try { var drive = stSyncDrive(provider); if (mode === 'save') { var saved = await drive.backup(stSyncStorage.effective()); if (stBackupEntries !== null) stBackupEntries.unshift(saved); stBackupNotice = 'Backup saved to ' + name + '.'; } else if (mode === 'list') { stBackupEntries = await drive.listBackups(); } else if (mode === 'apply') { var incoming = (await drive.readBackup(entry)).data; stSyncImport(incoming); stBackupBrowse(document.getElementById('st-p-s'), false); stBackupNotice = 'Imported. Reload to see the changes.'; } else if (mode === 'delete') { await drive.deleteBackup(entry); stBackupEntries = (stBackupEntries || []).filter(function (item) { return item.id !== entry.id; }); stBackupNotice = 'Backup deleted from ' + name + '.'; } else throw new Error('Unknown backup action'); if (mode !== 'list') stUI().mbuToast(stBackupNotice); } catch (e) { stBackupNotice = stSyncError(e); throw e; } finally { stSyncBusy = false; stSyncActivity = ''; stSyncPaint(); } } function stSyncImport(incoming) { // Partial imports preserve data absent from the file; incoming values win shared fields. stSyncStorage.stage(stSyncStorage.merge(undefined, stSyncStorage.effective(), incoming, 'remote')); // #1095: applied here and now, not by the next page load; the GM guard keeps running members' // stale saves from undoing it stSyncStorage.applyPending(); } function stBackupBrowse(panel, open) { if (!panel) return; var remote = panel.querySelector('#st-sync-remote'); remote.hidden = !open; Array.prototype.forEach.call(panel.children, function (child) { if (child !== remote) child.inert = open; }); } function stBackupPaint(panel, connected) { var list = panel.querySelector('#st-sync-backups'); if (!list) return; list.hidden = stBackupEntries === null; panel.querySelector('#st-sync-backup-status').textContent = stBackupNotice; list.replaceChildren(); var actions = panel.querySelector('#st-sync-backup-actions'); actions.replaceChildren(); if (stBackupEntries === null) return; if (!stBackupEntries.length) { list.textContent = 'No remote backups yet.'; stBackupSelected = null; return; } var selected = stBackupEntries.findIndex(function (entry) { return entry.id === stBackupSelected; }); if (selected < 0) selected = 0; stBackupSelected = stBackupEntries[selected].id; var choices = document.createElement('div'); choices.className = 'st-backup-choices'; choices.setAttribute('role', 'group'); choices.setAttribute('aria-label', 'Saved backups'); stBackupEntries.forEach(function (entry, i) { var row = document.createElement('button'); row.type = 'button'; row.className = 'st-backup-choice'; row.dataset.backupSelect = String(i); row.setAttribute('aria-pressed', String(i === selected)); row.disabled = stSyncBusy || !connected; var date = new Date(entry.server_modified), label = document.createElement('span'), size = document.createElement('small'); label.textContent = isNaN(date.getTime()) ? entry.name : new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' }).format(date); size.textContent = Math.max(1, Math.ceil(entry.size / 1024)) + ' KB'; row.append(label, size); choices.appendChild(row); }); list.appendChild(choices); var entry = stBackupEntries[selected]; [['apply', 'Apply'], ['delete', 'Delete']].forEach(function (pair) { var button = document.createElement('button'); button.type = 'button'; button.className = 'st-b'; button.textContent = pair[1]; button.dataset.backupAction = pair[0]; button.dataset.backupIndex = String(selected); button.disabled = stSyncBusy || !connected; if (pair[0] === 'apply') button.dataset.tip = 'Merge this backup into your settings Applies on the next page load'.replace(' ', '\n'); actions.appendChild(button); }); } function stSyncError(e, provider) { var name = stSyncName(provider); var status = e && (e.status || e.response && e.response.status); if ((provider || stSyncProvider()) === 'webdav') { if (status === 401) return 'WebDAV sign-in failed. Check the user name and password.'; if (status === 403) return 'WebDAV denied access. Check the folder permissions.'; if (status === 404 || status === 409) return 'WebDAV folder not found. Check the URL.'; if (status === 507) return 'WebDAV storage is full.'; } if (status === 400 || status === 401 || e instanceof stSyncProviders.OAuth2Error) return name + ' authorization failed. Connect again.'; if (status === 403) return name + ' denied access. Check the app permissions.'; if (status === 429) return name + ' is busy. Try again later.'; // Never show a provider response body: it may contain tokens or copied credentials. return status ? name + ' request failed (HTTP ' + status + ')' : e && e.message || 'Sync failed'; } async function stSyncConnect(provider, redirectHere) { if (stSyncBusy) return; provider = provider || stSyncProvider(); var authorizer = stSyncAuthorizer(false, provider); var url = await authorizer.buildAuthUrl(); // The callback runs in the same userscript namespace, including when this tab was reloaded. var pending = { provider: provider, state: authorizer.session.state, codeVerifier: authorizer.session.codeVerifier, at: Date.now() }; GM_setValue('string_theory.sync.oauth', pending); stSyncAuthPending = { provider: provider, state: pending.state, at: pending.at }; if (redirectHere) location.assign(url); else if (typeof GM_openInTab === 'function') GM_openInTab(url, { active: true, insert: true }); else window.open(url, '_blank', 'noopener'); stSyncPaint(); } var stSyncAuthPending = null; async function stSyncFinish(callback) { callback = new URL(String(callback)); var pending = GM_getValue('string_theory.sync.oauth'); if (!pending || Date.now() - pending.at > 10 * 60e3) throw new Error('Authorization expired. Connect again.'); var provider = pending.provider === 'google' ? 'google' : 'dropbox', name = stSyncName(provider); if (callback.origin !== 'https://musicbrainz.org' || callback.pathname !== '/' || callback.searchParams.get(provider === 'google' ? 'st-google' : 'st-dropbox') !== 'callback' || callback.searchParams.get('state') !== pending.state) throw new Error('Authorization callback did not match this connection'); if (callback.searchParams.has('error')) throw new Error(callback.searchParams.get('error') === 'access_denied' ? name + ' authorization cancelled' : name + ' authorization failed'); var a = stSyncAuthorizer(false, provider); a.session = { state: pending.state, codeVerifier: pending.codeVerifier }; // Keep the old credentials until the replacement has completed successfully. await a.finishAuth(callback); if (!a.stSyncTokens.refreshToken) throw new Error(name + ' returned no lasting access. Connect again.'); var account = await (provider === 'google' ? stSyncGoogle(a) : stSyncDropbox(a)).account(); if ((GM_getValue('string_theory.sync.oauth') || {}).state !== pending.state) throw new Error('A newer ' + name + ' connection was started'); stSyncKeepNewAuth(provider); GM_setValue(stSyncKey('auth', provider), a.stSyncTokens); var previous = stSyncState(null, provider); if (previous.account && previous.account !== account.id) { GM_deleteValue(stSyncKey('base', provider)); GM_deleteValue('string_theory.sync.stage'); } stSyncState({ account: account.id, name: account.name, error: '', notice: '', at: 0, next: 0, failures: 0 }, provider); GM_deleteValue('string_theory.sync.oauth'); GM_setValue('string_theory.sync.oauth.result', { provider: provider, state: pending.state, ok: true, at: Date.now() }); stSyncAuthPending = null; stSyncSchedule(); stSyncPaint(); } function stSyncListenAuth() { var pending = GM_getValue('string_theory.sync.oauth'); if (pending && Date.now() - pending.at <= 10 * 60e3) stSyncAuthPending = { provider: pending.provider || 'dropbox', state: pending.state, at: pending.at }; if (typeof GM_addValueChangeListener !== 'function') return; // A retry from the callback tab replaces the attempt the settings tab was watching. GM_addValueChangeListener('string_theory.sync.oauth', function (key, old, next) { if (!next || Date.now() - next.at > 10 * 60e3) return; stSyncAuthPending = { provider: next.provider || 'dropbox', state: next.state, at: next.at }; stSyncPaint(); }); GM_addValueChangeListener('string_theory.sync.oauth.result', function (key, old, result) { if (!result || !stSyncAuthPending || result.state !== stSyncAuthPending.state) return; stSyncAuthPending = null; stSyncSchedule(); stSyncPaint(); var name = stSyncName(result.provider || 'dropbox'); stUI().mbuToast(result.ok ? 'Connected to ' + name : result.error || name + ' authorization failed', result.ok ? {} : { kind: 'error' }); }); } async function stSyncCallback() { // Scrub the single-use authorization code before the rest of MusicBrainz draws its links. var url = location.href, state = new URL(url).searchParams.get('state'), provider = new URL(url).searchParams.has('st-google') ? 'google' : 'dropbox'; history.replaceState(null, '', provider === 'google' ? ST_GOOGLE_REDIRECT : ST_DROPBOX_REDIRECT); var message, connected = false; try { await stSyncFinish(url); connected = true; message = 'Connected to ' + stSyncName(provider) + '. You can close this tab.'; } catch (e) { message = stSyncError(e, provider); var pending = GM_getValue('string_theory.sync.oauth'); if (pending && pending.state === state) { GM_deleteValue('string_theory.sync.oauth'); GM_setValue('string_theory.sync.oauth.result', { provider: provider, state: state, ok: false, error: message, at: Date.now() }); } } function show() { var box = document.createElement('div'); box.style.cssText = 'max-width:560px;margin:48px auto;padding:20px;font:16px/1.5 system-ui,sans-serif'; var h = document.createElement('h1'); h.textContent = 'String Theory'; var p = document.createElement('p'); p.textContent = message; box.append(h, p); document.body.replaceChildren(box); if (connected) { window.close(); return; } var retry = document.createElement('button'); retry.type = 'button'; retry.textContent = 'Try again'; retry.style.cssText = 'font:inherit;color:inherit;background:none;border:0;padding:0;text-decoration:underline;cursor:pointer'; retry.onclick = async function () { retry.disabled = true; try { await stSyncConnect(provider, true); } catch (e) { p.textContent = stSyncError(e, provider); retry.disabled = false; } }; box.append(retry); } if (document.body) show(); else document.addEventListener('DOMContentLoaded', show, { once: true }); } function stSyncDisconnect() { var provider = stSyncProvider(), old = stSyncState(), stage = GM_getValue('string_theory.sync.stage'); if (stage) { ['before', 'after'].forEach(function (side) { delete stage[side].gm[stSyncKey('auth', provider)]; delete stage[side].gm['string_theory.sync.settings']; }); GM_setValue('string_theory.sync.stage', stage); } GM_deleteValue(stSyncKey('auth', provider)); GM_deleteValue(stSyncKey('base', provider)); stSyncAuthPending = null; GM_deleteValue('string_theory.sync.oauth'); GM_deleteValue('string_theory.sync.oauth.result'); GM_setValue('string_theory.sync.settings', Object.assign(stSyncSettings(), { automatic: false })); GM_setValue(stSyncKey('state', provider), old.account ? { account: old.account } : {}); stSyncSchedule(); stSyncPaint(); } async function stSyncRun(manual, mode) { mode = mode || 'sync'; var provider = stSyncProvider(), name = stSyncName(provider); if (['sync', 'push', 'pull'].indexOf(mode) < 0) throw new Error('Unknown sync action'); if (stSyncBusy) return; async function run() { var state = stSyncState(null, provider), settings = stSyncSettings(); if (!stSyncConnected(provider)) { if (provider === 'google' && stSyncAuth(provider).accessToken) stSyncState({ error: 'Reconnect Google Drive to turn on sync.' }, provider); stSyncPaint(); return; } if (!manual && (!settings.automatic || Date.now() < (state.next || 0))) return; stSyncBusy = true; stSyncActivity = 'sync'; stSyncPaint(); try { var drive = stSyncDrive(provider); for (var attempt = 0; attempt < 4; attempt++) { var remote = await drive.read(), local = stSyncStorage.effective(); var base = GM_getValue(stSyncKey('base', provider)); if (mode === 'pull' && !remote.data) { stSyncState({ notice: 'No ' + name + ' backup yet. Local data unchanged.', error: '' }, provider); if (manual) stUI().mbuToast('No ' + name + ' backup yet. Local data unchanged.'); return; } var conflicts = [], merged; if (mode === 'pull') merged = remote.data; else if (mode === 'push') merged = { gm: local.gm, local: Object.assign({}, remote.data && remote.data.local || {}, local.local) }; else merged = remote.data ? stSyncStorage.merge(base, local, remote.data, settings.conflict, conflicts) : local; try { if (mode !== 'pull' && (remote.filtered || stSyncData.stable(merged) !== stSyncData.stable(remote.data))) await drive.write(merged, remote.rev); } catch (e) { if ((e.conflict || e.response && e.response.status === 409 && /conflict/.test(e.cause && e.cause.error_summary || '')) && attempt < 3) continue; throw e; } // A user may have changed settings during the request; keep those edits for the next run. var after = stSyncStorage.effective(); var pending = stSyncStorage.merge(local, after, merged, 'local'); var applied = false; if (mode !== 'push' && stSyncData.stable(pending) !== stSyncData.stable(after)) { stSyncStorage.stage(pending); applied = stSyncStorage.applyPending(); } GM_setValue(stSyncKey('base', provider), merged); stSyncState({ at: Date.now(), next: Date.now() + settings.minutes * 60e3, error: '', notice: '', failures: 0, conflicts: conflicts.length }, provider); if (manual) stUI().mbuToast(applied ? (mode === 'pull' ? 'Pulled from ' + name + '.' : 'Synced.') + ' Reload to see downloaded changes.' : mode === 'push' ? 'Pushed to ' + name : mode === 'pull' ? 'Pulled from ' + name : remote.data ? 'Synced with ' + name : 'Created the first ' + name + ' backup'); return; } } catch (e) { var failures = (stSyncState(null, provider).failures || 0) + 1; stSyncState({ error: stSyncError(e, provider), failures: failures, next: Date.now() + Math.min(60, Math.pow(2, Math.min(6, failures))) * 60e3 }, provider); if (manual) stUI().mbuToast(stSyncError(e, provider), { kind: 'error' }); } finally { stSyncBusy = false; stSyncActivity = ''; stSyncPaint(); } } // Web Locks serializes tabs on this origin. Revision-checked writes also protect other origins // and other devices, which cannot share that lock. if (navigator.locks) await navigator.locks.request('string-theory-' + provider, { ifAvailable: true }, function (lock) { if (lock) return run(); if (manual) stUI().mbuToast('Another tab is syncing with ' + name); }); else { var lease = GM_getValue('string_theory.sync.lease', {}), owner = crypto.randomUUID(); if (lease.until > Date.now()) { if (manual) stUI().mbuToast('Another tab is syncing with ' + name); return; } GM_setValue('string_theory.sync.lease', { owner: owner, until: Date.now() + 45000 }); if (GM_getValue('string_theory.sync.lease', {}).owner !== owner) return; var heartbeat = setInterval(function () { if (GM_getValue('string_theory.sync.lease', {}).owner === owner) GM_setValue('string_theory.sync.lease', { owner: owner, until: Date.now() + 45000 }); }, 10000); try { await run(); } finally { clearInterval(heartbeat); if (GM_getValue('string_theory.sync.lease', {}).owner === owner) GM_deleteValue('string_theory.sync.lease'); } } } function stSyncSchedule() { if (stSyncTimer) clearInterval(stSyncTimer); stSyncTimer = null; if ((typeof __stSyncCallbackOnly !== 'undefined' && __stSyncCallbackOnly) || !ST_ON_MB || !stSyncSettings().automatic || !stSyncConnected()) return; stSyncTimer = setInterval(function () { stSyncRun(false).catch(function () {}); }, 60000); // #1095: a due sync waits for the page to go idle, not its load var first = function () { stSyncRun(false).catch(function () {}); }; if (typeof requestIdleCallback === 'function') requestIdleCallback(first, { timeout: 10000 }); else setTimeout(first, 3000); } function stSyncDownload(doc, name) { var url = URL.createObjectURL(new Blob([JSON.stringify(doc, null, 2)], { type: 'application/json' })); var a = document.createElement('a'); a.href = url; a.download = name; a.click(); setTimeout(function () { URL.revokeObjectURL(url); }, 1000); } function stSyncMarkup() { return '
' + '' + '

' + '

Sync

' + '
' + '

Sync options

' + '
' + '
' + '

Backups

Dropbox
' + '
This device
' + '
'; } function stSyncPaint() { var panel = document.getElementById('st-p-s'); if (!panel || panel.hidden) return; var q = function (id) { return panel.querySelector('#st-sync-' + id); }; var provider = stSyncProvider(), name = stSyncName(provider), auth = stSyncAuth(provider), state = stSyncState(), settings = stSyncSettings(), connected = stSyncConnected(provider); var backupAccount = provider + ':' + (state.account || ''); q('provider').value = provider; q('provider').disabled = stSyncBusy; q('backup-provider').textContent = name + ' backups'; q('backup-name').textContent = name; q('backups').setAttribute('aria-label', name + ' backups'); q('now').dataset.tip = 'Merge this device with ' + name; q('push').dataset.tip = 'Replace ' + name + '’s portable data with this device’s'; q('pull').dataset.tip = 'Replace this device’s portable data with ' + name + '’s\nKeeps device settings; applies on the next page load'; if (stBackupAccount !== backupAccount || !connected) { stBackupAccount = backupAccount; stBackupEntries = null; stBackupNotice = ''; stBackupSelected = null; stBackupBrowse(panel, false); } var dav = provider === 'webdav' && (!connected || stWebdavEditing); if (dav && q('dav').hidden) { q('dav-url').value = auth.url || ''; q('dav-user').value = auth.user || ''; q('dav-password').value = ''; } q('dav').hidden = !dav; ['dav-url', 'dav-user', 'dav-password'].forEach(function (id) { q(id).disabled = stSyncBusy; }); q('connect').textContent = (connected || auth.accessToken) && !dav ? 'Reconnect' : 'Connect'; q('disconnect').hidden = !auth.refreshToken && !auth.accessToken && !auth.url; q('auto').checked = settings.automatic; q('minutes').value = String(settings.minutes); q('conflict').value = settings.conflict; q('now').disabled = stSyncBusy || !connected; q('connect').disabled = stSyncBusy; q('disconnect').disabled = stSyncBusy; q('push').disabled = stSyncBusy || !connected; q('pull').disabled = stSyncBusy || !connected; ['remote-backup', 'remote-import'].forEach(function (id) { q(id).disabled = stSyncBusy || !connected; }); q('import').disabled = stSyncBusy; stBackupPaint(panel, connected); q('status').textContent = stSyncBusy ? '' : (provider === 'google' && auth.accessToken && !connected ? 'Reconnect Google Drive to turn on sync.' : state.error) || (stSyncAuthPending ? 'Waiting for ' + stSyncName(stSyncAuthPending.provider) + ' authorization…' : state.notice || (connected ? '' : 'Not connected')); q('status').hidden = !q('status').textContent; q('progress').hidden = !stSyncBusy || stSyncActivity !== 'sync'; q('backup-progress').hidden = !stSyncBusy || stSyncActivity !== 'backup'; q('browse-progress').hidden = !stSyncBusy || stSyncActivity !== 'backup'; var last = state.at && new Date(state.at), today = new Date(); q('last').textContent = last ? 'Last sync: ' + new Intl.DateTimeFormat(undefined, last.toDateString() === today.toDateString() ? { hour: '2-digit', minute: '2-digit' } : { dateStyle: 'short', timeStyle: 'short' }).format(last) : ''; q('last').dataset.tip = last ? new Intl.DateTimeFormat(undefined, { dateStyle: 'full', timeStyle: 'long' }).format(last) : ''; } function stSyncBind(panel) { var q = function (id) { return panel.querySelector('#st-sync-' + id); }; var action = function (fn) { return function () { Promise.resolve().then(fn).catch(function (e) { stUI().mbuToast(stSyncError(e), { kind: 'error' }); }).finally(stSyncPaint); }; }; q('provider').onchange = function () { stWebdavEditing = false; stSyncSaveSettings({ provider: q('provider').value }); }; q('connect').onclick = action(function () { if (stSyncProvider() !== 'webdav') return stSyncConnect(); // Reconnect first opens the form; Connect tests and saves what it holds. if (q('dav').hidden) { stWebdavEditing = true; stSyncPaint(); q('dav-password').focus(); return; } return stSyncConnectWebdav(q('dav-url').value, q('dav-user').value, q('dav-password').value).then(function () { q('dav-password').value = ''; }); }); q('dav').onkeydown = function (e) { if (e.key === 'Enter') { e.preventDefault(); q('connect').click(); } }; q('disconnect').onclick = stSyncDisconnect; q('auto').onchange = function () { stSyncSaveSettings({ automatic: q('auto').checked }); }; q('minutes').onchange = function () { stSyncSaveSettings({ minutes: +q('minutes').value }); }; q('conflict').onchange = function () { stSyncSaveSettings({ conflict: q('conflict').value }); }; q('now').onclick = action(function () { return stSyncRun(true); }); q('push').onclick = action(function () { return stSyncRun(true, 'push'); }); q('pull').onclick = action(function () { return stSyncRun(true, 'pull'); }); q('remote-backup').onclick = action(function () { return stBackupRun('save'); }); q('remote-import').onclick = action(function () { stBackupBrowse(panel, true); q('backup-close').focus(); return stBackupRun('list'); }); q('backup-close').onclick = function () { stBackupBrowse(panel, false); q('remote-import').focus(); }; q('remote').onclick = function (event) { var choice = event.target.closest('button[data-backup-select]'); if (choice && !stSyncBusy) { var index = choice.dataset.backupSelect; stBackupSelected = stBackupEntries[Number(index)].id; stSyncPaint(); q('backups').querySelector('[data-backup-select="' + index + '"]').focus(); return; } var button = event.target.closest('button[data-backup-action]'); if (!button || stSyncBusy) return; var entry = stBackupEntries && stBackupEntries[Number(button.dataset.backupIndex)]; if (!entry) return; var mode = button.dataset.backupAction; action(function () { return stBackupRun(mode, entry); })(); }; q('export').onclick = action(function () { stSyncDownload(stSyncStorage.document(stSyncStorage.effective()), 'string-theory-backup.json'); }); q('import').onclick = function () { q('file').click(); }; q('file').onchange = action(async function () { var file = q('file').files[0]; if (!file) return; if (file.size > 10 * 1024 * 1024) throw new Error('Backup exceeds 10 MB'); var incoming = stSyncStorage.read(await file.text()); stSyncImport(incoming); q('file').value = ''; stUI().mbuToast('Imported. Reload to see the changes.'); }); stSyncPaint(); } // Google Drive: redirect code flow with a refresh token, as Violentmonkey does. var ST_GOOGLE_KEY = '762250056217-8uip1j2fusc9npm4fievee31btjqf02o.apps.googleusercontent.com'; // An installed-app secret is public by design (Violentmonkey ships its own); PKCE still guards the code. var ST_GOOGLE_SECRET = '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'; var ST_GOOGLE_REDIRECT = 'https://musicbrainz.org/?st-google=callback'; var ST_GOOGLE_SCOPE = 'https://www.googleapis.com/auth/drive.file'; function stSyncGoogle(authorizer) { authorizer = authorizer || stSyncAuthorizer(true, 'google'); var drive = new stSyncProviders.GoogleDrive({ authProvider: 'google', user: '' }, { authorizer: authorizer, fetch: stSyncFetch }); var API = 'https://www.googleapis.com/drive/v3/', fields = 'id,name,mimeType,size,version,headRevisionId,modifiedTime,createdTime,appProperties,description,parents,trashed'; function request(path, options) { return drive.request(path.indexOf('https:') === 0 ? path : API + path, Object.assign({ responseType: 'json' }, options)); } function ours(file, kind) { return file && !file.trashed && file.appProperties && file.appProperties.stSuite === 'string-theory' && file.appProperties.stKind === kind; } async function list(kind) { var items = [], token = '', seen = Object.create(null); do { var query = new URLSearchParams({ q: "trashed = false and appProperties has { key='stSuite' and value='string-theory' } and appProperties has { key='stKind' and value='" + kind + "' }", spaces: 'drive', pageSize: '1000', fields: 'nextPageToken,files(' + fields + ')' }); if (token) query.set('pageToken', token); var page = await request('files?' + query); if (!page || !Array.isArray(page.files)) throw new Error('Invalid Google Drive file list'); page.files.forEach(function (f) { if (ours(f, kind)) items.push(f); }); token = page.nextPageToken || ''; if (token && seen[token]) throw new Error('Invalid Google Drive page token'); seen[token] = true; } while (token); return items; } async function folder() { var folders = await list('folder'); folders.sort(function (a, b) { return String(a.createdTime).localeCompare(String(b.createdTime)) || a.id.localeCompare(b.id); }); if (folders.length) return folders[0].id; return (await request('files?fields=id', { method: 'POST', json: { name: 'String Theory', mimeType: 'application/vnd.google-apps.folder', appProperties: { stSuite: 'string-theory', stKind: 'folder' } } })).id; } function entry(file) { if (!ours(file, 'backup') || file.mimeType !== 'application/json' || !file.id || !file.headRevisionId || !Number.isFinite(Number(file.size))) throw new Error('Invalid Google Drive backup'); return { provider: 'google', id: file.id, name: file.name, rev: file.headRevisionId, version: file.version, size: Number(file.size), server_modified: file.modifiedTime }; } async function readFile(file) { if (!file || file.mimeType !== 'application/json' || !file.id || !file.headRevisionId || !Number.isFinite(Number(file.size)) || Number(file.size) > 10 * 1024 * 1024) throw new Error('Invalid or oversized Google Drive snapshot'); var blob = await request('files/' + encodeURIComponent(file.id) + '/revisions/' + encodeURIComponent(file.headRevisionId) + '?alt=media', { responseType: 'blob' }); var info = {}, data = stSyncStorage.read(await blob.text(), info); return { data: data, filtered: info.filtered }; } async function create(data, kind, parents) { var text = JSON.stringify(stSyncStorage.document(data)), body = new Blob([text], { type: 'application/json' }); if (body.size > 10 * 1024 * 1024) throw new Error('Backup exceeds 10 MB'); var meta = { name: 'string-theory-' + kind + '-' + new Date().toISOString().replace(/:/g, '-') + '-' + crypto.randomUUID() + '.json', mimeType: 'application/json', parents: [await folder()], appProperties: { stSuite: 'string-theory', stKind: kind }, description: JSON.stringify({ parents: parents || [] }) }; // Resumable upload also covers snapshots between 5 and 10 MB. Only Google receives the token. var token = await stSyncProviders.ensureAccessToken(authorizer); var response = await stSyncFetch('https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable&fields=' + encodeURIComponent(fields), { method: 'POST', headers: { Authorization: 'Bearer ' + token, 'Content-Type': 'application/json', 'X-Upload-Content-Type': 'application/json' }, body: JSON.stringify(meta), }); if (!response.ok) throw Object.assign(new Error('Google Drive upload failed'), { response: response }); var destination = new URL(response.headers.get('Location')); if (destination.origin !== 'https://www.googleapis.com' || destination.pathname.indexOf('/upload/drive/v3/files') !== 0) throw new Error('Unexpected Google Drive upload destination'); return request(destination.href, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: body }); } return { account: async function () { // Drive's own about endpoint needs no extra email/profile scope. var user = (await request('about?fields=user')).user; if (!user || !user.permissionId) throw new Error('Google Drive returned no account'); return { id: user.permissionId, name: user.displayName || '' }; }, read: async function () { // Immutable revisions form a DAG. Concurrent writers add separate heads; neither can // overwrite the other. Read and merge their nearest shared ancestor on the next sync. var files = await list('sync'), byId = Object.create(null), ancestors = Object.create(null), used = new Set(), documents = Object.create(null), filtered = false; files.forEach(function (file) { if (byId[file.id]) throw new Error('Duplicate Google Drive revision'); var parents; try { parents = JSON.parse(file.description).parents; } catch (e) { throw new Error('Invalid Google Drive sync history'); } if (!Array.isArray(parents) || parents.some(function (id) { return typeof id !== 'string' || !/^[\w-]{1,200}$/.test(id) || id === file.id; })) throw new Error('Invalid Google Drive sync history'); byId[file.id] = { file: file, parents: parents }; parents.forEach(function (id) { used.add(id); }); }); used.forEach(function (id) { if (!byId[id]) throw new Error('Google Drive sync history is incomplete. Restore its trashed sync files.'); }); var degree = Object.create(null), children = Object.create(null), roots = []; files.forEach(function (f) { degree[f.id] = byId[f.id].parents.length; if (!degree[f.id]) roots.push(f.id); byId[f.id].parents.forEach(function (id) { (children[id] || (children[id] = [])).push(f.id); }); }); for (var r = 0; r < roots.length; r++) (children[roots[r]] || []).forEach(function (id) { if (!--degree[id]) roots.push(id); }); if (roots.length !== files.length) throw new Error('Invalid Google Drive sync history'); var heads = files.filter(function (f) { return !used.has(f.id); }).sort(function (a, b) { return String(a.modifiedTime).localeCompare(String(b.modifiedTime)) || a.id.localeCompare(b.id); }); if (!heads.length) { if (files.length) throw new Error('Invalid Google Drive sync history'); return { rev: null, data: null }; } function depths(id) { var out = Object.create(null), queue = [[id, 0]]; for (var i = 0; i < queue.length; i++) { var item = queue[i]; if (out[item[0]] !== undefined) continue; out[item[0]] = item[1]; byId[item[0]].parents.forEach(function (p) { queue.push([p, item[1] + 1]); }); } return out; } async function document(file) { if (!documents[file.id]) documents[file.id] = readFile(file); var doc = await documents[file.id]; filtered = filtered || doc.filtered; return doc.data; } async function combine(selected) { if (selected.length === 1) return document(selected[0]); selected.forEach(function (f) { if (!ancestors[f.id]) ancestors[f.id] = depths(f.id); }); var common = files.filter(function (f) { return selected.every(function (h) { return ancestors[h.id][f.id] !== undefined; }); }), commonParents = new Set(); common.forEach(function (f) { byId[f.id].parents.forEach(function (id) { commonParents.add(id); }); }); // Criss-cross merges can have multiple maximal common ancestors. Merge those too, // rather than choosing one and treating the other's saved items as new additions. var frontier = common.filter(function (f) { return !commonParents.has(f.id); }).sort(order); var base = frontier.length ? await combine(frontier) : undefined, merged; for (var i = 0; i < selected.length; i++) { var data = await document(selected[i]); merged = i ? stSyncStorage.merge(base, merged, data, 'remote') : data; } return merged; } function order(a, b) { return String(a.modifiedTime).localeCompare(String(b.modifiedTime)) || a.id.localeCompare(b.id); } var merged = await combine(heads); return { rev: heads.map(function (f) { return f.id; }), data: merged, filtered: filtered || heads.length > 1 }; }, write: function (data, rev) { return create(data, 'sync', rev || []); }, backup: async function (data) { return entry(await create(data, 'backup')); }, listBackups: async function () { return (await list('backup')).map(entry).sort(function (a, b) { return b.server_modified.localeCompare(a.server_modified) || b.id.localeCompare(a.id); }); }, readBackup: async function (selected) { var file = await request('files/' + encodeURIComponent(selected.id) + '?fields=' + fields); entry(file); // Read the selected immutable content revision even if a user edited it in Drive meanwhile. return readFile(Object.assign({}, file, { headRevisionId: selected.rev, size: selected.size })); }, deleteBackup: async function (selected) { var file = await request('files/' + encodeURIComponent(selected.id) + '?fields=' + fields); entry(file); // Drive's general version includes invisible metadata updates. Only a different // content revision makes this selection stale; reading a backup must not block deletion. if (file.headRevisionId !== selected.rev) throw new Error('Backup changed. Refresh the list.'); // Drive deletion is recoverable. Never permanently delete a file or touch sync revisions. return request('files/' + encodeURIComponent(file.id) + '?fields=id', { method: 'PATCH', json: { trashed: true } }); }, }; } // WebDAV (Nextcloud, ownCloud, Synology, Apache mod_dav, …): Basic auth to a folder the user names. // Writes carry the read ETag (If-Match), a first write If-None-Match: *, so a concurrent writer is a 412. var ST_WEBDAV_BACKUP = /^string-theory-[\w.-]+\.json$/; var stWebdavEditing = false; function stWebdavRoot(url) { var u; try { u = new URL(String(url || '').trim()); } catch (e) { throw new Error('Enter the WebDAV folder URL'); } if (u.protocol !== 'https:' && !(u.protocol === 'http:' && /^(?:localhost|127\.0\.0\.1|\[::1\])$/.test(u.hostname))) throw new Error('WebDAV needs an https:// URL'); if (u.username || u.password || u.search || u.hash) throw new Error('Enter the folder URL without a user name, query or fragment'); if (!/\/$/.test(u.pathname)) u.pathname += '/'; return u.href; } function stSyncWebdav(auth) { auth = auth || stSyncAuth('webdav'); var root = stWebdavRoot(auth.url), folder = root + 'backups/', file = root + ST_SYNC_PATH.slice(1); var bytes = new TextEncoder().encode(String(auth.user || '') + ':' + String(auth.password || '')), bin = ''; for (var i = 0; i < bytes.length; i++) bin += String.fromCharCode(bytes[i]); var basic = 'Basic ' + btoa(bin); async function request(url, options, ok) { options = options || {}; var r = await stSyncFetch(url, Object.assign({}, options, { headers: Object.assign({ Authorization: basic }, options.headers || {}), webdav: root })); if ((ok || [200, 201, 204]).indexOf(r.status) < 0) throw Object.assign(new Error('WebDAV request failed'), { response: r, status: r.status, conflict: r.status === 412 }); return r; } // If-Match compares strongly: a weak or missing ETag falls back to "the file still exists". function etag(r) { var t = r.headers.get('ETag') || ''; return /^"[^"]*"$/.test(t) ? t : ''; } async function text(r) { var body = await r.text(); if (new Blob([body]).size > 10 * 1024 * 1024) throw new Error('WebDAV file exceeds 10 MB'); return body; } function put(url, data, headers) { var body = JSON.stringify(stSyncStorage.document(data)); if (new Blob([body]).size > 10 * 1024 * 1024) throw new Error('Backup exceeds 10 MB'); return request(url, { method: 'PUT', headers: Object.assign({ 'Content-Type': 'application/json' }, headers), body: body }).then(function (r) { return { r: r, size: new Blob([body]).size }; }); } function propfind(url, depth) { return request(url, { method: 'PROPFIND', headers: { Depth: String(depth), 'Content-Type': 'application/xml; charset=utf-8' }, body: '' }, [207]); } function entry(name, rev, size, modified) { if (typeof name !== 'string' || !ST_WEBDAV_BACKUP.test(name) || typeof rev !== 'string' || !Number.isFinite(size) || size < 0) throw new Error('Invalid WebDAV backup'); return { provider: 'webdav', id: name, name: name, rev: rev, size: size, server_modified: modified }; } async function mkcol(url) { // 405: the collection already exists. await request(url, { method: 'MKCOL' }, [200, 201, 204, 405]); } return { account: async function () { try { await propfind(root, 0); } catch (e) { if (e.status !== 404) throw e; await mkcol(root); } return { id: String(auth.user) + '@' + root, name: String(auth.user) + ' at ' + new URL(root).host }; }, read: async function () { var r = await request(file, { headers: { 'Cache-Control': 'no-cache' } }, [200, 404]); if (r.status === 404) return { rev: null, data: null }; var info = {}, data = stSyncStorage.read(await text(r), info); return { rev: etag(r) || '*', data: data, filtered: info.filtered }; }, write: function (data, rev) { return put(file, data, rev ? { 'If-Match': rev } : { 'If-None-Match': '*' }); }, backup: async function (data) { await mkcol(folder); var name = 'string-theory-' + new Date().toISOString().replace(/:/g, '-') + '-' + crypto.randomUUID() + '.json'; var saved = await put(folder + name, data, { 'If-None-Match': '*' }); return entry(name, etag(saved.r), saved.size, new Date().toISOString()); }, listBackups: async function () { var r; try { r = await propfind(folder, 1); } catch (e) { if (e.status === 404) return []; throw e; } var doc = new DOMParser().parseFromString(await text(r), 'application/xml'); if (doc.getElementsByTagName('parsererror').length) throw new Error('Invalid WebDAV backup list'); var dir = decodeURIComponent(new URL(folder).pathname), entries = []; Array.prototype.forEach.call(doc.getElementsByTagNameNS('DAV:', 'response'), function (res) { var one = function (tag) { var n = res.getElementsByTagNameNS('DAV:', tag)[0]; return n ? n.textContent.trim() : ''; }; try { if (res.getElementsByTagNameNS('DAV:', 'collection').length) return; var path = decodeURIComponent(new URL(one('href'), folder).pathname); if (path.indexOf(dir) !== 0) return; var name = path.slice(dir.length); var modified = new Date(one('getlastmodified')), tag = one('getetag'); entries.push(entry(name, /^"[^"]*"$/.test(tag) ? tag : '', Number(one('getcontentlength')), isNaN(modified.getTime()) ? '' : modified.toISOString())); } catch (e) { /* unrelated files and folders */ } }); return entries.sort(function (a, b) { return String(b.server_modified).localeCompare(String(a.server_modified)) || b.name.localeCompare(a.name); }); }, readBackup: async function (selected) { entry(selected.name, selected.rev, selected.size, selected.server_modified); if (selected.size > 10 * 1024 * 1024) throw new Error('WebDAV backup exceeds 10 MB'); var r; try { r = await request(folder + encodeURIComponent(selected.name), { headers: selected.rev ? { 'If-Match': selected.rev } : {} }); } catch (e) { if (e.status === 404 || e.status === 412) throw new Error('Backup changed or is unavailable. Refresh the list.'); throw e; } var info = {}, data = stSyncStorage.read(await text(r), info); return { rev: selected.rev, data: data, filtered: info.filtered }; }, deleteBackup: async function (selected) { entry(selected.name, selected.rev, selected.size, selected.server_modified); try { await request(folder + encodeURIComponent(selected.name), { method: 'DELETE', headers: selected.rev ? { 'If-Match': selected.rev } : {} }); } catch (e) { if (e.status === 404 || e.status === 412) throw new Error('Backup changed or is unavailable. Refresh the list.'); throw e; } }, }; } async function stSyncConnectWebdav(url, user, password) { if (stSyncBusy) return; var auth = { url: stWebdavRoot(url), user: String(user || '').trim(), password: String(password || '') }; if (!auth.user || !auth.password) throw new Error('Enter the WebDAV user name and password'); stSyncBusy = true; stSyncActivity = 'sync'; stSyncPaint(); try { // Keep the old credentials until the new ones have answered. var account = await stSyncWebdav(auth).account(); stSyncKeepNewAuth('webdav'); GM_setValue(stSyncKey('auth', 'webdav'), auth); var previous = stSyncState(null, 'webdav'); if (previous.account && previous.account !== account.id) { GM_deleteValue(stSyncKey('base', 'webdav')); GM_deleteValue('string_theory.sync.stage'); } stSyncState({ account: account.id, name: account.name, error: '', notice: '', at: 0, next: 0, failures: 0 }, 'webdav'); stWebdavEditing = false; } finally { stSyncBusy = false; stSyncActivity = ''; } stSyncSchedule(); stSyncPaint(); stUI().mbuToast('Connected to WebDAV'); } if (__stSyncCallbackOnly) { stSyncCallback(); return; } // String Theory's settings window (#851). build.mjs writes this file into the bundle, inside the scope of // its toggles, where these are defined: stMembers ([folder, name, version, @icon] per member), ST_VERSION, // ST_BRANCH (the branch a test build was made on, empty on main and stable), // ST_ICON, ST_HOME, ST_ON_MB, stFlip(folder), __stReadOff(), __stStarters (folder → { so, soStarted(), go() }), mbuShared(), mbRestackCorner(), and stUI() // and stTokens(), which return the shared UI and token blocks (each made once, the first time the window // opens). Plain ES5, as the bundle's own code: no build step touches it. var stCfgOv = null; function stEsc(s) { return String(s == null ? '' : s).replace(/[&<>"]/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"' }[c]; }); } function stCmpVer(a, b) { var pa = String(a).split('.').map(Number), pb = String(b).split('.').map(Number); for (var i = 0; i < Math.max(pa.length, pb.length); i++) { var d = (pa[i] || 0) - (pb[i] || 0); if (d) return d; } return 0; } var ST_REPO = 'majkinetor/musicbrainz-userscripts'; function stInstallUrl(ref) { return 'https://github.com/' + ST_REPO + '/raw/refs/heads/' + ref + '/userscripts/string_theory/string_theory.user.js'; } // A branch's newest commit, asked of GitHub's API, so its commit-pinned link installs exactly that build: // a branch link is served from GitHub's cache, which can hand out the build before for a few minutes. function stHeadSha(ref, cb) { var url = 'https://api.github.com/repos/' + ST_REPO + '/commits/' + ref; var done = function (txt) { var m = txt && /^[0-9a-f]{40}$/.exec(String(txt).trim()); cb(m ? m[0] : null); }; try { if (typeof GM_xmlhttpRequest === 'function') { GM_xmlhttpRequest({ method: 'GET', url: url, headers: { Accept: 'application/vnd.github.sha' }, timeout: 15000, onload: function (r) { done(r.status >= 200 && r.status < 300 ? r.responseText : null); }, onerror: function () { done(null); }, ontimeout: function () { done(null); } }); } else { fetch(url, { headers: { Accept: 'application/vnd.github.sha' }, cache: 'no-store' }) .then(function (r) { return r.ok ? r.text() : null; }).then(done, function () { done(null); }); } } catch (e) { done(null); } } // Install the branch's newest commit, pinned. The tab opens at once, while the click still counts, and // is sent on when GitHub answers; if it can't, the branch link is the fallback. function stInstallPinned(ref) { var w = window.open('about:blank', '_blank'); if (w) try { w.opener = null; } catch (_) {} stHeadSha(ref, function (sha) { var url = sha ? 'https://github.com/' + ST_REPO + '/raw/' + sha + '/userscripts/string_theory/string_theory.user.js' : stInstallUrl(ref); if (w) w.location.href = url; else window.open(url, '_blank', 'noopener'); }); } // only the first few KB: @version is on the metadata block's third line function stRemoteVersion(ref, cb) { var url = 'https://raw.githubusercontent.com/' + ST_REPO + '/refs/heads/' + ref + '/userscripts/string_theory/string_theory.user.js?t=' + Date.now(); var done = function (txt) { var m = txt && /@version +([0-9.]+)/.exec(txt); cb(m ? m[1] : null); }; try { if (typeof GM_xmlhttpRequest === 'function') { GM_xmlhttpRequest({ method: 'GET', url: url, headers: { Range: 'bytes=0-4095' }, timeout: 15000, onload: function (r) { done(r.status >= 200 && r.status < 300 ? r.responseText : null); }, onerror: function () { done(null); }, ontimeout: function () { done(null); } }); } else { fetch(url, { headers: { Range: 'bytes=0-4095' }, cache: 'no-store' }) .then(function (r) { return r.ok ? r.text() : null; }).then(done, function () { done(null); }); } } catch (e) { done(null); } } // Icons are drawn with different margins, so the same box shows them at different sizes: crop an SVG // icon to what it draws, square and with a little room for strokes. A raster icon is left as it is. // Both fits are kept in localStorage, keyed by a hash of the icon: measuring forces a layout of the whole // page per icon, which made every page's first open of the settings take a second or more. var stFitStore = (function () { var KEY = 'mbu-st-icon-fit', data = null, timer = 0; var hash = function (s) { var h = 5381; for (var i = 0; i < s.length; i++) h = (h * 33 ^ s.charCodeAt(i)) >>> 0; return s.length + ':' + h.toString(36); }; var load = function () { if (!data) { try { data = JSON.parse(localStorage.getItem(KEY) || '{}') || {}; } catch (e) { data = {}; } } return data; }; return { get: function (k) { return load()[hash(k)]; }, set: function (k, v) { load()[hash(k)] = v === k ? 1 : v; clearTimeout(timer); timer = setTimeout(function () { try { localStorage.setItem(KEY, JSON.stringify(data)); } catch (e) { /* full or blocked */ } }, 500); }, }; })(); var stFitCache = {}; function stFitIcon(src) { if (!src) return ''; if (stFitCache[src]) return stFitCache[src]; var kept = stFitStore.get('b' + src); if (kept) return (stFitCache[src] = kept === 1 ? src : kept); var out = src; try { var txt = null, m = /^]*?\ssrc="([^"]*)"/i.exec(src); if (m) { var url = m[1].replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&'); var d = /^data:image[/]svg\+xml([^,]*),([\s\S]*)$/i.exec(url); if (d) txt = /;base64/i.test(d[1]) ? decodeURIComponent(escape(atob(d[2]))) : decodeURIComponent(d[2]); } else if (/^ 0 && b.height > 0) { var side = Math.max(b.width, b.height) * 1.08, cx = b.x + b.width / 2, cy = b.y + b.height / 2; svg.setAttribute('viewBox', [cx - side / 2, cy - side / 2, side, side].map(function (n) { return Math.round(n * 100) / 100; }).join(' ')); svg.removeAttribute('width'); svg.removeAttribute('height'); svg.removeAttribute('style'); out = ''; } } box.remove(); } } catch (e) { /* keep the icon as it is */ } stFitCache[src] = out; stFitStore.set('b' + src, out === src ? 'b' + src : out); return out; } // getBBox counts what a clip path or a mask hides (Art Station's sky), so the box can still be too big: // once an icon is drawn, crop it again to its visible pixels. var stPixCache = {}; function stFitPixels(root) { Array.prototype.forEach.call(root.querySelectorAll('img[src^="data:image/svg+xml"]'), function (img) { var src = img.getAttribute('src'); if (!stPixCache[src]) { var kept = stFitStore.get('p' + src); if (kept) stPixCache[src] = kept === 1 ? src : kept; } if (stPixCache[src]) { if (stPixCache[src] !== src) img.src = stPixCache[src]; return; } try { var txt = decodeURIComponent(src.slice(src.indexOf(',') + 1)); var svg = new DOMParser().parseFromString(txt, 'image/svg+xml').documentElement; var vb = (svg.getAttribute('viewBox') || '').split(/[\s,]+/).map(Number); if (vb.length !== 4 || !(vb[2] > 0) || vb[2] !== vb[3]) { stPixCache[src] = src; return; } var N = 256; svg.setAttribute('width', N); svg.setAttribute('height', N); var im = new Image(); im.onload = function () { try { var c = document.createElement('canvas'); c.width = c.height = N; var x = c.getContext('2d'); x.drawImage(im, 0, 0, N, N); var px = x.getImageData(0, 0, N, N).data, x0 = N, y0 = N, x1 = -1, y1 = -1; for (var i = 0; i < N * N; i++) if (px[i * 4 + 3] > 8) { var yy = Math.floor(i / N), xx = i % N; if (xx < x0) x0 = xx; if (xx > x1) x1 = xx; if (yy < y0) y0 = yy; if (yy > y1) y1 = yy; } if (x1 < 0) { stPixCache[src] = src; return; } var k = vb[2] / N, w = (x1 - x0 + 1) * k, h = (y1 - y0 + 1) * k; var side = Math.max(w, h) * 1.06, cx = vb[0] + (x0 + x1 + 1) / 2 * k, cy = vb[1] + (y0 + y1 + 1) / 2 * k; svg.setAttribute('viewBox', [cx - side / 2, cy - side / 2, side, side].map(function (n) { return Math.round(n * 100) / 100; }).join(' ')); svg.removeAttribute('width'); svg.removeAttribute('height'); var out = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(new XMLSerializer().serializeToString(svg)); stPixCache[src] = out; stFitStore.set('p' + src, out); Array.prototype.forEach.call(root.querySelectorAll('img'), function (o) { if (o.getAttribute('src') === src) o.src = out; }); } catch (e) { stPixCache[src] = src; } }; im.src = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(new XMLSerializer().serializeToString(svg)); } catch (e) { stPixCache[src] = src; } }); } function stCopy(text, ok) { try { if (typeof GM_setClipboard === 'function') { GM_setClipboard(text, 'text'); ok(true); return; } } catch (e) { /* fall back */ } try { navigator.clipboard.writeText(text).then(function () { ok(true); }, function () { ok(false); }); } catch (e) { ok(false); } } // What runs the bundle, the same facts a script's log starts with (mbuStartupInfo): manager, browser, site function stEnvLines() { var out = [], g = null; try { g = (typeof GM_info !== 'undefined' && GM_info) || null; } catch (e) { /* no GM_info */ } var p = (g && g.platform) || {}; if (g && g.scriptHandler) out.push(['Manager', g.scriptHandler + (g.version ? ' ' + g.version : '')]); if (p.browserName) out.push(['Browser', p.browserName + (p.browserVersion ? ' ' + p.browserVersion : '') + (p.os ? ' (' + p.os + ')' : '')]); else { try { out.push(['Browser', navigator.userAgent]); } catch (e) { /* no navigator */ } } try { var site = location.hostname; if (/(^|\.)musicbrainz\.(org|eu)$/i.test(site)) site += ', in ' + ((document.documentElement && document.documentElement.lang) || ((document.cookie.match(/(?:^|;\s*)lang=([^;]+)/) || [])[1]) || 'en'); out.push(['Site', site]); } catch (e) { /* no location */ } return out; } // The versions to paste into an issue as Markdown. // The channel String Theory was installed from: the install address when the manager tells it, else the // channel whose version About last read is this one, else the branch a test build was made on. var stRemote = {}; function stChannel() { var g = null; try { g = (typeof GM_info !== 'undefined' && GM_info) || null; } catch (e) { /* no GM_info */ } var sc = (g && g.script) || {}, urls = [g && g.scriptUpdateURL, sc.updateURL, sc.downloadURL, g && g.scriptURL, sc.fileURL]; for (var i = 0; i < urls.length; i++) { var u = typeof urls[i] === 'string' ? urls[i] : '', m; if ((m = /\/refs\/heads\/([^/]+)\//.exec(u)) || (m = /\/raw\/(?!refs\/)([^/]+)\/userscripts\//.exec(u))) { return m[1] === 'main' ? 'Latest' : m[1] === 'stable' ? 'Stable' : /^[0-9a-f]{7,40}$/.test(m[1]) ? 'pinned ' + m[1].slice(0, 8) : 'branch ' + m[1]; } } if (ST_BRANCH) return 'branch ' + ST_BRANCH; if (stRemote.stable === ST_VERSION) return 'Stable'; if (stRemote.main === ST_VERSION) return 'Latest'; return ''; } function stVersionsText() { var off = __stReadOff(), ch = stChannel(); // A details section keeps a long list from taking over the issue; Markdown doesn't render inside var lines = ['
', 'String Theory v' + ST_VERSION + '' + (ch ? ' (' + ch + ')' : '') + '\n']; stMembers.forEach(function (m) { lines.push('- [' + (off.indexOf(m[0]) < 0 ? 'x' : ' ') + '] ' + m[1] + ' `v' + m[2] + '`'); }); lines.push(''); stEnvLines().forEach(function (e) { lines.push('**' + e[0] + ':** ' + e[1] + ' '); }); lines[lines.length - 1] = lines[lines.length - 1].replace(/ {2}$/, ''); lines.push('', '
'); return lines.join('\n'); } var ST_CSS = '' + '#st-cfg{width:min(620px,94vw);padding:14px 16px;box-sizing:border-box;overflow:auto;font:13px/1.4 var(--mbu-font);outline:none}' + '#st-cfg .st-sec{margin:0 0 14px}#st-cfg .st-sec:last-child{margin:0}' + '#st-cfg .st-nav{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:0 0 10px;border-bottom:1px solid var(--mbu-border)}' + '#st-cfg .st-tabs{display:flex;gap:2px}' + '#st-cfg .st-tabs button{font:inherit;font-size:12px;font-weight:600;margin:0 0 -1px;padding:5px 12px;border:1px solid transparent;border-bottom:0;border-radius:var(--mbu-radius) var(--mbu-radius) 0 0;background:none;color:var(--mbu-text-dim);cursor:pointer}' + '#st-cfg .st-tabs button:hover{color:inherit}' + '#st-cfg .st-tabs button[aria-selected=true]{color:inherit;background:var(--mbu-bg);border-color:var(--mbu-border)}' + '#st-cfg h3{margin:0 0 4px;padding:0;border:0;background:none;font:600 11px/1.4 var(--mbu-font);text-transform:uppercase;letter-spacing:.06em;color:var(--mbu-text-weak)}' + '#st-cfg .st-row{display:flex;align-items:center;gap:8px;min-height:28px;margin:0;font-weight:400}' + '#st-cfg .st-row>label:first-child{flex:0 0 64px}' + '#st-cfg #st-p-s .st-row{flex-wrap:wrap;margin:7px 0}#st-cfg #st-p-s .st-row>label{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;flex:0 0 auto}#st-cfg #st-sync-status{color:var(--mbu-text-weak);overflow-wrap:anywhere}' + '#st-cfg #st-sync-backups{max-height:220px;overflow:auto}#st-cfg #st-sync-backups .st-row{padding:5px 0;border-bottom:1px solid var(--mbu-border)}#st-cfg #st-sync-backup-status{color:var(--mbu-text-weak)}' + '#st-cfg #st-p-s .st-sync-between{justify-content:space-between}#st-cfg #st-p-s .st-sync-group{border-top:1px solid var(--mbu-border);margin-top:18px;padding-top:12px}#st-cfg #st-p-s h3{font:600 13px/1.4 var(--mbu-font);text-transform:none;letter-spacing:0;color:var(--mbu-text);margin:0}' + '#st-cfg #st-p-s details{margin-top:14px}#st-cfg #st-p-s summary{cursor:pointer;color:var(--mbu-text-dim)}#st-cfg #st-p-s .st-sync-backup-row>span:first-child{flex:1}#st-cfg #st-p-s .st-sync-link{border:0;background:none;color:var(--mbu-accent-text);padding-inline:0}#st-cfg #st-p-s .st-sync-primary{color:var(--mbu-accent-text);font-weight:600}#st-cfg #st-p-s .st-sync-footer{justify-content:flex-end}#st-cfg #st-sync-status{margin:6px 0}#st-cfg #st-sync-last{font-size:11px}' + '#st-cfg #st-p-g .st-row>.st-lbl:first-child{flex:0 0 96px;white-space:nowrap}#st-cfg #st-p-g .st-lbl{white-space:nowrap}#st-cfg #st-p-g select{flex:0 1 150px;width:150px;min-width:0;height:26px}#st-cfg .st-time{box-sizing:border-box;width:60px;height:26px;padding:0 6px;text-align:center;font:inherit;color:inherit;background:var(--mbu-bg);border:1px solid var(--mbu-border);border-radius:15px}' + '#st-cfg label.st-row{cursor:pointer}#st-cfg label.st-row input{margin:0}' + '#st-cfg-news{white-space:nowrap}' + '#st-cfg .st-ver{margin-left:auto;color:var(--mbu-text-weak);font-size:11px;white-space:nowrap}' + '#st-cfg .st-note{flex:1 1 auto;color:var(--mbu-text-dim);font-size:12px}' + '#st-cfg .st-b{flex:0 0 auto;font:inherit;font-size:12px;padding:3px 10px;border:1px solid var(--mbu-border);border-radius:var(--mbu-radius);cursor:pointer}' + '#st-cfg .st-b:hover{background:var(--mbu-bg-hover)}#st-cfg .st-b:disabled{opacity:.6;cursor:default}' + '#st-cfg a{color:var(--mbu-accent-text)}' + '#st-cfg .st-upd{margin:4px 0 12px;padding:6px 10px;border-radius:var(--mbu-radius);background:var(--mbu-bg-sunken);font-size:12px}' + '#st-cfg .st-upd>div{display:flex;align-items:center;gap:8px;min-height:24px}#st-cfg .st-upd b{flex:0 0 auto;min-width:64px;font-weight:600;white-space:nowrap}#st-cfg .st-upd span{white-space:nowrap}' + '#st-cfg .st-upd .st-newer{color:var(--mbu-ok);font-weight:600}#st-cfg .st-upd>div.st-upd-new{background:color-mix(in srgb,var(--mbu-ok) 14%,transparent);border-radius:var(--mbu-radius);margin:0 -6px;padding:0 6px}#st-cfg .st-upd>div.st-upd-new>span:first-of-type{color:var(--mbu-ok);font-weight:600}' + '#st-cfg #st-tc-open{cursor:pointer}' + '#st-cfg .st-lbl{flex:0 0 auto;color:var(--mbu-text-weak)!important;font:600 11px/1.4 var(--mbu-font, system-ui, sans-serif);text-transform:uppercase;letter-spacing:.06em}' + '#st-cfg .st-seg{display:inline-flex;border:1px solid var(--mbu-border);border-radius:var(--mbu-radius);overflow:hidden;margin-right:10px}' + '#st-cfg .st-seg button{font:inherit;font-size:12px;border:0;margin:0;border-radius:0;background:none;color:inherit;padding:2px 10px;min-height:22px;line-height:18px;cursor:pointer}' + '#st-cfg .st-seg button+button{border-left:1px solid var(--mbu-border)}#st-cfg .st-seg button:hover{background:var(--mbu-bg-hover)}' + '#st-cfg .st-seg button[aria-checked=true]{background:var(--mbu-accent-soft);color:var(--mbu-accent-text)}' + '#st-cfg .st-step{display:inline-flex;align-items:center;border:1px solid var(--mbu-border);border-radius:var(--mbu-radius)}' + '#st-cfg .st-step button{font:inherit;font-size:15px;line-height:1;border:0!important;margin:0!important;padding:0!important;border-radius:0!important;background:none!important;color:inherit;box-sizing:border-box;flex:0 0 28px;width:28px!important;min-width:28px!important;height:22px!important;display:inline-flex;align-items:center;justify-content:center;cursor:pointer}' + '#st-cfg .st-step button:hover:not(:disabled){background:var(--mbu-bg-hover)!important}#st-cfg .st-step button:disabled{opacity:.4;cursor:default}' + '#st-cfg .st-step output{min-width:50px;text-align:center;font-variant-numeric:tabular-nums}' + '#st-cfg .st-strip{display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding:4px 6px;margin:2px 0;border:1px dashed var(--mbu-border);border-radius:var(--mbu-radius);touch-action:none;min-height:24px}' + '#st-cfg .st-di{display:grid;place-items:center;flex:0 0 auto;width:28px;height:28px;border-radius:50%;cursor:grab;user-select:none}' + '#st-cfg .st-di>img,#st-cfg .st-di>svg{width:100%;height:100%;display:block;pointer-events:none}' + '#st-cfg .st-di.st-drag{outline:2px solid var(--mbu-accent);outline-offset:2px;cursor:grabbing}' + '#st-cfg .st-cap{color:var(--mbu-text-dim);font-size:12px}' + '#st-cfg .st-links{display:flex;gap:14px;margin-left:auto;white-space:nowrap}' + '#st-cfg .st-scripts{display:grid;grid-template-columns:1fr 1fr;column-gap:40px}#st-cfg .st-scripts .st-row{min-height:24px;gap:6px;white-space:nowrap}' + '#st-cfg .st-si{flex:0 0 18px;width:18px;height:18px;display:grid;place-items:center}#st-cfg .st-si>img,#st-cfg .st-si>svg{width:100%;height:100%;display:block}' + '#st-cfg h3.st-h{margin:10px 0 4px;padding:0 0 3px;border-bottom:1px solid var(--mbu-border);font:700 14px/1.3 var(--mbu-font);text-transform:none;letter-spacing:0;color:var(--mbu-text)!important}#st-cfg h3.st-h:first-child{margin-top:2px}' + '#st-cfg .st-key{min-width:96px;font-variant-numeric:tabular-nums}#st-cfg .st-key[data-rec]{border-color:var(--mbu-accent);color:var(--mbu-accent-text)}' + '#st-cfg [hidden]{display:none!important}' // one size for the window: the tabs share a cell, and the one not shown keeps its room, as do Time's and Sun's extras + '#st-cfg .st-panes,#st-cfg .st-th-x{display:grid}#st-cfg .st-panes>.st-sec,#st-cfg .st-th-x>*{grid-area:1/1;margin:0}#st-cfg .st-th-x{display:inline-grid;align-items:center}#st-cfg .st-tx{display:inline-flex;align-items:center;gap:6px}' + '#st-cfg .st-panes>.st-sec[hidden]{display:block!important;visibility:hidden}' + '#st-cfg-ov{background:none;pointer-events:none}#st-cfg-ov>#st-cfg{pointer-events:auto}' // a phone: the whole screen, one column, each label above its control (majkinetor) + '@media (max-width:640px){#st-cfg{position:fixed!important;inset:0!important;width:auto!important;max-width:none!important;height:auto!important;max-height:none!important;margin:0!important;border-radius:0!important;transform:none!important;padding:12px 14px calc(16px + env(safe-area-inset-bottom,0px))!important;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain}' + '#st-cfg *{min-width:0;max-width:100%}#st-cfg .st-row{flex-wrap:wrap;row-gap:4px;height:auto;margin:6px 0}' + '#st-cfg .st-row>.st-lbl,#st-cfg #st-p-g .st-row>.st-lbl:first-child{flex:1 0 100%;white-space:normal;margin-top:4px}' + '#st-cfg .st-seg{flex-wrap:wrap;margin-right:6px}#st-cfg .st-seg button{min-height:32px;padding:4px 12px}' + '#st-cfg .st-step button{height:32px!important;width:36px!important;flex-basis:36px}' + '#st-cfg #st-p-g select{flex:1 1 auto;width:auto;height:32px}' + '#st-cfg .st-scripts{grid-template-columns:1fr}#st-cfg .st-scripts .st-row{white-space:normal}' + '#st-cfg .st-nav{row-gap:4px}#st-cfg .st-links{margin-left:0}#st-cfg .st-ver{white-space:normal}' + '#st-cfg .st-cap,#st-cfg .st-note,#st-cfg .st-upd span,#st-cfg .st-lbl,#st-cfg #st-p-g .st-lbl{white-space:normal;overflow-wrap:anywhere}#st-cfg .st-upd>div{flex-wrap:wrap}' + '#st-cfg .st-di{width:36px;height:36px}#st-cfg .st-strip{gap:10px}#st-cfg .mbu-cfg-h{flex-wrap:wrap;row-gap:4px;cursor:default}}'; ST_CSS += '#st-cfg h3.st-about-h{font:600 13px/1.4 var(--mbu-font);text-transform:none;letter-spacing:0;color:var(--mbu-text);margin:0 0 12px}#st-cfg #st-p-s .st-row:has(>#st-sync-backup-status:empty){display:none}'; ST_CSS +='#st-cfg{width:min(760px,94vw);container-type:inline-size}#st-cfg .st-panes{display:block}#st-cfg .st-panes>.st-sec[hidden]{display:none!important}#st-cfg .st-title{flex-wrap:nowrap!important;white-space:nowrap;gap:12px}#st-cfg .st-title .mbu-cfg-name{flex-shrink:0}#st-cfg .st-title .mbu-cfg-sp,#st-cfg .st-title .mbu-cfg-ver{display:none}#st-cfg .st-title .st-tabs{margin-left:auto;flex-shrink:0}#st-cfg .st-title .st-tabs button{border:0;border-bottom:2px solid transparent;background:none;border-radius:0;margin:0;padding:5px 0;color:var(--mbu-text-dim)}#st-cfg .st-title .st-tabs{gap:18px}#st-cfg .st-title .st-tabs button[aria-selected=true]{border-bottom-color:var(--mbu-accent);color:var(--mbu-accent-text)}#st-cfg .st-title #st-tab-menu{margin-left:auto;width:100px;flex-shrink:0}#st-cfg .st-title .mbu-ov-x{margin-left:0}' + '#st-cfg .st-footer{display:flex;flex-wrap:wrap;align-items:center;gap:18px;margin-top:20px;padding-top:12px;border-top:1px solid var(--mbu-border)}#st-cfg .st-footer .st-links{margin-left:0}#st-cfg .st-footer #st-cfg-news{margin-right:0}#st-cfg .st-footer .mbu-help{margin-left:auto}#st-cfg .st-group{margin:0;padding:12px 0 18px}#st-cfg .st-group+.st-group{border-top:1px solid var(--mbu-border);padding-top:18px}#st-cfg .st-group>h3.st-h{border:0;margin:0 0 12px;padding:0;font-size:13px}#st-cfg .st-lbl{font:inherit!important;letter-spacing:0;text-transform:none;color:var(--mbu-text)!important}#st-cfg .st-field-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:8px 28px}#st-cfg .st-field{display:grid;grid-template-columns:100px minmax(0,180px);align-items:center;gap:10px;min-width:0}#st-cfg .st-field select{width:100%;max-width:180px}#st-cfg .st-field .st-seg{justify-self:start}#st-cfg .st-mode-label{display:none}#st-cfg .st-seg{border:0;gap:14px;border-radius:0;margin:0;overflow:visible}#st-cfg .st-seg button{border:0!important;border-bottom:2px solid transparent!important;border-radius:0;padding:4px 0;background:none;color:var(--mbu-text-dim)}#st-cfg .st-seg button[aria-checked=true]{background:none;border-bottom-color:var(--mbu-accent)!important;color:var(--mbu-accent-text)}#st-cfg .st-step{border:0;border-radius:0}#st-cfg .st-key{justify-self:start;border:0;border-bottom:1px solid var(--mbu-border);border-radius:0;background:none}#st-cfg .st-strip{border:0;padding:0;margin:12px 0 6px;gap:10px}#st-cfg .st-th-x{display:block}#st-cfg .st-th-x:has(.st-tx[hidden]):has(.st-cap[hidden]){display:none}' + '#st-cfg #st-p-s .st-sync-between{justify-content:flex-start;gap:20px}#st-cfg #st-p-s .st-sync-backup-row>span:first-child{flex:0 0 100px}#st-cfg #st-p-s .st-sync-footer{display:none}#st-cfg #st-p-s .st-sync-group{margin-top:18px;padding-top:16px}#st-cfg .st-upd{background:none;padding:0;margin:0 0 20px}#st-cfg .st-upd>div{display:grid;grid-template-columns:70px minmax(0,max-content) minmax(0,max-content) auto;gap:12px;margin:10px 0}#st-cfg .st-upd b{min-width:0}#st-cfg .st-upd-links{display:flex;gap:12px;white-space:nowrap}#st-cfg .st-upd span{white-space:normal}#st-cfg .st-scripts{grid-template-columns:minmax(0,1fr);gap:4px 28px}#st-cfg .st-scripts .st-row{white-space:normal}#st-cfg .st-ver{font-size:11px}#st-cfg .st-title [hidden]{display:none!important}@container(min-width:620px){#st-cfg .st-field-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}@container(min-width:520px){#st-cfg .st-scripts{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:640px){#st-cfg .st-title{gap:8px}#st-cfg .st-title .mbu-cfg-name{font-size:14px}#st-cfg .st-title .st-tabs{gap:12px}#st-cfg .st-title .st-tabs button{font-size:12px;min-height:30px}#st-cfg #st-p-g .st-field select{width:100%;height:30px}#st-cfg .st-field .st-lbl{margin:0}#st-cfg .st-upd>div{grid-template-columns:62px minmax(0,1fr) auto}#st-cfg .st-upd .st-channel-state{display:none}#st-cfg .st-seg button{padding:6px 0;min-height:30px}}'; ST_CSS += '#st-cfg .st-th-x{margin-inline-start:18px}#st-cfg #st-th-time{font:400 12px/18px var(--mbu-font);gap:8px;min-height:28px}#st-cfg #st-th-time .st-time{font:inherit;height:28px}#st-cfg .st-panes{display:grid}#st-cfg .st-panes>.st-sec{grid-area:1/1}#st-cfg .st-panes>.st-sec[hidden]{display:block!important;visibility:hidden}'; ST_CSS += '#st-cfg .st-idle-opts{gap:18px}#st-cfg .st-idle-opts label{display:inline-flex;align-items:center;gap:6px;cursor:pointer;white-space:nowrap}#st-cfg .st-idle-opts input{margin:0}#st-cfg .st-idle-opts label:has(:disabled){opacity:.45;cursor:default}'; ST_CSS += '#st-cfg{font-size:12px;padding:12px 14px}#st-cfg .st-title{gap:8px;margin-bottom:8px}#st-cfg .st-title .mbu-cfg-ver{display:inline}#st-cfg .st-title .mbu-cfg-name{font-size:inherit}#st-cfg .st-title .mbu-help{margin-left:0}#st-cfg .st-title .st-tabs{gap:14px}#st-cfg .st-group{padding:8px 0 12px}#st-cfg .st-group+.st-group{padding-top:12px}#st-cfg .st-group>h3.st-h,#st-cfg h3.st-about-h{margin-bottom:8px}#st-cfg .st-field-grid{gap:4px 22px}#st-cfg .st-field{grid-template-columns:88px minmax(0,160px);gap:8px}#st-cfg .st-row{min-height:24px}#st-cfg .st-group>.st-row{margin:0}#st-cfg .st-strip{margin:8px 0 4px}#st-cfg .st-cap{font-size:11px}#st-cfg .st-footer{margin-top:12px;padding-top:8px;gap:14px}#st-cfg .st-upd{margin:0 0 12px;font-size:11px}#st-cfg .st-upd>div{grid-template-columns:58px minmax(0,max-content) minmax(0,max-content) auto;min-height:20px;margin:3px 0;gap:8px}#st-cfg .st-scripts{gap:0 22px}#st-cfg .st-scripts .st-row{min-height:22px}#st-cfg .st-ver{font-size:10px}#st-cfg #st-p-s .st-row{margin:4px 0;min-height:24px}#st-cfg #st-p-s .st-sync-group{margin-top:12px;padding-top:10px}#st-cfg #st-p-s details{margin-top:10px}#st-cfg #st-sync-status{margin:4px 0}#st-cfg #st-p-s .st-sync-backup-row>span:first-child{flex-basis:88px}#st-cfg #st-th-time{font:400 12px/18px var(--mbu-font)}#st-cfg .st-upd .st-channel-state{overflow-wrap:anywhere}@media(max-width:640px){#st-cfg .st-upd>div{grid-template-columns:58px minmax(0,1fr) auto}#st-cfg .st-row{margin:4px 0}#st-cfg .st-title{gap:6px}}'; ST_CSS += '#st-cfg .st-sync-columns{display:grid;grid-template-columns:minmax(0,1fr);gap:12px 28px}#st-cfg #st-p-s .st-sync-options>h3{margin:4px 0 8px}@container(min-width:620px){#st-cfg .st-sync-columns{grid-template-columns:repeat(2,minmax(0,1fr))}}'; ST_CSS += '#st-cfg .st-title .mbu-ov-x{padding:0;margin:0;align-self:center;width:26px;height:26px}#st-cfg .st-title .mbu-ov-x svg{width:18px;height:18px;display:block}#st-cfg .st-title .mbu-help{align-self:center}'; ST_CSS += '#st-cfg .st-footer .st-links{margin-left:auto}'; ST_CSS += '#st-cfg .st-section-lead{display:flex;align-items:center;gap:16px;margin:0 0 4px}#st-cfg .st-section-lead>h3.st-h,#st-cfg .st-palette-enabled>h3.st-h{flex:0 0 auto;border:0;margin:0;padding:0;font:600 13px/1.4 var(--mbu-font)}#st-cfg .st-section-lead>.st-row{flex:0 1 auto;min-width:0;margin:0;flex-wrap:wrap}#st-cfg .st-inline-side,#st-cfg .st-palette-enabled{display:flex;align-items:center;gap:12px;min-height:28px}#st-cfg .st-inline-side .st-lbl{margin:0}#st-cfg .st-section-lead .st-seg{flex-wrap:wrap}#st-cfg .st-palette-enabled>h3.st-h{font-size:12px}#st-cfg .st-group:has(.st-palette-enabled)>.st-field-grid{margin-top:0}'; ST_CSS += '#st-cfg .st-section-lead{align-items:flex-start}#st-cfg .st-section-lead>h3.st-h{margin-top:5px}#st-cfg .st-section-lead>.st-inline-side+.st-inline-side{margin-inline-start:18px}'; ST_CSS += '#st-cfg{background:var(--mbu-bg)!important}'; // a button pair wraps as one, never one button left behind; on a phone Time's hours get their own line under Theme ST_CSS += '#st-cfg #st-p-s .st-sync-acts{display:inline-flex;flex-wrap:wrap;align-items:center;gap:inherit}' + '@media (max-width:640px){#st-cfg .st-section-lead{flex-wrap:wrap;row-gap:4px}#st-cfg .st-section-lead>.st-row{display:contents}#st-cfg .st-section-lead .st-th-x{flex:1 0 100%;margin:0}#st-cfg #st-p-s .st-sync-between{row-gap:6px}}'; ST_CSS += '#st-cfg #st-p-s{position:relative}#st-cfg .st-backup-columns{display:grid;grid-template-columns:minmax(0,1fr);gap:4px 28px}#st-cfg .st-sync-spinner{display:inline-block;box-sizing:border-box;width:12px;height:12px;margin-left:8px;vertical-align:middle;border:1.5px solid var(--mbu-text-weak);border-right-color:transparent;border-radius:50%;animation:st-sync-spin .8s linear infinite}#st-cfg #st-sync-remote{position:absolute;inset:0;z-index:2;background:var(--mbu-bg);padding:0;display:flex;flex-direction:column;min-height:0}#st-cfg .st-backup-head{display:flex;align-items:center;gap:10px;padding:0 0 8px;border-bottom:1px solid var(--mbu-border)}#st-cfg .st-backup-head h3{margin:0}#st-cfg #st-sync-backups{display:flex;flex:1;flex-direction:column;min-height:0;max-height:none;overflow:hidden;padding-top:6px}#st-cfg .st-backup-choices{flex:1;min-height:0;overflow:auto}#st-cfg .st-backup-choice{display:flex;align-items:center;gap:12px;justify-content:space-between;width:100%;border:0;border-radius:0;background:none;color:var(--mbu-text);font:inherit;text-align:left;padding:7px 8px;cursor:pointer}#st-cfg .st-backup-choice small{color:var(--mbu-text-weak);font-size:11px}#st-cfg .st-backup-choice[aria-pressed=true]{background:var(--mbu-accent-soft);color:var(--mbu-accent-text)}#st-cfg .st-backup-actions{display:flex;gap:8px;flex-wrap:wrap;padding-top:8px;margin-top:4px;border-top:1px solid var(--mbu-border)}@container(min-width:620px){#st-cfg .st-backup-columns{grid-template-columns:repeat(2,minmax(0,1fr))}}@keyframes st-sync-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){#st-cfg .st-sync-spinner{animation:none}}'; ST_CSS += '#st-cfg .st-backup-head{flex-wrap:wrap;gap:8px}#st-cfg .st-backup-head h3{margin-right:auto}#st-cfg .st-backup-head .st-backup-actions{margin:0;padding:0;border:0;gap:6px}#st-cfg .st-backup-choices{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,240px),1fr));align-content:start;gap:3px 12px}#st-cfg .st-backup-choice{min-width:0}'; ST_CSS += '#st-cfg #st-sync-backup-actions{margin:0 0 0 auto}'; ST_CSS += '#st-cfg #st-sync-dav input{flex:1 1 140px;min-width:0;height:26px;box-sizing:border-box;padding:0 8px;border:1px solid var(--mbu-border);border-radius:4px;background:var(--mbu-bg);color:var(--mbu-text);font:inherit}#st-cfg #st-sync-dav #st-sync-dav-url{flex-basis:100%}'; // a launcher opens its script's settings on right-click: pass the click on to the live one function stLive(name) { var els = Array.prototype.filter.call(document.querySelectorAll('[data-mb-corner="br"][data-mb-corner-label]'), function (el) { return el.id !== 'mbu-dock' && el.dataset.mbCornerLabel === name; }); return els.filter(function (el) { return el.dataset.mbuDocked !== 'off'; })[0] || els[0] || null; } // On any page: the script opens them itself when it runs here (mbu-open-settings), else its launcher's // right-click does, else String Theory starts it only to open its settings, off or not on this page. // toFront(false) puts String Theory's window behind them; false back means the script has none. function stOpenFor(name, toFront) { toFront = toFront || function () {}; var m = stMembers.filter(function (x) { return x[1] === name; })[0], folder = m ? m[0] : name, el = stLive(name); toFront(false); if (!document.dispatchEvent(new CustomEvent('mbu-open-settings', { detail: folder, cancelable: true }))) return true; if (el) { el.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, cancelable: true, button: 2 })); return true; } var st = __stStarters[folder]; if (st && st.so && !st.soStarted()) { st.go(); return true; } toFront(true); try { stUI().mbuToast('⚠ ' + name + ' has no settings'); } catch (err) { /* no toast */ } return false; } // tab: 'g' General, 'a' About (MusicBrainz only; elsewhere there is only About); 'l' is General's Dock section function stSettings(tab) { var dock = tab === 'l'; if (dock) tab = 'g'; var toDock = function () { var d = ST_ON_MB && stCfgOv && stCfgOv.querySelector('#st-dock'); if (dock && d) d.scrollIntoView({ block: 'start' }); }; if (stCfgOv && stCfgOv.isConnected) { if (tab && stCfgOv.querySelector('#st-tab-' + tab)) stCfgOv.querySelector('#st-tab-' + tab).click(); stCfgOv.querySelector('#st-cfg').focus(); toDock(); return; } var U = stUI(), T = stTokens(), html = document.documentElement; // Event Horizon's effect presets, when it's on and has any: each theme can bring one var ehFx = __stReadOff().indexOf('event_horizon') < 0 && mbuShared('ehFxPresets') || []; ehFx = Array.isArray(ehFx) ? ehFx.slice().sort(function (a, b) { return a.localeCompare(b, undefined, { sensitivity: 'base', numeric: true }); }) : []; if (!document.getElementById('st-cfg-css')) { var css = document.createElement('style'); css.id = 'st-cfg-css'; css.textContent = T.MBU_TOKENS + U.MBU_UI_CSS + ST_CSS; (document.head || html).appendChild(css); } var h = U.mbuCfgHeader({ icon: '', name: 'String Theory', version: ST_VERSION, script: 'string_theory' }); if (ST_ON_MB) h = h.replace('', 'What\'s newGate log'); var links = '' + 'Website' + 'Issues' + 'Forum'; if (ST_ON_MB) { var seg = function (id, label, opts) { return '' + label + '' + opts.map(function (o) { return ''; }).join('') + ''; }; h += '
' + '' + '
' + links + '
' + '
' + '

Theme

' + '
' + seg('st-th-mode', 'Mode', [['light', 'Light'], ['dark', 'Dark'], ['auto', 'System'], ['sun', 'Sun'], ['time', 'Time']]) + '' + 'Asks for your location once
' + '
' + ['light', 'dark'].map(function (v) { return ''; }).join('') + '
' + (ehFx.length ? '
' + ['light', 'dark'].map(function (v) { return ''; }).join('') + '
' : '') + '

Idle

' + '
' + seg('st-idle-on', 'Idle', [['on', 'On'], ['off', 'Off']]) + '
' + '
' + (ehFx.length ? '' : '') + '
' + '
' + '

Dock

' + '
' + seg('st-side', 'Side', [['left', 'Left'], ['right', 'Right']]) + seg('st-flow', 'Orientation', [['column', 'Column'], ['row', 'Row']]) + 'Size' + '
' + '
' + seg('st-hover', 'Hover', [['none', 'None'], ['shelf', 'Shelf']]) + '
' + '
' + seg('st-count', 'Counter', [['pill', 'Pill'], ['seg', 'Segmented'], ['bare', 'Bare']]) + seg('st-count-pos', 'Position', [['on', 'On icon'], ['side', 'Beside']]) + '
' + '
' + '
Drag to reorder, the first nearest the corner; right-click for its settings.
' + '

Command palette

' + '
' + seg('st-pal-on', 'Palette', [['on', 'On'], ['off', 'Off']]) + 'Hotkey
' + '
'; h += ''; } var off = __stReadOff(), known = mbuShared('dockKnown') || {}; h += '
' + (ST_ON_MB ? '' : '
' + links + '
') + '

Updates

' + '

Scripts

' + stMembers.map(function (m) { var icon = m[3] ? '' : known[m[1]] || ''; return ''; }).join('') + '
' + '
A change applies from the next page load.' + '
' + '
' + (ST_ON_MB ? '
' : ''); var ov = document.createElement('div'); ov.className = 'mbu-ov'; ov.id = 'st-cfg-ov'; ov.innerHTML = ''; (document.body || html).appendChild(ov); stCfgOv = ov; var panel = ov.querySelector('#st-cfg'), q = function (s) { return panel.querySelector(s); }; // a phone: MusicBrainz's page is wider than the screen, so the browser's layout viewport (which a fixed // inset:0 window fills) is too, and the screen shows a panned part of it. Fit the window to what shows. var vv = window.visualViewport, narrow = window.matchMedia('(max-width:640px)'); var pin = function () { var on = vv && narrow.matches, s = panel.style; [['left', vv && vv.offsetLeft], ['top', vv && vv.offsetTop], ['width', vv && vv.width], ['height', vv && vv.height]].forEach(function (p) { if (on) s.setProperty(p[0], p[1] + 'px', 'important'); else s.removeProperty(p[0]); }); if (on) { s.setProperty('right', 'auto', 'important'); s.setProperty('bottom', 'auto', 'important'); } else { s.removeProperty('right'); s.removeProperty('bottom'); } }; // a theme that sets a transform or filter on the page makes the fixed window scroll with the page: // it is pinned back to the viewport when shown and on every scroll and resize var ovPin = function () { if (ov.style.display === 'none') return; try { var r = ov.getBoundingClientRect(), w = html.clientWidth, h = window.innerHeight; if (Math.abs(r.top) <= 1 && Math.abs(r.left) <= 1 && Math.abs(r.height - h) <= 1 && Math.abs(r.width - w) <= 1) return; var t0 = parseFloat(ov.style.top) || 0, l0 = parseFloat(ov.style.left) || 0; // read first: inset resets them ov.style.inset = 'auto'; ov.style.top = (t0 - r.top) + 'px'; ov.style.left = (l0 - r.left) + 'px'; ov.style.width = w + 'px'; ov.style.height = h + 'px'; } catch (e) {} }; var close = function () { removeEventListener('scroll', ovPin, true); removeEventListener('resize', ovPin); if (vv) { vv.removeEventListener('resize', pin); vv.removeEventListener('scroll', pin); } if (tabObserver) tabObserver.disconnect(); ov.remove(); document.removeEventListener('keydown', onKey, true); document.removeEventListener('mousedown', onOut, true); }; var newsLink = ov.querySelector('#st-cfg-news'); if (newsLink) newsLink.addEventListener('click', function (e) { e.preventDefault(); close(); stNewsOpen(); }); var gateLink = ov.querySelector('#st-cfg-gate'); if (gateLink) gateLink.addEventListener('click', function (e) { e.preventDefault(); close(); stGateOpen(); }); // #851: a script's settings opened from here sit above this window, which stays open; the one used last // is in front and takes Escape. A floating (position: fixed) element is taken for such a window. var front = true, toFront = function (on) { front = on; ov.style.zIndex = on ? '' : '9000'; }; // #851: behind every script's window, the lowest of which is 9990 var floating = function (t) { for (var n = t; n && n.nodeType === 1 && n !== ov; n = n.parentElement) if (getComputedStyle(n).position === 'fixed') return true; return false; }; var onKey = function (e) { if (e.key !== 'Escape') return; var backups = q('#st-sync-remote'); if (backups && !backups.hidden && !q('#st-p-s').hidden) { e.preventDefault(); e.stopPropagation(); q('#st-sync-backup-close').click(); return; } if (!front) { toFront(true); return; } // the script's window closes first, this one on the next Escape e.stopPropagation(); close(); }; var onOut = function (e) { if (panel.contains(e.target)) { if (!front) toFront(true); return; } if (e.target.closest && e.target.closest('#mbu-toast')) return; if (floating(e.target)) { toFront(false); return; } close(); }; var tabObserver = null, refresh = function () {}; if (ST_ON_MB) { var title = q('.mbu-cfg-h'), tabs = q('.st-tabs'), footer = document.createElement('div'); title.classList.add('st-title'); footer.className = 'st-footer'; var news = q('#st-cfg-news'), help = title.querySelector('.mbu-help'), linksNode = q('.st-links'); if (news) footer.appendChild(news); if (linksNode) footer.appendChild(linksNode); panel.appendChild(footer); title.insertBefore(tabs, help); q('.st-nav').remove(); var menu = document.createElement('select'); menu.id = 'st-tab-menu'; menu.setAttribute('aria-label', 'Settings tab'); menu.hidden = true; menu.innerHTML = ''; title.insertBefore(menu, help); menu.onchange = function () { q('#st-tab-' + menu.value).click(); }; // a quiet way to the theme chooser beside the help, drawn like it; the window steps aside so the page shows each theme var themes = document.createElement('button'); themes.type = 'button'; themes.className = 'mbu-help'; themes.id = 'st-tc-open'; themes.setAttribute('aria-label', 'Theme chooser'); themes.dataset.tip = 'Theme chooser\nStep through every theme on this page'; themes.innerHTML = ''; themes.onclick = function () { close(); setTimeout(stThemeChooser, 0); }; title.insertBefore(themes, help); var x = title.querySelector('.mbu-cfg-x'); x.setAttribute('aria-label', 'Close settings'); x.onclick = close; var fitTabs = function () { var version = title.querySelector('.mbu-cfg-ver'), name = title.querySelector('.mbu-cfg-name'); tabs.hidden = false; menu.hidden = true; if (version) version.hidden = false; name.hidden = false; var measure = function () { var width = 0, children = Array.prototype.filter.call(title.children, function (n) { return getComputedStyle(n).display !== 'none'; }); children.forEach(function (n) { width += n.getBoundingClientRect().width; }); return width + Math.max(0, children.length - 1) * parseFloat(getComputedStyle(title).columnGap || 0) + 12; }; if (version && measure() > title.clientWidth) version.hidden = true; if (measure() > title.clientWidth) name.hidden = true; tabs.hidden = measure() > title.clientWidth; menu.hidden = !tabs.hidden; }; tabObserver = new ResizeObserver(fitTabs); tabObserver.observe(panel); var general = q('#st-p-g'); var pairRow = function (row) { var nodes = Array.prototype.slice.call(row.children); row.classList.add('st-field-grid'); row.classList.remove('st-row'); for (var i = 0; i + 1 < nodes.length; i += 2) { var f = document.createElement('div'); f.className = 'st-field'; f.appendChild(nodes[i]); f.appendChild(nodes[i + 1]); row.appendChild(f); } }; q('#st-th-mode-l').classList.add('st-mode-label'); pairRow(q('#st-th-light').parentElement); pairRow(q('#st-side').parentElement); pairRow(q('#st-hover').parentElement); pairRow(q('#st-count').parentElement); pairRow(q('#st-pal-on').parentElement); pairRow(q('#st-idle-on').parentElement); pairRow(q('#st-idle-theme').parentElement); if (ehFx.length) { var ehRow = q('#st-th-eh-light').parentElement, thGrid = q('#st-th-light').closest('.st-field-grid'); pairRow(ehRow); while (ehRow.firstChild) thGrid.appendChild(ehRow.firstChild); ehRow.remove(); } var dockGrid = q('#st-side').closest('.st-field-grid'), hoverGrid = q('#st-hover').closest('.st-field-grid'); while (hoverGrid.firstChild) dockGrid.appendChild(hoverGrid.firstChild); hoverGrid.remove(); var countGrid = q('#st-count').closest('.st-field-grid'); while (countGrid.firstChild) dockGrid.appendChild(countGrid.firstChild); countGrid.remove(); var sections = [], active = null; Array.prototype.slice.call(general.children).forEach(function (n) { if (n.tagName === 'H3') { active = document.createElement('section'); active.className = 'st-group'; sections.push(active); } if (active) active.appendChild(n); }); sections.forEach(function (n) { general.appendChild(n); }); // Let the first control share its section's heading row, keeping Hotkey in the second field. var inlineLead = function (section, control) { var heading = section.querySelector('h3'), lead = document.createElement('div'); lead.className = 'st-section-lead'; section.insertBefore(lead, heading); lead.appendChild(heading); lead.appendChild(control); }; inlineLead(q('#st-th-mode').closest('.st-group'), q('#st-th-mode').parentElement); var sideField = q('#st-side').closest('.st-field'); sideField.classList.add('st-inline-side'); inlineLead(sideField.closest('.st-group'), sideField); var flowField = q('#st-flow').closest('.st-field'); flowField.classList.add('st-inline-side'); sideField.parentElement.appendChild(flowField); var paletteField = q('#st-pal-on').closest('.st-field'), paletteHeading = paletteField.closest('.st-group').querySelector('h3'); paletteHeading.textContent = 'Palette'; paletteField.classList.add('st-palette-enabled'); q('#st-pal-on-l').classList.add('st-mode-label'); paletteField.insertBefore(paletteHeading, paletteField.firstChild); fitTabs(); } if (ST_ON_MB) q('.st-tabs').onclick = function (e) { var t = e.target.closest('[role=tab]'); if (!t) return; var enteringAbout = t.id === 'st-tab-a' && t.getAttribute('aria-selected') !== 'true'; Array.prototype.forEach.call(q('.st-tabs').children, function (b) { b.setAttribute('aria-selected', String(b === t)); q('#' + b.getAttribute('aria-controls')).hidden = b !== t; }); q('#st-tab-menu').value = t.id.slice(-1); try { localStorage.setItem('st-cfg-tab', t.id.slice(-1)); } catch (_) {} if (enteringAbout) checkUpdates(); if (t.id === 'st-tab-s') stSyncPaint(); }; var live = stLive, openFor = function (name) { stOpenFor(name, toFront); }; q('.st-scripts').addEventListener('contextmenu', function (e) { var r = e.target.closest('[data-name]'); if (!r) return; e.preventDefault(); openFor(r.dataset.name); }); if (ST_ON_MB) { stSyncBind(q('#st-p-s')); var restack = function () { ['br', 'bl', 'tr', 'tl'].forEach(function (c) { try { mbRestackCorner(c); } catch (e) { /* a corner's script broke */ } }); }; var size = function () { return Math.round((Number(mbuShared('cornerSize')) || 1) * 10) * 10; }; var show = function () { var pick = function (id, v) { Array.prototype.forEach.call(q(id).children, function (b) { b.setAttribute('aria-checked', String(b.dataset.v === v)); }); }; pick('#st-side', mbuShared('cornerSide') === 'left' ? 'left' : 'right'); pick('#st-flow', mbuShared('cornerFlow') === 'row' ? 'row' : 'column'); pick('#st-hover', mbuShared('dockHover') === 'shelf' ? 'shelf' : 'none'); pick('#st-count', mbuShared('dockCount') === 'seg' || mbuShared('dockCount') === 'bare' ? mbuShared('dockCount') : 'pill'); pick('#st-count-pos', mbuShared('dockCountPos') === 'side' ? 'side' : 'on'); var v = size(); q('#st-size').textContent = v + ' %'; q('#st-size-dn').disabled = v <= 60; q('#st-size-up').disabled = v >= 160; }; var segSet = function (key, alt) { return function (e) { var b = e.target.closest('button'); if (!b) return; // alt: the one value stored, or a list of them; any other is the default, stored as null mbuShared(key, [].concat(alt).indexOf(b.dataset.v) >= 0 ? b.dataset.v : null); restack(); show(); }; }; var showTheme = function () { var th = __stTheme.read(); Array.prototype.forEach.call(q('#st-th-mode').children, function (b) { b.setAttribute('aria-checked', String(b.dataset.v === th.mode)); }); q('#st-th-dark').value = th.dark; q('#st-th-light').value = th.light; // each theme's effect preset; one deleted in Event Horizon is already gone from the map if (ehFx.length) ['light', 'dark'].forEach(function (v) { var cur = th.eh[v + ':' + th[v]] || '', sel = q('#st-th-eh-' + v); sel.innerHTML = '' + ehFx.concat(cur && cur !== '-' && ehFx.indexOf(cur) < 0 ? [cur] : []).map(function (n) { return ''; }).join(''); sel.value = cur; }); q('#st-th-from').value = th.from; q('#st-th-to').value = th.to; q('#st-th-time').hidden = th.mode !== 'time'; q('#st-th-sun').hidden = th.mode !== 'sun'; }; q('#st-th-mode').onclick = function (e) { var b = e.target.closest('button'); if (!b) return; __stTheme.setMode(b.dataset.v, showTheme); showTheme(); }; ['dark', 'light'].forEach(function (v) { // the new theme brings the effect on show, as stepping in the theme chooser does, so a theme pick never changes it q('#st-th-' + v).onchange = function (e) { var th = __stTheme.read(), p = {}, on = th.eh[v + ':' + th[v]], map = {}; p[v] = e.target.value; if (ehFx.length) { Object.keys(th.eh).forEach(function (k) { map[k] = th.eh[k]; }); if (on) map[v + ':' + p[v]] = on; else delete map[v + ':' + p[v]]; p.eh = map; } __stTheme.set(p); showTheme(); }; if (ehFx.length) q('#st-th-eh-' + v).onchange = function (e) { var th = __stTheme.read(), map = {}; Object.keys(th.eh).forEach(function (k) { map[k] = th.eh[k]; }); if (e.target.value) map[v + ':' + th[v]] = e.target.value; else delete map[v + ':' + th[v]]; __stTheme.set({ eh: map }); }; }); ['from', 'to'].forEach(function (k) { // text, not type=time: that one shows AM/PM by the browser's locale q('#st-th-' + k).oninput = function (e) { var m = e.target.value.trim().match(/^([01]?\d|2[0-3]):([0-5]\d)$/); if (!m) return; var p = {}; p[k] = (m[1].length < 2 ? '0' : '') + m[1] + ':' + m[2]; __stTheme.set(p); }; q('#st-th-' + k).onchange = showTheme; // tidies what was typed, or restores it }); showTheme(); var showIdle = function () { var i = __stTheme.read().idle; Array.prototype.forEach.call(q('#st-idle-on').children, function (b) { b.setAttribute('aria-checked', String((b.dataset.v === 'on') === i.on)); }); q('#st-idle-minutes').value = i.minutes; q('#st-idle-theme').value = i.theme; if (q('#st-idle-effect')) q('#st-idle-effect').value = i.effect; q('#st-idle-info').checked = i.info; q('#st-idle-cont').checked = i.cont; q('#st-idle-cont').disabled = i.theme !== '*' && i.effect !== '*'; // only Random parts change }; function setIdle(k, v) { var i = __stTheme.read().idle; i[k] = v; __stTheme.set({ idle: i }); showIdle(); } q('#st-idle-on').onclick = function (e) { var b = e.target.closest('button'); if (b) setIdle('on', b.dataset.v === 'on'); }; q('#st-idle-minutes').onchange = function (e) { setIdle('minutes', Math.max(1, Math.min(1440, Math.round(Number(e.target.value) || 5)))); }; q('#st-idle-theme').onchange = function (e) { setIdle('theme', e.target.value); }; if (q('#st-idle-effect')) q('#st-idle-effect').onchange = function (e) { setIdle('effect', e.target.value); }; q('#st-idle-info').onchange = function (e) { setIdle('info', e.target.checked); }; q('#st-idle-cont').onchange = function (e) { setIdle('cont', e.target.checked); }; showIdle(); var showPal = function () { var p = stPalRead(); Array.prototype.forEach.call(q('#st-pal-on').children, function (b) { b.setAttribute('aria-checked', String(b.dataset.v === (p.on ? 'on' : 'off'))); }); var k = q('#st-pal-key'); k.removeAttribute('data-rec'); k.textContent = stKeyLabel(p.key); }; q('#st-pal-on').onclick = function (e) { var b = e.target.closest('button'); if (!b) return; stPalSet({ on: b.dataset.v === 'on' }); showPal(); }; // the next key pressed with it, modifiers held, is the hotkey; Escape keeps the old one q('#st-pal-key').onclick = function () { var k = q('#st-pal-key'); k.setAttribute('data-rec', ''); k.textContent = 'Press keys…'; var rec = function (e) { if (/^(Control|Alt|Shift|Meta|OS|AltGraph)$/.test(e.key)) return; e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); window.removeEventListener('keydown', rec, true); stPalRecording = false; if (e.key !== 'Escape') { var h = stKeyOf(e); if (!h.ctrl && !h.alt && !h.meta) { try { U.mbuToast('⚠ A hotkey needs Ctrl, Alt or Meta'); } catch (err) { /* no toast */ } } else stPalSet({ key: h }); } showPal(); }; stPalRecording = true; window.addEventListener('keydown', rec, true); }; showPal(); q('#st-side').onclick = segSet('cornerSide', 'left'); q('#st-flow').onclick = segSet('cornerFlow', 'row'); q('#st-hover').onclick = segSet('dockHover', 'shelf'); q('#st-count').onclick = segSet('dockCount', ['seg', 'bare']); q('#st-count-pos').onclick = segSet('dockCountPos', 'side'); var step = function (d) { var v = Math.min(160, Math.max(60, size() + d)); mbuShared('cornerSize', v === 100 ? null : v / 100); restack(); show(); }; q('#st-size-dn').onclick = function () { step(-10); }; q('#st-size-up').onclick = function () { step(10); }; // Every launcher any page has shown (dockKnown), in dockOrder, then as the page stacks them. var strip = q('#st-order'), order = mbuShared('dockOrder'); order = Array.isArray(order) ? order : []; var rank = function (n) { var i = order.indexOf(n), el = i < 0 && live(n); return i >= 0 ? i - 1e5 : el ? Number(el.dataset.mbCornerOrder) || 0 : 1e5; }; Object.keys(known).sort(function (a, b) { return rank(a) - rank(b) || (a < b ? -1 : 1); }).forEach(function (n) { var d = document.createElement('div'); d.className = 'st-di'; d.dataset.name = n; d.dataset.tip = n; d.innerHTML = stFitIcon(known[n]); strip.appendChild(d); }); if (!strip.children.length) strip.innerHTML = 'The launchers show here once a page has them.'; var drag = null; strip.addEventListener('pointerdown', function (e) { var d = e.button === 0 && e.target.closest('.st-di'); if (!d) return; e.preventDefault(); drag = d; d.classList.add('st-drag'); try { strip.setPointerCapture(e.pointerId); } catch (err) { /* old browser */ } }); strip.addEventListener('pointermove', function (e) { if (!drag) return; var over = Array.prototype.filter.call(strip.children, function (c) { var r = c.getBoundingClientRect(); return c !== drag && e.clientX >= r.left && e.clientX <= r.right && e.clientY >= r.top - 3 && e.clientY <= r.bottom + 3; })[0]; if (!over) return; var r = over.getBoundingClientRect(); strip.insertBefore(drag, e.clientX < r.left + r.width / 2 ? over : over.nextSibling); }); var drop = function () { if (!drag) return; drag.classList.remove('st-drag'); drag = null; var names = Array.prototype.map.call(strip.querySelectorAll('.st-di'), function (c) { return c.dataset.name; }); if (names.join('\n') === order.join('\n')) return; order = names; mbuShared('dockOrder', names); restack(); }; strip.addEventListener('pointerup', drop); strip.addEventListener('pointercancel', drop); strip.addEventListener('contextmenu', function (e) { var d = e.target.closest('.st-di'); if (!d) return; e.preventDefault(); openFor(d.dataset.name); }); show(); refresh = function () { show(); showTheme(); showIdle(); showPal(); }; } var updateCheck = 0; function checkUpdates() { var check = ++updateCheck, box = q('#st-upd'); var refs = ['main', 'stable']; // The installed build is shown below the available channels. // a row per channel from the start, so the box keeps its size when the answers come var got = {}, left = refs.length, draw = function (checking) { box.innerHTML = refs.map(function (r) { var v2 = got[r], name = r === 'main' ? 'Latest' : r === 'stable' ? 'Stable' : r; var state = checking ? 'checking…' : !v2 ? 'couldn’t be read' : stCmpVer(v2, ST_VERSION) === 0 ? 'the one you have' : stCmpVer(v2, ST_VERSION) > 0 ? 'newer' : 'older'; return '
0 ? ' class="st-upd-new"' : '') + '>' + stEsc(name) + '' + (v2 ? 'v' + stEsc(v2) : '') + '' + state + '' + (v2 && stCmpVer(v2, ST_VERSION) !== 0 ? 'Install' + (r === 'main' ? 'Pinned' : '') + '' : '') + '
'; }).join('') + '
Installedv' + stEsc(ST_VERSION) + '' + stEsc(stChannel()) + '
'; }; draw(true); box.onclick = function (e) { var a = e.target.closest('[data-st-pinned]'); if (!a) return; e.preventDefault(); stInstallPinned(a.getAttribute('data-st-pinned')); }; refs.forEach(function (ref) { stRemoteVersion(ref, function (v) { got[ref] = v; if (v) stRemote[ref] = v; if (--left || check !== updateCheck) return; draw(false); }); }); } if (!ST_ON_MB) checkUpdates(); else { if (!tab) try { tab = localStorage.getItem('st-cfg-tab'); } catch (_) {} if (tab && tab !== 'g' && q('#st-tab-' + tab)) q('#st-tab-' + tab).click(); } Array.prototype.forEach.call(panel.querySelectorAll('[data-st-m]'), function (box) { box.onchange = function () { stFlip(box.getAttribute('data-st-m')); q('#st-reload').hidden = false; q('#st-apply').textContent = 'Reload the page to apply.'; }; }); q('#st-reload').onclick = function () { location.reload(); }; q('#st-copy-md').onclick = function () { stCopy(stVersionsText(), function (ok) { try { U.mbuToast(ok ? '✓ Versions copied as Markdown' : '⚠ Couldn’t copy the versions'); } catch (e) { /* no toast */ } }); }; stFitPixels(panel); U.mbuControls(panel); U.mbuCfgDrag(panel); var activate = function (t, d) { pin(); if (vv) { vv.addEventListener('resize', pin); vv.addEventListener('scroll', pin); } document.addEventListener('keydown', onKey, true); document.addEventListener('mousedown', onOut, true); ov.style.display = ''; ovPin(); addEventListener('scroll', ovPin, { capture: true, passive: true }); addEventListener('resize', ovPin, { passive: true }); if (t && q('#st-tab-' + t)) q('#st-tab-' + t).click(); panel.focus(); var dk = d && ST_ON_MB && q('#st-dock'); if (dk) dk.scrollIntoView({ block: 'start' }); }; activate(null, dock); } // String Theory's command palette (#890): a hotkey (Ctrl+K by default) opens a list of commands, filtered as // you type, as in VS Code. build.mjs writes this file into the bundle after settings.js, in the same scope. // Its setting is the GM value 'string_theory.palette': { on, key: { ctrl, alt, shift, meta, key }, pins, recent, last }. // Plain ES5, as the rest of the bundle's own code. var ST_PAL_KEY = 'string_theory.palette'; var ST_PAL_HOTKEY = { ctrl: true, alt: false, shift: false, meta: false, key: 'k' }; var stPal = null, stPalOv = null, stPalRecording = false; function stPalRead() { if (stPal) return stPal; var v; try { v = GM_getValue(ST_PAL_KEY, null); } catch (e) { v = null; } v = v && typeof v === 'object' ? v : {}; var list = function (a) { return Array.isArray(a) ? a.filter(function (x) { return typeof x === 'string'; }) : []; }; stPal = { on: v.on !== false, key: v.key && v.key.key ? v.key : ST_PAL_HOTKEY, pins: list(v.pins), recent: list(v.recent), last: typeof v.last === 'string' ? v.last : '' }; return stPal; } function stPalSet(patch) { var p = stPalRead(); Object.keys(patch).forEach(function (k) { p[k] = patch[k]; }); try { GM_setValue(ST_PAL_KEY, p); } catch (e) { /* not kept */ } } // e.code, not e.key, for letters and digits: Alt and Shift change what e.key says function stKeyOf(e) { var c = /^(Key|Digit)(.)$/.exec(e.code || ''), k = c ? c[2].toLowerCase() : String(e.key || '').toLowerCase(); return { ctrl: e.ctrlKey, alt: e.altKey, shift: e.shiftKey, meta: e.metaKey, key: k === ' ' ? 'space' : k }; } function stKeyLabel(h) { var k = h.key.length === 1 ? h.key.toUpperCase() : h.key.charAt(0).toUpperCase() + h.key.slice(1); return [h.ctrl && 'Ctrl', h.alt && 'Alt', h.shift && 'Shift', h.meta && 'Meta', k].filter(Boolean).join('+'); } function stKeyIs(e, h) { var k = stKeyOf(e); return k.key === h.key && k.ctrl === !!h.ctrl && k.alt === !!h.alt && k.shift === !!h.shift && k.meta === !!h.meta; } var ST_PAL_CSS = '' // above every window, a config window included: they share the modal z-index, where the later one wins + '#st-pal-ov{z-index:2147483600;align-items:flex-start;padding-top:12vh;background:none}' + '#st-pal{width:min(640px,94vw);max-height:min(70vh,560px);font:13px/1.4 var(--mbu-font);outline:none}' + '#st-pal-q{box-sizing:border-box;width:100%;margin:0;padding:12px 14px;border:0;border-bottom:1px solid var(--mbu-border);border-radius:0;background:var(--mbu-bg);color:var(--mbu-text);font:15px/1.3 var(--mbu-font);outline:none;box-shadow:none}' + '#st-pal-list{flex:1 1 auto;overflow:auto;margin:0;padding:4px 0;list-style:none}' + '#st-pal-list .st-pal-g{padding:8px 14px 2px;color:var(--mbu-text-weak);font:600 11px/1.4 var(--mbu-font);text-transform:uppercase;letter-spacing:.06em}' + '#st-pal-list .st-pal-i{display:flex;align-items:center;gap:8px;margin:0;padding:5px 8px 5px 14px;cursor:pointer;color:var(--mbu-text);white-space:nowrap}' + '#st-pal-list .st-pal-i[aria-selected=true]{background:var(--mbu-accent-soft)}' + '#st-pal-list .st-pal-c{flex:0 0 auto;color:var(--mbu-text-dim)}' + '#st-pal-list .st-pal-l{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis}' + '#st-pal-list mark{background:none;color:var(--mbu-accent-text);font-weight:700;padding:0}' + '#st-pal-list .st-pal-h{flex:0 0 auto;color:var(--mbu-text-weak);font-size:12px}' + '#st-pal-list .st-pal-pin{flex:0 0 auto;width:24px;height:22px;display:inline-flex;align-items:center;justify-content:center;margin:0;padding:0;border:0;border-radius:var(--mbu-radius);background:none;color:var(--mbu-text-weak);cursor:pointer;visibility:hidden;font-size:13px;line-height:1}' + '#st-pal-list .st-pal-pin:hover{background:var(--mbu-bg-hover);color:var(--mbu-text)}' + '#st-pal-list .st-pal-i:hover .st-pal-pin,#st-pal-list .st-pal-i[aria-selected=true] .st-pal-pin,#st-pal-list .st-pal-pin[aria-pressed=true]{visibility:visible}' + '#st-pal-list .st-pal-pin[aria-pressed=true]{color:var(--mbu-accent-text)}' + '#st-pal-list .st-pal-i.st-pal-drag{opacity:.55;background:var(--mbu-accent-soft)}' + '#st-pal-list.st-pal-dragging,#st-pal-list.st-pal-dragging .st-pal-i{cursor:grabbing}' + '#st-pal-list .st-pal-none{padding:10px 14px;color:var(--mbu-text-dim)}' + '#st-pal-foot{display:flex;gap:14px;flex-wrap:wrap;padding:6px 14px;border-top:1px solid var(--mbu-border);color:var(--mbu-text-weak);font-size:11px}' + '#st-pal-foot kbd{font:inherit;font-weight:600;color:var(--mbu-text-dim)}'; // ── the commands ──────────────────────────────────────────────────────────── // Each is { id, cat, label, hint?, run(), preview?() }. The id is what a pin and the recent list keep. // preview runs when the command is highlighted (with the arrows, or first after typing) and is undone // when another is, or when the palette closes without Enter. var ST_ENTITIES = 'artist|release|release-group|recording|work|label|area|place|series|event|instrument|genre|url'; var ST_ENTITY_NAMES = { artist: 'Artist', release: 'Release', 'release-group': 'Release group', recording: 'Recording', work: 'Work', label: 'Label', area: 'Area', place: 'Place', series: 'Series', event: 'Event', instrument: 'Instrument', genre: 'Genre', url: 'URL' }; function stGo(path) { return function () { location.href = path; }; } // the page shown: Event Horizon can show another than the tab loaded (#847) function stPagePath() { return document.documentElement.getAttribute('data-mbu-page') || location.pathname; } function stPalCommands() { var out = [], add = function (c) { out.push(c); }, U = stUI(); var toast = function (m) { try { U.mbuToast(m); } catch (e) { /* no toast */ } }; // Settings add({ id: 'set:st', cat: 'Settings', label: 'String Theory', run: function () { stSettings('g'); } }); if (ST_ON_MB) { var newsN = stNewsUnread(stNewsRead()).length; add({ id: 'st:news', cat: 'String Theory', label: "What's new", hint: newsN ? newsN + ' new' : '', run: stNewsOpen }); add({ id: 'st:gatelog', cat: 'String Theory', label: 'Gate log', hint: 'MusicBrainz requests', run: stGateOpen }); } if (ST_ON_MB) { add({ id: 'set:dock', cat: 'Settings', label: 'Dock', run: function () { stSettings('l'); } }); add({ id: 'set:about', cat: 'Settings', label: 'About and updates', run: function () { stSettings('a'); } }); } [['main', 'Latest'], ['stable', 'Stable']].forEach(function (r) { add({ id: 'st:install:' + r[0], cat: 'String Theory', label: 'Install ' + r[1].toLowerCase(), hint: stChannel() === r[1] ? 'current' : '', run: function () { window.open(stInstallUrl(r[0]), '_blank', 'noopener'); } }); }); add({ id: 'st:install:pinned', cat: 'String Theory', label: 'Install latest pinned', run: function () { stInstallPinned('main'); } }); stMembers.forEach(function (m) { add({ id: 'set:' + m[0], cat: 'Settings', label: m[1], run: function () { stOpenFor(m[1]); } }); }); // Theme: highlighting one shows it, Enter keeps it if (ST_ON_MB) { add({ id: 'theme:chooser', cat: 'Theme', label: 'Theme chooser', run: function () { setTimeout(stThemeChooser, 0); } }); [['light', 'Light'], ['dark', 'Dark'], ['auto', 'System'], ['sun', 'Sun'], ['time', 'Time']].forEach(function (o) { add({ id: 'theme:' + o[0], cat: 'Theme', label: o[1], hint: __stTheme.read().mode === o[0] ? 'current' : '', preview: function () { if (o[0] !== 'sun' || __stTheme.read().lat != null) __stTheme.preview({ mode: o[0] }); }, run: function () { __stTheme.setMode(o[0]); } }); }); ['dark', 'light'].forEach(function (v) { var th = __stTheme.read(); __stTheme.names(v).forEach(function (n) { add({ id: 'theme:' + v + ':' + n, cat: v === 'dark' ? 'Dark theme' : 'Light theme', label: n, hint: th[v] === n ? 'current' : '', // shown in its own variant, whatever the mode; kept for when that variant is on preview: function () { var p = { mode: v }; p[v] = n; __stTheme.preview(p); }, run: function () { var p = {}; p[v] = n; __stTheme.set(p); if (__stTheme.variant() !== v) toast('✓ ' + n + ' is your ' + v + ' theme; this page stays ' + __stTheme.variant()); } }); }); }); } // Open: each launcher on this page, as a click on it would Array.prototype.forEach.call(document.querySelectorAll('[data-mb-corner][data-mb-corner-label]'), function (el) { var n = el.dataset.mbCornerLabel; if (el.id === 'mbu-dock' || el.dataset.mbuDocked === 'off' || out.some(function (c) { return c.id === 'open:' + n; })) return; add({ id: 'open:' + n, cat: 'Open', label: n, run: function () { el.click(); } }); }); // each member's own commands: window.__mbuPalette = {