Skip to content

Instantly share code, notes, and snippets.

@lhns
Created June 9, 2022 14:14
Show Gist options
  • Save lhns/f3d596cb0f2f86e3ddc9901ca92a206c to your computer and use it in GitHub Desktop.
Save lhns/f3d596cb0f2f86e3ddc9901ca92a206c to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name GitLab: Open with GitHub Desktop
// @namespace http://tampermonkey.net/
// @version 0.1
// @description
// @match http://gitlab.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=gitlab.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
const label='GitHub Desktop'
const html = `<a class="dropdown-item open-with-link"><div class="gl-new-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.getElementsByName('http_project_clone')[0].value.replace(/\.git$/, "");
document.evaluate("//label[contains(text(),'Open in your IDE')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.parentNode.appendChild(elem);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment