Open with VSCode

Support Open Remote Repo in GitHub Code menu!

当前为 2021-07-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Open with VSCode
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.0
  5. // @description Support Open Remote Repo in GitHub Code menu!
  6. // @author Sanonz <sanonz@126.com>
  7. // @match https://github.com/*/*
  8. // @icon https://github.githubassets.com/pinned-octocat.svg
  9. // @homepage https://sanonz.github.io
  10. // @supportURL https://github.com/sanonz
  11. // @grant none
  12. // @run-at document-idle
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. var ul = document.querySelector('[data-target="get-repo.modal"] > ul');
  19.  
  20. var li = document.createElement('li');
  21. li.className = 'Box-row Box-row--hover-gray p-0';
  22.  
  23. var a = document.createElement('a');
  24. a.className = 'd-flex flex-items-center color-text-primary text-bold no-underline p-3';
  25. a.rel = 'nofollow';
  26. a.href = `vscode://github.remotehub/open?url=${encodeURIComponent(location.href)}`;
  27.  
  28. var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
  29. svg.setAttribute('width', 16);
  30. svg.setAttribute('height', 15);
  31. svg.setAttribute('viewBox', '0 0 1024 1024');
  32. svg.setAttribute('version', '1.1');
  33. svg.setAttribute('class', 'octicon mr-3');
  34. svg.setAttribute('aria-hidden', 'true');
  35.  
  36. var path = document.createElementNS(svg.namespaceURI, 'path');
  37. path.setAttribute('d', 'M746.222933 102.239573l-359.799466 330.820267L185.347413 281.4976 102.2464 329.864533l198.20544 182.132054-198.20544 182.132053 83.101013 48.510293 201.076054-151.558826 359.799466 330.676906 175.527254-85.251413V187.4944z m0 217.57952v384.341334l-255.040853-192.177494z');
  38.  
  39. var text = document.createTextNode('Open with VSCode');
  40.  
  41. svg.appendChild(path);
  42. a.appendChild(svg);
  43. a.appendChild(text);
  44. li.appendChild(a);
  45. ul.insertBefore(li, ul.children[0]);
  46. })();

QingJ © 2025

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