Grab the bookmarklet here: Bookmarklet Generator - ShareProgress
In a much simpler form it can also work like this:
javascript:prompt("Copy page link", `[${document.title}](${window.location.href})`)
In a much simpler form it can also work like this:
javascript:prompt("Copy page link", `[${document.title}](${window.location.href})`)
/* Extract canonical page url */ | |
const { href } = | |
document.querySelector("link[href][rel=shortlink]") || | |
document.querySelector("link[href][rel=canonical]") || | |
window.location; | |
const url = href.replace(/(?:^|&)utm_[^&]+/g, "").replace(/^&/, ""); | |
const link = `[${document.title}](${url})`; | |
/* Copy markdown contents to clipboard */ | |
try { | |
const element = document.createElement("textarea"); | |
const selection = document.getSelection(); | |
element.textContent = link; | |
document.body.appendChild(element); | |
selection.removeAllRanges(); | |
element.select(); | |
document.execCommand("copy"); | |
selection.removeAllRanges(); | |
element.remove(); | |
} catch (e) { | |
prompt("Failed to copy to clipboard", link); | |
} |