Greasy Fork is available in English.

Github Private by Default

Make Private Repos the default on github.com

  1. // ==UserScript==
  2. // @name Github Private by Default
  3. // @namespace http://github.com/cswarth
  4. // @version 0.5
  5. // @description Make Private Repos the default on github.com
  6. // @author Chris Warth
  7. // @include http://*github.com/*/new
  8. // @include https://*github.com/*/new
  9. // @include http://*github.com/new
  10. // @include https://*github.com/new
  11. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  12. // @require https://greatest.deepsurf.us/scripts/6250-waitforkeyelements/code/waitForKeyElements.js?version=23756
  13. // @run-at document-start
  14. // ==/UserScript==
  15.  
  16. $(function () {
  17. "use strict";
  18.  
  19. // I'm serious as cancer - public repos by default are a terrible risk!
  20. // Don't even present the options to accidentaly create the repo as public.
  21. // By hiding the option entirely, you have to go through several steps
  22. // to make a repo public.
  23. waitForKeyElements ("#new_repository > div.with-permission-fields > div:nth-child(4)", hideElement);
  24.  
  25. function hideElement (jNode) {
  26. jNode.hide();
  27. }
  28.  
  29. // Synthesize mouse events to pre-select the private option.
  30. waitForKeyElements ("#repository_public_false", triggerMostButtons);
  31.  
  32. function triggerMostButtons (jNode) {
  33. triggerMouseEvent (jNode[0], "mouseover");
  34. triggerMouseEvent (jNode[0], "mousedown");
  35. triggerMouseEvent (jNode[0], "mouseup");
  36. triggerMouseEvent (jNode[0], "click");
  37. }
  38.  
  39. function triggerMouseEvent (node, eventType) {
  40. var clickEvent = document.createEvent('MouseEvents');
  41. clickEvent.initEvent (eventType, true, true);
  42. node.dispatchEvent (clickEvent);
  43. }
  44. });