Skip to content

Instantly share code, notes, and snippets.

@ipatalas
Last active May 1, 2024 21:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ipatalas/031c4836606a7352f9f286203b09adbf to your computer and use it in GitHub Desktop.
Save ipatalas/031c4836606a7352f9f286203b09adbf to your computer and use it in GitHub Desktop.
Azure DevOps bookmarklets
var header = $('.grid-header');
var itemName = "";
var itemId = undefined;
var type = undefined;
if ($('.work-item-form-id').length == 1) {
itemId = $('.work-item-form-id').text();
itemName = $('.work-item-form-title input').val();
type = $('.work-item-type-icon-host').find('i').attr('aria-label');
} else {
var idIndex = header.find(".grid-header-column[aria-label='ID']").index();
var titleIndex = header.find(".grid-header-column[aria-label='Title']").index();
itemId = $('.grid-row-current').find('.grid-cell')[idIndex].innerText;
var titleColumn = $('.grid-row-current').find('.grid-cell')[titleIndex];
type = $(titleColumn).find('.work-item-type-icon-host i').attr("aria-label");
itemName = titleColumn.innerText;
}
var prefix = type == "Bug" ? "Bug" : "US";
var message = `message\n\n${prefix}#${itemId} (${itemName})`;
navigator.clipboard.writeText(message)
@ipatalas
Copy link
Author

This is a bookmarklet to be used along with Azure DevOps.
It will copy selected item on the list (or when opened) and prepare a commit message in the following form:

message

US#12345 (User Story Title)

To generate a bookmarklet from that you can use this service for instance: https://mrcoles.com/bookmarklet/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment