Skip to content

Instantly share code, notes, and snippets.

@jdeniau
Last active August 23, 2023 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdeniau/75ef8c78acc6ab12744ce4240a9a332d to your computer and use it in GitHub Desktop.
Save jdeniau/75ef8c78acc6ab12744ce4240a9a332d to your computer and use it in GitHub Desktop.
Copy github PR title and link as markdown bookmarklet
javascript:(() => {
text = '';
for (const n of document.querySelectorAll('.js-issue-labels > *')) {
text += `[${n.textContent.trim()}] `
}
text += `${document.querySelector('.gh-header-title > bdi').textContent } [${document.querySelector('.gh-header-title > span').textContent }](${window.location.toString()}) by [@${document.querySelector('#discussion_bucket .author').textContent}](${document.querySelector('#discussion_bucket .author').href})`;
navigator.permissions.query({name: "clipboard-write"})
.then((result) => {
if (result.state === "granted" || result.state === "prompt") {
/* write to the clipboard now */
navigator.clipboard.writeText(text);
}
})
.catch(() => {
prompt('you can copy that', text)
});
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment