Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bookmarklet script that can send AJAX requests, create UI elements and do authentication
javascript: (function() {
var el = '
<div id="bookmarklet" style="
position:fixed;
background: #FFF;
border: 1px #000 solid;
right:50px;
top:50px;
z-index:1000;
width:250px;
">
Tag: <input type="text" id="tag-input">
<button id="add-tag">Submit</button></div>';
document.body.innerHTML += el;
document.getElementById('add-tag').addEventListener("click", function () {
xhr = new XMLHttpRequest();
xhr.open("POST", encodeURI("http://localhost:8080"));
xhr.withCredentials = true;
xhr.send(JSON.stringify({
url: document.location.href,
tags: document.getElementById('tag-input').value
}));
document.getElementById('bookmarklet').remove();
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.