github助手

github助手 | 按alt + x 快捷复制克隆地址 |

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         github助手
// @namespace    https://github.com/Twtcer
// @version      0.0.1
// @match        https://github.com/*
// @description  github助手 | 按alt + x 快捷复制克隆地址 |
// @author       Twtcer
// @grant        GM_setClipboard
// @license     MIT
// ==/UserScript==

(function() {
    'use strict';
      document.onkeydown = function(e) {
              if (e.keyCode == 88 && e.altKey) {
                  //console.log(`url: ${window.location.href}`);
                  let url = window.location.href;
                  let github = 'https://github.com/';
                  let arr = url.replace(github,'').split('/');

                  if(arr.length > 0) {
                      let userName = arr[0];
                      let repo = arr[1];
                      let projectUrl = `${github}${userName}/${repo}`;
                      let cloneUrl = `git clone ${projectUrl}`;
                      GM_setClipboard(cloneUrl,'{ type: ‘text’, mimetype: ‘text/plain’}'); 
                  }
              }
      }


})();