document.addEventListener('DOMContentLoaded', function () { const confirmUnshareBtn = document.getElementById('confirmUnshareBtn'); if (!confirmUnshareBtn) return; confirmUnshareBtn.addEventListener('click', function () { fetch(`/paste/${document.body.dataset.pasteId}/unshare`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username: window.unshareUsername }) }) .then(response => response.json()) .then(data => { showToast(data.message || 'User unshared!', 'bg-success'); location.reload(); }) .catch(err => { console.error('Error unsharing:', err); showToast('Error unsharing.', 'bg-danger'); }); }); });