// ==UserScript== // @name GitHub in VSCode // @version 0.1.4 // @description A userscript that adds a button to open a repo in VSCode using github1s // @license MIT // @author Rob Garrison // @namespace https://github.com/Mottie // @match https://github.com/* // @run-at document-idle // @grant GM_addStyle // @connect github.com // @connect githubusercontent.com // @require https://greasyfork.org/scripts/398877-utils-js/code/utilsjs.js?version=1079637 // @require https://greasyfork.org/scripts/28721-mutations/code/mutations.js?version=1108163 // @icon https://github.githubassets.com/pinned-octocat.svg // @updateURL https://raw.githubusercontent.com/Mottie/GitHub-userscripts/master/github-in-vscode.user.js // @downloadURL https://raw.githubusercontent.com/Mottie/GitHub-userscripts/master/github-in-vscode.user.js // @supportURL https://github.com/Mottie/GitHub-userscripts/issues // ==/UserScript== /* global $ on make */ (() => { "use strict"; // Icon modified from https://commons.wikimedia.org/wiki/File:Visual_Studio_Code_1.35_icon.svg const vsCodeIcon = ` `; const contentWrap = document.createElement("div"); contentWrap.className = "ghiv-content"; function init() { const goToFile = $("a[data-hotkey='t']"); if (!goToFile || $(".ghiv-link")) { return; } const margin = goToFile.classList.contains("mr-2") ? "mr-2" : "ml-2"; const link = make({ el: "a", id: "github-in-vscode", className: `ghiv-link btn ${margin} tooltipped tooltipped-n`, attrs: { href: `https://github1s.com${window.location.pathname}`, "aria-label": "Open this repo in VS Code using github1s", target: "_blank", rel: "noopener noreferrer" }, html: vsCodeIcon }); goToFile.before(link); GM_addStyle("@media print { #github-in-vscode { display: none; } }"); } on(document, "ghmo:container pjax:end", init); init(); })();