25 lines
1.0 KiB
HTML
25 lines
1.0 KiB
HTML
<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>
|