Github - Open with VSCode

Fixes "Open with Visual Studio" button on GitHub to open with VSCode instead of Visual Studio

当前为 2023-10-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Github - Open with VSCode
  3. // @namespace V@no
  4. // @description Fixes "Open with Visual Studio" button on GitHub to open with VSCode instead of Visual Studio
  5. // @match https://github.com/*
  6. // @version 23.10.21-004817
  7. // @license MIT
  8. // @run-at document-end
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (() =>
  13. {
  14. "use strict";
  15. const fixLink = () =>
  16. {
  17. const elLink = document.querySelector('[data-open-app="visual-studio"]');
  18. if (!elLink)
  19. return true;
  20.  
  21. elLink.dataset.openApp = "vscode"; // display "Launching Visual Studio Code..." message
  22. elLink.innerHTML += " Code";
  23. const cloneURL = (document.querySelector(".input-group > .form-control") || {}).value;
  24. if (cloneURL)
  25. elLink.href = "vscode://vscode.git/clone?url=" + encodeURI(cloneURL);
  26. else
  27. elLink.href = elLink.href.replace("git-client://", "vscode://vscode.git/");
  28.  
  29. //we don't need keep observing DOM changes
  30. observer.disconnect();
  31. };
  32.  
  33. const observer = new MutationObserver(fixLink);
  34. if (fixLink())
  35. observer.observe(document, {childList: true, subtree: true});
  36. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址