fix: MakerWorld Bookmarklet als Base64-Payload - robuster gegen Tastatur/URL-Feld-Veraenderungen

This commit is contained in:
2026-07-12 09:17:31 +02:00
parent f0a3289d9e
commit ff681a8cf2

View File

@@ -226,7 +226,18 @@ function MakerworldTab({ toast }) {
finally { setRegenerating(false); } finally { setRegenerating(false); }
}; };
const bookmarkletCode = tokenInfo ? `javascript:(function(){try{var el=document.getElementById('__NEXT_DATA__');if(!el){alert('MakerWorld: __NEXT_DATA__ nicht gefunden. Bist du auf der Statistikseite (/my/data-overview/model)?');return;}var nd=JSON.parse(el.textContent);var sd=nd.props&&nd.props.pageProps&&nd.props.pageProps.statisticalData;if(!sd||!sd.summary){alert('MakerWorld: Keine Statistikdaten auf dieser Seite gefunden.');return;}fetch('${tokenInfo.origin}/api/tools/makerworld/ingest',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({token:'${tokenInfo.token}',statisticalData:sd})}).then(function(r){return r.json();}).then(function(j){alert(j.ok?'DickenDock aktualisiert ✓':('Fehler: '+(j.error||'unbekannt')));}).catch(function(e){alert('Fehler: '+e.message);});}catch(e){alert('Fehler: '+e.message);}})();//%s` : ''; // Skript-Inhalt getrennt von der Verpackung, damit er sauber Base64-kodiert werden kann —
// das eliminiert praktisch alle Leerzeichen/Anführungszeichen im übertragenen Code, die von
// mobilen Tastaturen (intelligente Anführungszeichen) oder URL-Feldern verändert werden könnten.
const bookmarkletInner = tokenInfo ? `(function(){try{var el=document.getElementById('__NEXT_DATA__');if(!el){alert('MakerWorld: __NEXT_DATA__ nicht gefunden. Bist du auf der Statistikseite (/my/data-overview/model)?');return;}var nd=JSON.parse(el.textContent);var sd=nd.props&&nd.props.pageProps&&nd.props.pageProps.statisticalData;if(!sd||!sd.summary){alert('MakerWorld: Keine Statistikdaten auf dieser Seite gefunden.');return;}fetch('${tokenInfo.origin}/api/tools/makerworld/ingest',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({token:'${tokenInfo.token}',statisticalData:sd})}).then(function(r){return r.json();}).then(function(j){alert(j.ok?'DickenDock aktualisiert ✓':('Fehler: '+(j.error||'unbekannt')));}).catch(function(e){alert('Fehler: '+e.message);});}catch(e){alert('Fehler: '+e.message);}})();` : '';
const bookmarkletCode = tokenInfo
? (() => {
const b64 = btoa(unescape(encodeURIComponent(bookmarkletInner)));
const urlSafeB64 = b64.replace(/\+/g, '-').replace(/\//g, '_');
return `javascript:eval(atob('${urlSafeB64}'.replace(/-/g,'+').replace(/_/g,'/')))`;
})()
: '';
const codeRef = useRef(null); const codeRef = useRef(null);