NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Azure devops line to clipboard // @namespace http://tampermonkey.net/ // @version 0.2 // @description You can copy to clipboard the filename:line by clicking on the line number on the page // @author MT // @match https://tfssrv.systtech.ru/tfs/* // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js // @grant GM.setClipboard // @copyright 2021, semapv (https://openuserjs.org/users/semapv) // @license MIT // ==/UserScript== function toClipboard(txt) { GM.setClipboard(txt); console.log(txt); } function lineClick(evt) { const obj = evt.target; if(obj.classList.contains("line-numbers")) { const lineNumber = obj.textContent; const mainContainer = obj.closest(".page-content"); if (!mainContainer) { return; } const fileNameContainer = mainContainer.querySelector(".body-m.text-ellipsis"); if (!fileNameContainer) { return; } const fileName = fileNameContainer.textContent; toClipboard(fileName + ":" + lineNumber); obj.style.color = 'red'; } if(obj.classList.contains("repos-line-number")) { const lineNumber = obj.dataset.line; var fileNameContainer; var fileContainer = obj.closest(".repos-summary-header"); if (fileContainer) { fileNameContainer = fileContainer.querySelector(".flex-center") if (!fileNameContainer) { return; } } if (!fileContainer) { fileContainer = obj.closest(".comment-file-header"); if (fileContainer) { fileNameContainer = fileContainer.querySelector(".comment-file-header-link") if (!fileNameContainer) { return; } } } if (!fileNameContainer) { return; } const fileName = fileNameContainer.textContent; toClipboard(fileName + ":" + lineNumber); obj.style.color = 'red'; } } (function() { document.addEventListener("click", lineClick); })();