add page to create bookmarklet

This commit is contained in:
2026-01-23 01:12:48 +00:00
parent dc16cdda95
commit 0c7af4ce51

24
bookmarklet.html Normal file
View File

@@ -0,0 +1,24 @@
<p>your token will be stored inside the bookmark</p>
<input id="auth_token" placeholder="auth_token" />
<input id="url" placeholder="https://server/api/v1/add" />
<button id="button">create bookmark</button>
<a id="scriptLink" style="display: none;"> save me as bookmark!</a>
<script>
function button_action() {
scriptText = "javascript: (() => { fetch(URL, { method: 'POST', headers: { Authorization: 'Bearer ' + AUTH_TOKEN, 'Content-Type': 'application/json', }, body: JSON.stringify({ title: document.title, url: document.location.href, description: document.title }) }) })();"
auth_token = document.getElementById("auth_token").value;
url = document.getElementById("url").value;
newscript = scriptText.replace(
"AUTH_TOKEN", "'" + auth_token + "'",
).replace(
"URL", "'" + url + "'",
);
document.getElementById("scriptLink").href = newscript;
document.getElementById("scriptLink").style = "";
}
document.getElementById('button').addEventListener('click', button_action);
</script>