2

GM 脚本:修正 github

 3 years ago
source link: https://blog.lilydjwg.me/2012/8/20/gm-script-fix-github.35156.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

GM 脚本:修正 github

本文来自依云's Blog,转载请注明。

从某时起,Github 和 Linux 一样,开始有着越来越多的 bug 和让人不舒服的地方。本文所附的 GreaseMonkey 脚本修正以下问题:

  • 项目首页默认下载文件格式是 zip 而不是 gzip
  • 新建项目后,从已有项目创建的提示命令使用 HTTPS 而不再是 SSH 协议。这直接导致 git 向用户询问用户名和密码,而不使用用户已经上传并确认的密钥。

Google Code 后来也加入了 git 支持,但是我极少使用。为什么呢?因为我讨厌输入用户名和密码!虽然 Github 没有像 Google Code 那样给你生成个随机密码,但这种麻烦且不安全的方式能避免我就决不容忍。你的密码会比密钥还长吗?你使用密钥时需要输入或者显示密钥的内容吗??

github.user.js
// ==UserScript==
// @name           github fixes
// @namespace      http://lilydjwg.is-programmer.com/
// @description    下载默认 gzip 格式,新建项目时使用 ssh 协议
// @include        https://github.com/*
// @version    1.4
// @grant          none
// ==/UserScript==
var dl = document.querySelector('[icon_class=octicon-cloud-download]');
if(!dl){
dl = document.querySelector('a[title^=Download]');
}
if(dl){
dl.title = dl.title.replace('zip', 'gzip');
dl.href = dl.href.replace(/archive\/[^\/]+.zip/, 'tarball/master');
var infotext = dl.childNodes[dl.childNodes.length-1];
infotext.textContent = infotext.textContent.replace('ZIP', 'GZIP');
}
var repourl = document.querySelectorAll('.js-live-clone-url');
var re = /https:\/\/github\.com\/([^\/]+)\/(.*)/;
var span, m;
var i, len;
for(i=0, len=repourl.length; i<len; i++){
span = repourl[i];
m = re.exec(span.textContent);
if(m){
span.textContent = '[email protected]:'+m[1]+'/'+m[2];
}
}

点此安装

2012年9月9日更新:跟随 github 的更新,修正修改默认下载的格式失败的问题。

2012年11月27日更新:跟随 github 更新,使用带版本号的下载链接地址。

2013年5月17日更新:跟随 github 更新,更新 CSS 选择器。

2013年6月18日更新:支持 新版界面


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK