all atb changes
This commit is contained in:
35
app/plugins/bookmarks/js/bookmarklet.js
Normal file
35
app/plugins/bookmarks/js/bookmarklet.js
Normal file
@ -0,0 +1,35 @@
|
||||
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.");
|
||||
});
|
||||
})();
|
Reference in New Issue
Block a user