Skip to content

Instantly share code, notes, and snippets.

@tvhong
Created January 29, 2025 16:01
Show Gist options
  • Save tvhong/6e530d8a62df996efce0fc6c32ff86d7 to your computer and use it in GitHub Desktop.
Save tvhong/6e530d8a62df996efce0fc6c32ff86d7 to your computer and use it in GitHub Desktop.
Bookmarket to copy GitHub pull request info to your clipboard
javascript:(function(){
try {
const url = window.location.href;
const title = document.querySelector('.js-issue-title').innerText;
const author = document.querySelector ('.author').innerText;
const filesChanged = document.querySelector('#files_tab_counter').innerText;
const diffStats = document.querySelector('.diffstat').innerText.trim();
const formattedText = `Title: ${title}\n
Author: ${author}\n
URL: ${url}\n
Files changed: ${filesChanged}\n
Changes: ${diffStats}`;
document.activeElement.focus(); /* need this so clipboard works reliably */
navigator.clipboard.writeText(formattedText);
} catch(e) {
alert('Error: Make sure you are on a GitHub PR page');
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment