A bookmarklet to extract <link rel="webmention" href="endpoint">
endpoint for Webmentions
(() => {
const copy = () => {
const textArea = document.createElement("textarea");
const webmention = document.querySelector('link[rel="webmention"]')
if(webmention) {
const href = webmention.href
const url = window.location;
textArea.value = `-d target="${url}" ${href}`;
textArea.style.top = "0";
textArea.style.left = "0";
textArea.style.position = "fixed";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
document.execCommand("copy");
} catch (err) {
console.error("Copying err", err);
}
document.body.removeChild(textArea);
} else {
alert('No webmention endpoint')
}
};
copy();
})();
minified
javascript:(function()%7B(()%20%3D%3E%20%7B%0A%20%20const%20copy%20%3D%20()%20%3D%3E%20%7B%0A%20%20%20%20const%20textArea%20%3D%20document.createElement(%22textarea%22)%3B%0A%20%20%20%20const%20webmention%20%3D%20document.querySelector('link%5Brel%3D%22webmention%22%5D')%0A%20%20%20%20if(webmention)%20%7B%0A%09%09const%20href%20%3D%20webmention.href%0A%0A%09%09const%20url%20%3D%20window.location%3B%0A%09%09%0A%09%20%20%20%20textArea.value%20%3D%20%60-d%20target%3D%22%24%7Burl%7D%22%20%24%7Bhref%7D%60%3B%0A%09%20%20%20%20textArea.style.top%20%3D%20%220%22%3B%0A%09%20%20%20%20textArea.style.left%20%3D%20%220%22%3B%0A%09%20%20%20%20textArea.style.position%20%3D%20%22fixed%22%3B%0A%09%20%20%20%20document.body.appendChild(textArea)%3B%0A%09%20%20%20%20textArea.focus()%3B%0A%09%20%20%20%20textArea.select()%3B%0A%09%20%20%20%20try%20%7B%0A%09%20%20%20%20%20%20document.execCommand(%22copy%22)%3B%0A%09%20%20%20%20%7D%20catch%20(err)%20%7B%0A%09%20%20%20%20%20%20console.error(%22Copying%20err%22%2C%20err)%3B%0A%09%20%20%20%20%7D%0A%09%0A%09%20%20%20%20document.body.removeChild(textArea)%3B%0A%20%20%20%20%7D%20else%20%7B%0A%09%20%20%20%20alert('No%20webmention%20endpoint')%0A%20%20%20%20%7D%0A%20%20%7D%3B%0A%0A%20%20copy()%3B%0A%7D)()%3B%7D)()%3B