Last active
August 23, 2023 09:53
-
-
Save jdeniau/75ef8c78acc6ab12744ce4240a9a332d to your computer and use it in GitHub Desktop.
Copy github PR title and link as markdown bookmarklet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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