// ==UserScript== // @name TFS Changeset History Helper // @namespace http://jonas.ninja // @version 1.6.1 // @description Changeset reference utilities // @author @_jnblog // @match http://*/tfs/DefaultCollection/*/_versionControl* // @grant GM_addStyle // @grant GM_setClipboard // @downloadURL none // ==/UserScript== /* jshint -W097 */ /* global GM_addStyle */ /* jshint asi: true, multistr: true */ var $ = unsafeWindow.jQuery; var mergedChangesetRegex = /\(merge c\d{5,} to QA\)/gi var urls = { base: window.location.origin + window.location.pathname.match(/^\/(.*?)\/(.*?)\//)[0], changesetLinkedWorkItems: '_apis/tfvc/changesets/{}/workItems', changesetInfo: '_apis/tfvc/changesets/{}', apiVersion: '?api-version=1.0', } waitForKeyElements('.history-result', doEverything, false) waitForKeyElements(".vc-page-title[title^=Changeset]", addChangesetIdCopyUtilities, true) $(document).on('mouseenter', '.history-result', highlightHistoryResult) .on('mouseleave', '.history-result', unhighlightHistoryResult) function doEverything(historyResult) { historyResult = $(historyResult) spanifyText(historyResult) addCopyUtilities(historyResult) } function spanifyText(historyResult) { // wraps changeset/task IDs with spans so they can be targeted individually // adds data to the newly-created spans historyResult.find('.change-link').each(function() { // commit messages may have either Tasks or Changesets $(this).html($(this).text().replace(/[ct]\d{3,}/gi, function(match) { var id = match.replace(/[ct]/gi, '') if (match.startsWith('t')) { historyResult.data('ijgTaskId', id) return '' + match + '' } return '' + match + '' })) }) historyResult.find('.change-info').each(function() { // '.history-result's will only have changesets, and they will not be prefixed with 'c' $(this).html($(this).text().replace(/\d{3,}/gi, function(match) { var changesetId = match.replace(/c/i, '') return '' + match + '' })) }) } function addCopyUtilities(historyResult) { var $container = $('
') var changesetId = historyResult.find('.change-info').prop('title').match(/^\d{3,6}/)[0] var url = historyResult.find('a.change-link').prop('href') var formattedUrl = '*' + historyResult.find('a.change-link').text() + '*\n' + url var message = createCommitMessage(historyResult, changesetId) var button = $('