Github Private by Default

Make Private Repos the default on github.com

Від 09.02.2017. Дивіться остання версія.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Github Private by Default
// @namespace    http://github.com/cswarth
// @version      0.4
// @description  Make Private Repos the default on github.com
// @author       Chris Warth
// @include http://*github.com/new
// @include https://*github.com/new
// @require  http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://greatest.deepsurf.us/scripts/6250-waitforkeyelements/code/waitForKeyElements.js?version=23756
// @run-at document-start
// ==/UserScript==

$(function () {
    "use strict";

	// I'm serious as cancer - public repos by default are a terrible risk!
	// Don't even present the options to accidentaly create the repo as public.
	// By hiding the option entirely, you have to go through several steps
	// to make a repo public.
    waitForKeyElements ("#new_repository > div.with-permission-fields > div:nth-child(4)", hideElement);

    function hideElement (jNode) {
        jNode.hide();
    }

	// Synthesize mouse events to pre-select the private option.
    waitForKeyElements ("#repository_public_false", triggerMostButtons);

    function triggerMostButtons (jNode) {
        triggerMouseEvent (jNode[0], "mouseover");
        triggerMouseEvent (jNode[0], "mousedown");
        triggerMouseEvent (jNode[0], "mouseup");
        triggerMouseEvent (jNode[0], "click");
    }

    function triggerMouseEvent (node, eventType) {
        var clickEvent = document.createEvent('MouseEvents');
        clickEvent.initEvent (eventType, true, true);
        node.dispatchEvent (clickEvent);
    }
});