Skip to content

Instantly share code, notes, and snippets.

@muslemomar
Last active August 20, 2025 08:28
Show Gist options
  • Select an option

  • Save muslemomar/25a23967cefbf1d1ef7f5243612248b6 to your computer and use it in GitHub Desktop.

Select an option

Save muslemomar/25a23967cefbf1d1ef7f5243612248b6 to your computer and use it in GitHub Desktop.
A bookmarklet that creates a comprehensive message about the PR and copies it to the clipboard. Open any PR and click on the bookmarklet. Useful for copying a formatted PR review request message.
javascript:(function(){if(!window.location.href.includes('github.com')||!window.location.href.includes('/pull/')){alert('Please run this on a GitHub Pull Request page');return;}try{const title=document.querySelector('h1.gh-header-title .js-issue-title')?.textContent?.trim()||%27No title found%27;const prNumber=window.location.pathname.split(%27/pull/%27)[1]?.split(%27/%27)[0]||%27Unknown%27;const author=document.querySelector(%27.author%27)?.textContent?.trim()||%27Unknown author%27;const prUrl=window.location.href.split(%27#')[0];const repoPath=window.location.pathname.split('/pull/')[0];const repoName=repoPath.split('/').slice(-2).join('/');const branchName=document.querySelector('.head-ref')?.textContent?.trim()||'Unknown branch';let status='Open';if(document.querySelector('.State--merged')){status='Merged';}else if(document.querySelector('.State--closed')){status='Closed';}const description=document.querySelector('.comment-body p')?.textContent?.trim()||'';const shortDescription=description.length>150?description.substring(0,150)+'...':description;const labels=Array.from(document.querySelectorAll('.IssueLabel')).map(label=>label.textContent.trim()).filter(label=>label.length>0);const reviewers=Array.from(document.querySelectorAll('.reviewer .css-truncate-target')).map(reviewer=>reviewer.textContent.trim()).filter(reviewer=>reviewer.length>0);let slackMessage=':mag: PR Review Request\n';slackMessage+=title+' (#'+prNumber+')\n';slackMessage+=':file_folder: Repository: '+repoName+'\n';slackMessage+=':seedling: Branch: '+branchName+'\n';slackMessage+=':bust_in_silhouette: Author: '+author+'\n';slackMessage+=':bar_chart: Status: '+status+'\n';if(shortDescription){slackMessage+=':memo: Description: '+shortDescription+'\n';}if(labels.length>0){slackMessage+=':label: Labels: '+labels.join(', ')+'\n';}if(reviewers.length>0){slackMessage+=':busts_in_silhouette: Reviewers: '+reviewers.join(', ')+'\n';}slackMessage+=':link: '+prUrl+'\n';slackMessage+='\nPlease review when you have a moment! :pray:';navigator.clipboard.writeText(slackMessage).then(()=>{const notification=document.createElement('div');notification.style.cssText='position: fixed;top: 20px;right: 20px;background: #28a745;color: white;padding: 15px 20px;border-radius: 5px;z-index: 10000;font-family: -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif;box-shadow: 0 4px 12px rgba(0,0,0,0.3);';notification.textContent='✅ PR details copied to clipboard!';document.body.appendChild(notification);setTimeout(()=>{document.body.removeChild(notification);},3000);}).catch(()=>{const modal=document.createElement('div');modal.style.cssText='position: fixed;top: 0;left: 0;width: 100%;height: 100%;background: rgba(0,0,0,0.8);z-index: 10000;display: flex;align-items: center;justify-content: center;';const content=document.createElement('div');content.style.cssText='background: white;padding: 20px;border-radius: 8px;max-width: 600px;max-height: 80vh;overflow-y: auto;font-family: -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif;';content.innerHTML='<h3>Copy this text to Slack:</h3><textarea style="width: 100%; height: 300px; font-family: monospace; font-size: 12px;" readonly>'+slackMessage+'</textarea><button onclick="this.parentElement.parentElement.remove()" style="margin-top: 10px; padding: 10px 20px; background: #007cba; color: white; border: none; border-radius: 4px; cursor: pointer;">Close</button>';modal.appendChild(content);document.body.appendChild(modal);});}catch(error){alert('Error extracting PR details: '+error.message);}})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment