// ==UserScript== // @name Bamboo Script File Repo Link // @namespace http://tampermonkey.net/ // @version 0.1 // @description add link to script file in stash repository // @author kunz@ideadapt.net // @require https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.2/babel.js // @require https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.16.0/polyfill.js // @include *://*/*/*editBuildTasks.action* // @include *://*/*/*configureEnvironmentTasks.action* // @run-at document-idle // ==/UserScript== /* jshint ignore:start */ var inline_src = (<> 0){ // resize inline text editor let ace = document.querySelector(".bambooAceResizableContainer"); if(ace){ ace.style.width = "1200px"; ace.style.height= "800px"; } // script link let ctrl = document.querySelector("#panel-editor-config #scriptLocation"); if(ctrl && ctrl.value === 'FILE'){ const scriptFilenameCtrl = document.querySelector("#script"); const path = scriptFilenameCtrl.value; const scriptFilename = path.split('/').pop(); for(let repo of repos){ fetch(stashRestRoot + filesApi, {credentials: "same-origin", method: "GET"}) .then(res => { return res.ok ? res.json() : Promise.reject(res); }) .then(json => { const repoFilepath = json.values.filter(path => path.endsWith(scriptFilename)).pop(); if(repoFilepath){ let href = `${repo.url}/browse/${repoFilepath}`; // ` let link = document.createElement("a"); link.href = href; link.innerText = repo.name; scriptFilenameCtrl.parentElement.appendChild(link); } }); } } } }); }) .observe(document.querySelector("#panel-editor-config"), { attributes: false, childList: true, characterData: false }); /* jshint ignore:start */ ]]>).toString(); var c = Babel.transform(inline_src, { presets: [ "es2015", "es2016" ] }); eval(c.code); /* jshint ignore:end */