webtoaudio / share-target.js
Brunwo
attempt pwa share target
48414d2
raw
history blame contribute delete
566 Bytes
// This function will be called when the PWA receives a share
function handleShareTarget() {
const urlParams = new URLSearchParams(window.location.search);
const sharedUrl = urlParams.get('url') || urlParams.get('text');
if (sharedUrl) {
// Redirect to the main page with the shared URL as a parameter
window.location.href = `/index.html?url=${encodeURIComponent(sharedUrl)}`;
} else {
// If no URL is shared, just go to the main page
window.location.href = '/index.html';
}
}
// Call the function when the page loads
handleShareTarget();