Skip to content

Instantly share code, notes, and snippets.

@ideadapt
Last active November 2, 2018 09:02
Show Gist options
  • Save ideadapt/5f5580a9034c9464c7b1d74299111f30 to your computer and use it in GitHub Desktop.
Save ideadapt/5f5580a9034c9464c7b1d74299111f30 to your computer and use it in GitHub Desktop.

Revisions

  1. ideadapt revised this gist Nov 2, 2018. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions tampermonkey-bamboo-scripfile-link.js
    Original file line number Diff line number Diff line change
    @@ -29,7 +29,15 @@ var inline_src = (<><![CDATA[
    new MutationObserver(function(mutations) {
    mutations.forEach(function(mutation) {
    if(mutation.addedNodes.length > 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");
  2. ideadapt revised this gist Aug 3, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions tampermonkey-bamboo-scripfile-link.js
    Original file line number Diff line number Diff line change
    @@ -18,10 +18,10 @@ var inline_src = (<><![CDATA[
    /* jshint esversion: 6 */

    // adjust to your needs/setup
    const stashRestRoot = "https://dev.finnova.ch/stash/rest/api/1.0/";
    const stashRestRoot = "https://HOST/stash/rest/api/1.0/";
    const filesApi = "projects/IB/repos/bamboo-scripts/files?limit=100";
    const repos = [{
    url: "https://dev.finnova.ch/stash/projects/IB/repos/bamboo-scripts",
    url: "https://HOST/stash/projects/IB/repos/bamboo-scripts",
    name: "Bamboo Scripts"
    }];
    // end of config
  3. ideadapt revised this gist Aug 3, 2017. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions tampermonkey-bamboo-scripfile-link.js
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,7 @@
    // @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==

    @@ -17,10 +18,10 @@ var inline_src = (<><![CDATA[
    /* jshint esversion: 6 */

    // adjust to your needs/setup
    const stashRestRoot = "https://HOST/stash/rest/api/1.0/";
    const stashRestRoot = "https://dev.finnova.ch/stash/rest/api/1.0/";
    const filesApi = "projects/IB/repos/bamboo-scripts/files?limit=100";
    const repos = [{
    url: "https://HOST/stash/projects/IB/repos/bamboo-scripts",
    url: "https://dev.finnova.ch/stash/projects/IB/repos/bamboo-scripts",
    name: "Bamboo Scripts"
    }];
    // end of config
  4. ideadapt created this gist Jun 26, 2017.
    63 changes: 63 additions & 0 deletions tampermonkey-bamboo-scripfile-link.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,63 @@
    // ==UserScript==
    // @name Bamboo Script File Repo Link
    // @namespace http://tampermonkey.net/
    // @version 0.1
    // @description add link to script file in stash repository
    // @author [email protected]
    // @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*
    // @run-at document-idle
    // ==/UserScript==

    /* jshint ignore:start */
    var inline_src = (<><![CDATA[
    /* jshint ignore:end */
    /* jshint esnext: false */
    /* jshint esversion: 6 */

    // adjust to your needs/setup
    const stashRestRoot = "https://HOST/stash/rest/api/1.0/";
    const filesApi = "projects/IB/repos/bamboo-scripts/files?limit=100";
    const repos = [{
    url: "https://HOST/stash/projects/IB/repos/bamboo-scripts",
    name: "Bamboo Scripts"
    }];
    // end of config

    new MutationObserver(function(mutations) {
    mutations.forEach(function(mutation) {
    if(mutation.addedNodes.length > 0){

    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 */