// ==UserScript== // @name TFS Changeset History Helper // @namespace http://jonas.ninja // @version 1.5.0 // @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 waitForKeyElements('.history-result', doEverything, false) waitForKeyElements(".vc-page-title[title^=Changeset]", addChangesetIdCopyUtilities, true) $(document).on('mouseenter', '.history-result', highlightHistoryResult) .on('mouseleave', '.history-result', unhighlightHistoryResult) $(document).on('click', 'input.ijg-copy-changeset-id', copy) .on('click', 'input.ijg-copy-changeset-id', copy) .on('dblclick', 'input.ijg-copy-changeset-page-link', copyPageMessage) .on('click', 'input.ijg-copy-changeset-page-link', copyPageId) function copyId(e) { if (e.ctrlKey) { var historyResult = $(this).closest('.history-result') copy(this, historyResult.data().ijgTaskId) } else { copy(this) displayResult($(this).parent()) } } function copyMessage(e) { var historyResult = $(this).closest('.history-result') copy(this, createCommitMessage(historyResult, this.value)) displayResult($(this).parent()) } function copyPageId(e) { if (e.ctrlKey) { var historyResult = $(this).closest('.history-result') copy(this, $('.vc-change-summary-comment').text().match(/t\d{3,}/gi)[0].replace('t', '')) } else { copy(this) displayResult($(this).parent()) } } function copyPageMessage(e) { copy(this, createCommitMessage(".vc-change-summary-comment", this.value)) displayResult($(this).parent()) } function copy(e) { // !!! new function $target = $(this) GM_setClipboard($target.data('ijgCopyText')) displayResult($target) } function doEverything(historyResult) { historyResult = $(historyResult) spanifyText(historyResult) addCopyUtilities(historyResult) createTaskContainers(historyResult) //fetchTaskLinks(historyResult) } function createTaskContainers(historyResult) { // makes a positioned div in the right place to hold Task info var tasks = historyResult.find('.ijg-task-id') if (tasks.size()) { // make a container and append rows var container = $('
') historyResult.find('.change-link-container').append(container) tasks.each(function() { var tasknum = $(this).data('ijgTaskId') var task = $('') 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() + '](' + url + ')' var message = createCommitMessage(historyResult, changesetId) var button = $('