Skip to content

Instantly share code, notes, and snippets.

@zbicin
Last active February 12, 2019 16:16
Show Gist options
  • Select an option

  • Save zbicin/cc61a5cdef6f2108bc333df0fd9bf5ff to your computer and use it in GitHub Desktop.

Select an option

Save zbicin/cc61a5cdef6f2108bc333df0fd9bf5ff to your computer and use it in GitHub Desktop.
Copy VSTS Pull Request branch to clipboard

How to use?

  1. Copy the contents below *:
(function(){const copyText=(text)=>{const textField=document.createElement('textarea');textField.innerText=text;document.body.appendChild(textField);textField.select();document.execCommand('copy');textField.remove()};const branchLinks=document.querySelectorAll('.ms-Link.vc-pullrequest-detail-branch-name, .vc-branches-container .vss-PickListDropdown--title-text');if(branchLinks.length<1){alert('Branch link not found')}else{const branchName=branchLinks[0].innerText.trim();copyText(branchName);const oldTitle=document.title;document.title=`๐Ÿ“‹ Copied: "${branchName}"`;setTimeout(()=>document.title=oldTitle,1000)}})()
  1. Create a new bookmark and paste the contents as URL.
  2. Done. We can call it a day.

* or minify them yourself from bookmarklet.js if you're paranoid

(function() {
const copyText = (text) => {
const textField = document.createElement('textarea');
textField.innerText = text;
document.body.appendChild(textField);
textField.select();
document.execCommand('copy');
textField.remove();
};
const branchLinks = document.querySelectorAll('.ms-Link.vc-pullrequest-detail-branch-name, .vc-branches-container .vss-PickListDropdown--title-text');
if(branchLinks.length < 1) {
alert('Branch link not found');
} else {
const branchName = branchLinks[0].innerText.trim();
copyText(branchName);
const oldTitle = document.title;
document.title = `๐Ÿ“‹ Copied: "${branchName}"`;
setTimeout(() => document.title = oldTitle, 1000);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment