GitHub Hide Suggested Repository Name

Hides GitHub Suggested Repository Name

  1. // ==UserScript==
  2. // @name GitHub Hide Suggested Repository Name
  3. // @namespace http://userstyles.org
  4. // @description Hides GitHub Suggested Repository Name
  5. // @author 636597
  6. // @match https://*.github.com/new*
  7. // @run-at document-start
  8. // @version 0.4
  9. // ==/UserScript==
  10.  
  11. function on_element( query_selector , interval=20 , timeout=10000 ) {
  12. return new Promise( function( resolve , reject ) {
  13. try {
  14. let READY_CHECK_INTERVAL = setInterval( function() {
  15. let item = document.querySelectorAll( query_selector );
  16. if ( item ) {
  17. if ( item[ 0 ] ) {
  18. clearInterval( READY_CHECK_INTERVAL );
  19. resolve( item[0] );
  20. return;
  21. }
  22. }
  23. } , interval );
  24. setTimeout( function() {
  25. clearInterval( READY_CHECK_INTERVAL );
  26. resolve( false );
  27. return;
  28. } , timeout );
  29. }
  30. catch( error ) { console.log( error ); reject( error ); return; }
  31. });
  32. }
  33.  
  34. function hide() {
  35. document.querySelectorAll('button[aria-label*="suggested"]').forEach(el => el.parentNode.style.display = 'none');
  36. }
  37.  
  38. function add_css() {
  39. var sheet = document.createElement('style');
  40. sheet.innerHTML = 'button[aria-label*="suggested"] {display: none !important}';
  41. document.body.appendChild(sheet);
  42. }
  43.  
  44. function add_css_two() {
  45. let css = 'button[aria-label*="suggested"] {display: none !important;}';
  46. let head = document.head || document.getElementsByTagName('head')[0];
  47. let style = document.createElement('style');
  48. head.appendChild(style);
  49. style.type = 'text/css';
  50. if ( style.styleSheet ){
  51. style.styleSheet.cssText = css;
  52. } else {
  53. style.appendChild(document.createTextNode(css));
  54. }
  55. }
  56.  
  57. function init( input_element=false ) {
  58. hide();
  59. if ( !input_element ) {
  60. input_element = document.querySelector('input[aria-label="Repository"]');
  61. }
  62. input_element.addEventListener('input',hide);
  63. }
  64.  
  65. ( async ()=> {
  66. add_css();
  67. add_css_two();
  68. let x_input = await on_element( 'input[aria-label="Repository"]' );
  69. init( x_input );
  70. })();