36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
javascript:(function() {
|
|
const apiKey = localStorage.getItem('notAnAuthToken');
|
|
const apiUrl = localStorage.getItem('api_url');
|
|
const name = prompt("Enter a name for the bookmark:");
|
|
const notes = prompt("Enter any notes (optional):");
|
|
const color = prompt("Enter a color (optional):");
|
|
const privacy = prompt("Enter privacy level (e.g., public/private):");
|
|
const folder = prompt("Enter a folder (optional):");
|
|
const url = window.location.href;
|
|
|
|
if (!name) {
|
|
alert("Name is required.");
|
|
return;
|
|
}
|
|
|
|
fetch(apiUrl, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': `Bearer ${apiKey}`
|
|
},
|
|
body: JSON.stringify({ name, url, notes, color, privacy, folder })
|
|
})
|
|
.then(response => {
|
|
if (response.ok) {
|
|
alert("Bookmark saved successfully!");
|
|
} else {
|
|
alert("Failed to save bookmark. Please check your API key.");
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error(error);
|
|
alert("An unknown error occurred while saving the bookmark.");
|
|
});
|
|
})();
|