Skip to content

Instantly share code, notes, and snippets.

@MaienM
Last active July 20, 2018 08:29
Show Gist options
  • Select an option

  • Save MaienM/d6131f286942e530f4b4267162178d80 to your computer and use it in GitHub Desktop.

Select an option

Save MaienM/d6131f286942e530f4b4267162178d80 to your computer and use it in GitHub Desktop.

Revisions

  1. Michon van Dooren revised this gist Jul 20, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gitlab-utils.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    // ==UserScript==
    // @name GitLab Utils
    // @namespace http://tampermonkey.net/
    // @namespace https://gist.github.com/MaienM/d6131f286942e530f4b4267162178d80
    // @updateUrl https://gist.githubusercontent.com/MaienM/d6131f286942e530f4b4267162178d80/raw/
    // @version 0.1
    // @description GitLab Utilities
    // @author MaienM
  2. Michon van Dooren created this gist Jul 20, 2018.
    28 changes: 28 additions & 0 deletions gitlab-utils.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    // ==UserScript==
    // @name GitLab Utils
    // @namespace http://tampermonkey.net/
    // @version 0.1
    // @description GitLab Utilities
    // @author MaienM
    // @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
    // @require https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js
    // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js
    // @match https://gitlab.waxd.nl/*
    // ==/UserScript==

    var inline_src = (<><![CDATA[

    $('body[data-page="admin:users:index"] .content .flex-row .controls').each(function() {
    const $this = $(this);
    const $btnEdit = $this.find('.btn[href$="/edit"]');
    const $btnImpersonate = $btnEdit.clone();
    $btnImpersonate.attr('href', $btnImpersonate.attr('href').replace('/edit', '/impersonate'));
    $btnImpersonate.html('Impersonate');
    $btnImpersonate.attr('data-method', 'post');
    $btnEdit.before($btnImpersonate);
    });

    ]]></>).toString();
    var c = Babel.transform(inline_src, { presets: [ "es2015", "es2016" ] });
    eval(c.code);