mirror of
https://github.com/urbit/shrub.git
synced 2024-12-20 01:01:37 +03:00
3a859ef585
link-server-hook exposes (parts of) the link-store over eyre, on the condition that the client is authenticated as the host ship. link-webext as committed is a very minimal web extension. When its toolbar button is clicked, it saves the current webpage to /private in the link-store. In the future, this should support choosing a target to save to, highlighting already-saved pages, and many other features.
21 lines
595 B
JavaScript
Executable File
21 lines
595 B
JavaScript
Executable File
|
|
function storeOptions(e) {
|
|
e.preventDefault();
|
|
|
|
// clean up endpoint address and store it
|
|
let endpoint = document.querySelector("#endpoint").value
|
|
.replace(/^.*:\/\//, '') // strip protocol
|
|
.replace(/\/+$/, ''); // strip trailing slashes
|
|
setEndpoint(endpoint);
|
|
}
|
|
|
|
async function restoreOptions() {
|
|
|
|
const endpoint = await getEndpoint();
|
|
console.log('prefilling with', endpoint);
|
|
|
|
document.querySelector("#endpoint").value = endpoint;
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", restoreOptions);
|
|
document.querySelector("form").addEventListener("submit", storeOptions); |