Skip to content

Instantly share code, notes, and snippets.

@lhns
Last active May 22, 2023 14:57
Show Gist options
  • Save lhns/fa403e9e2ba65b4f094741c7af411eab to your computer and use it in GitHub Desktop.
Save lhns/fa403e9e2ba65b4f094741c7af411eab to your computer and use it in GitHub Desktop.
scriptPath="$(readlink -f "$(dirname "$0")")"
cd /opt/gitlab/embedded/service/gitlab-rails/public/assets/webpack
echo >> main.*.js
echo "$scriptPath/"*.js
cat "$scriptPath/"*.js >> main.*.js
gzip -c main.*.js > main.*.js.gz
const initGithubDesktop=(function() {
'use strict';
const targetElem = document.evaluate("//label[contains(text(),'Open in your IDE')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (targetElem == null) {
//setTimeout(initGithubDesktop, 200);
return;
}
const label='GitHub Desktop'
const html = `<a class="dropdown-item open-with-link"><div class="gl-dropdown-item-text-wrapper">${label}</div></a>`
const elem = new DOMParser().parseFromString(html, 'text/html').body.children[0];
elem.href = "x-github-client://openRepo/" + document.getElementById('http_project_clone').value.replace(/\.git$/, "");
targetElem.parentNode.appendChild(elem);
})
window.addEventListener("load", initGithubDesktop);
const initJsonEditor=(function() {
'use strict';
const targetElem = document.querySelector('.tree-controls>div>*:nth-child(3)');
if (targetElem == null) {
//setTimeout(initJsonEditor, 200);
return;
}
const label='JSON Editor'
const html = `<a class="gl-button btn btn-default shortcuts-find-file" rel="nofollow">${label}</a>`
const elem = new DOMParser().parseFromString(html, 'text/html').body.children[0];
const url = new URL('https://git-json-editor.de/')
url.searchParams.set('url', document.getElementById('http_project_clone').value)
const branch = document.querySelector('.tree-ref-holder .gl-dropdown-button-text')?.textContent;
if (branch != null) {
url.searchParams.set('branch', branch);
}
elem.href = url.href;
targetElem.parentNode.insertBefore(elem, targetElem);
})
window.addEventListener("load", initJsonEditor);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment