64 lines
3.0 KiB
HTML
64 lines
3.0 KiB
HTML
<div class="col-10 offset-md-1 context-main-bg p-4 my-5">
|
|
<legend class="text-center">Mobile Bookmarklet</legend>
|
|
<hr>
|
|
<div class="col-8 offset-2 ">
|
|
<div class="h5">
|
|
<p>
|
|
You can quickly and easily add bookmarks to your AllTheBookmarks account from any mobile device.
|
|
Since you can't use extensions on mobile, you can log in from your mobile device and visit this page.
|
|
</p>
|
|
<p>
|
|
Below is a code snippet that you can copy, then create a new bookmark on your mobile device as you would normally.
|
|
Before saving the bookmark, change the name to something simple like "ATB Bookmarker" and paste thiis code as the url.
|
|
</p>
|
|
<p>
|
|
Once you have the bookmarklet saved, you can simply go to your mobile bookmarks while on a page and this snippet will grab the info you need and add it to you account.
|
|
</p>
|
|
</div>
|
|
|
|
<div class="">
|
|
<pre lang="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 (!apiKey) {
|
|
alert("You must sign in to obtain an auth token.");
|
|
return;
|
|
}
|
|
|
|
if (!name) {
|
|
alert("Name is required.");
|
|
return;
|
|
}
|
|
|
|
fetch(apiUrl + 'api/bookmarks/create', {
|
|
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.");
|
|
});
|
|
})();
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div> |