GitHub Custom Global Navigation

Customize GitHub's new global navigation

当前为 2025-04-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GitHub Custom Global Navigation
  3. // @namespace https://github.com/blakegearin/github-custom-global-navigation
  4. // @version 1.6.11
  5. // @description Customize GitHub's new global navigation
  6. // @author Blake Gearin <hello@blakeg.me> (https://blakegearin.com)
  7. // @match https://github.com/*
  8. // @require https://openuserjs.org/src/libs/sizzle/GM_config.js
  9. // @grant GM.getValue
  10. // @grant GM.setValue
  11. // @icon https://raw.githubusercontent.com/blakegearin/github-custom-global-navigation/main/img/light_logo.png
  12. // @supportURL https://github.com/blakegearin/github-custom-global-navigation/issues
  13. // @license MIT
  14. // @copyright 2023–2025, Blake Gearin (https://blakegearin.com)
  15. // ==/UserScript==
  16.  
  17. /* jshint esversion: 6 */
  18. /* global GM_config */
  19.  
  20. (function () {
  21. 'use strict';
  22.  
  23. const VERSION = '1.6.11';
  24. const USERSCRIPT_NAME = 'GitHub Custom Global Navigation';
  25.  
  26. const SILENT = 0;
  27. const QUIET = 1;
  28. const INFO = 2;
  29. const DEBUG = 3;
  30. const VERBOSE = 4;
  31. const TRACE = 5;
  32.  
  33. // Change to SILENT, QUIET, INFO, DEBUG, VERBOSE, or TRACE
  34. const LOG_LEVEL_OVERRIDE = DEBUG;
  35.  
  36. const LOG_LEVELS = {
  37. default: QUIET,
  38. getName: (level) => {
  39. return {
  40. 0: 'silent',
  41. 1: 'quiet',
  42. 2: 'info',
  43. 3: 'debug',
  44. 4: 'verbose',
  45. 5: 'trace',
  46. }[level];
  47. },
  48. getValue: (name) => {
  49. return {
  50. silent: SILENT,
  51. quiet: QUIET,
  52. info: INFO,
  53. debug: DEBUG,
  54. verbose: VERBOSE,
  55. trace: TRACE,
  56. }[name];
  57. },
  58. };
  59.  
  60. let CURRENT_LOG_LEVEL = LOG_LEVELS.default;
  61.  
  62. function log (level, message, variable = undefined) {
  63. if (CURRENT_LOG_LEVEL < level) return;
  64.  
  65. const levelName = LOG_LEVELS.getName(level);
  66.  
  67. const log = `[${VERSION}] [${levelName}] ${USERSCRIPT_NAME}: ${message}`;
  68.  
  69. console.groupCollapsed(log);
  70.  
  71. if (variable !== undefined) console.dir(variable, { depth: null });
  72.  
  73. console.trace();
  74. console.groupEnd();
  75. }
  76.  
  77. function logError (message, error = undefined) {
  78. const log = `[${VERSION}] [error] ${USERSCRIPT_NAME}: ${message}`;
  79.  
  80. console.groupCollapsed(log);
  81.  
  82. if (error !== undefined) console.error(error);
  83.  
  84. console.trace();
  85. console.groupEnd();
  86. }
  87.  
  88. log(TRACE, 'Starting');
  89.  
  90. function updateHeader() {
  91. log(DEBUG, 'updateHeader()');
  92.  
  93. if (CONFIG.backgroundColor !== '') {
  94. HEADER_STYLE.textContent += `
  95. ${SELECTORS.header.self}
  96. {
  97. background-color: ${CONFIG.backgroundColor} !important;
  98. }
  99. `;
  100. }
  101.  
  102. updateHamburgerButton();
  103. updateLogo();
  104.  
  105. if (CONFIG.repositoryHeader.import) importRepositoryHeader();
  106.  
  107. updatePageTitle();
  108. updateSearch();
  109. updateCopilot();
  110.  
  111. if (CONFIG.divider.remove) removeDivider();
  112.  
  113. if (CONFIG.marketplace.add) createMarketplaceLink();
  114. if (CONFIG.explore.add) createExploreLink();
  115.  
  116. updateLink('issues');
  117. updateLink('pullRequests');
  118.  
  119. if (CONFIG.marketplace.add) updateLink('marketplace');
  120. if (CONFIG.explore.add) updateLink('explore');
  121.  
  122. if (CONFIG.flipIssuesPullRequests) flipIssuesPullRequests();
  123.  
  124. updateCreateNewButton();
  125. updateInboxLink();
  126.  
  127. if (CONFIG.flipCreateInbox) flipCreateInbox();
  128.  
  129. updateAvatar();
  130.  
  131. updateGlobalBar();
  132. updateLocalBar();
  133.  
  134. updateSidebars();
  135.  
  136. modifyThenObserve(() => {
  137. document.body.appendChild(HEADER_STYLE);
  138. });
  139. }
  140.  
  141. function updateHamburgerButton() {
  142. log(DEBUG, 'updateHamburgerButton()');
  143.  
  144. const configKey = 'hamburgerButton';
  145. const elementConfig = CONFIG.hamburgerButton;
  146. log(DEBUG, 'elementConfig', elementConfig);
  147.  
  148. const hamburgerButton = HEADER.querySelector(SELECTORS[configKey]);
  149.  
  150. if (!hamburgerButton) {
  151. logError(`Selector '${SELECTORS[configKey]}' not found`);
  152. return;
  153. }
  154.  
  155. if (elementConfig.remove) {
  156. HEADER_STYLE.textContent += cssHideElement(SELECTORS[configKey]);
  157.  
  158. return;
  159. }
  160. }
  161.  
  162. function updateLogo() {
  163. log(DEBUG, 'updateLogo()');
  164.  
  165. const configKey = 'logo';
  166.  
  167. const elementConfig = CONFIG[configKey];
  168. const elementSelector = SELECTORS[configKey];
  169.  
  170. if (elementConfig.remove) {
  171. HEADER_STYLE.textContent += cssHideElement(elementSelector.topDiv);
  172. }
  173.  
  174. const logo = HEADER.querySelector(elementSelector.svg);
  175.  
  176. if (elementConfig.color !== '') {
  177. HEADER_STYLE.textContent += `
  178. ${elementSelector.svg} path
  179. {
  180. fill: ${elementConfig.color} !important;
  181. }
  182. `;
  183. }
  184.  
  185. if (elementConfig.customSvg !== '') {
  186. const oldSvg = logo;
  187.  
  188. let newSvg;
  189.  
  190. if (isValidURL(elementConfig.customSvg)) {
  191. newSvg = document.createElement('img');
  192. newSvg.src = elementConfig.customSvg;
  193. } else {
  194. const parser = new DOMParser();
  195. const svgDoc = parser.parseFromString(elementConfig.customSvg, 'image/svg+xml');
  196. newSvg = svgDoc.documentElement;
  197. }
  198.  
  199. oldSvg.parentNode.replaceChild(newSvg, oldSvg);
  200. }
  201. }
  202.  
  203. function removePageTitle() {
  204. HEADER_STYLE.textContent += cssHideElement(createId(SELECTORS.pageTitle.id));
  205. }
  206.  
  207. function updatePageTitle() {
  208. log(DEBUG, 'updatePageTitle()');
  209.  
  210. const elementConfig = CONFIG.pageTitle;
  211. log(DEBUG, 'elementConfig', elementConfig);
  212.  
  213. const pageTitle = HEADER.querySelector(SELECTORS.pageTitle.topDiv);
  214.  
  215. if (!pageTitle) {
  216. logError(`Selector '${SELECTORS.pageTitle.topDiv}' not found`);
  217. return;
  218. }
  219.  
  220. pageTitle.setAttribute('id', SELECTORS.pageTitle.id);
  221.  
  222. if (elementConfig.remove) {
  223. removePageTitle();
  224. return;
  225. }
  226.  
  227. if (elementConfig.color !== '') {
  228. HEADER_STYLE.textContent += `
  229. ${SELECTORS.pageTitle.links}
  230. {
  231. color: ${elementConfig.color} !important;
  232. }
  233. `;
  234. }
  235.  
  236. if (elementConfig.hover.color !== '') {
  237. HEADER_STYLE.textContent += `
  238. ${SELECTORS.pageTitle.links}:hover
  239. {
  240. color: ${elementConfig.hover.color} !important;
  241. }
  242. `;
  243. }
  244.  
  245. if (elementConfig.hover.backgroundColor !== '') {
  246. HEADER_STYLE.textContent += `
  247. ${SELECTORS.pageTitle.links}:hover
  248. {
  249. background-color: ${elementConfig.hover.backgroundColor} !important;
  250. }
  251. `;
  252. }
  253. }
  254.  
  255. function updateSearch() {
  256. log(DEBUG, 'updateSearch()');
  257.  
  258. const configKey = 'search';
  259.  
  260. const elementConfig = CONFIG[configKey];
  261. const elementSelector = SELECTORS[configKey];
  262.  
  263. let topDivSelector = elementSelector.id;
  264. const topDiv = HEADER.querySelector(createId(elementSelector.id)) ||
  265. HEADER.querySelector(elementSelector.topDiv);
  266.  
  267. if (!topDiv) {
  268. logError(`Selectors '${createId(elementSelector.id)}' and '${elementSelector.topDiv}' not found`);
  269. return;
  270. }
  271.  
  272. topDiv.setAttribute('id', elementSelector.id);
  273.  
  274. if (elementConfig.remove) {
  275. HEADER_STYLE.textContent += cssHideElement(createId(elementSelector.id));
  276. return;
  277. }
  278.  
  279. if (elementConfig.alignLeft) {
  280. const response = cloneAndLeftAlignElement(createId(topDivSelector), topDivSelector);
  281.  
  282. if (response.length === 0) return;
  283.  
  284. // Also need to hide button due to it showing up on larger screen widths
  285. HEADER_STYLE.textContent += cssHideElement(`${createId(topDivSelector)} ${elementSelector.input}`);
  286.  
  287. HEADER_STYLE.textContent += `
  288. ${createId(topDivSelector)}
  289. {
  290. flex-grow: 1 !important;
  291. }
  292. `;
  293.  
  294. const [cloneId, _cloneElement] = response;
  295.  
  296. topDivSelector = createId(cloneId);
  297.  
  298. HEADER_STYLE.textContent += `
  299. ${topDivSelector}
  300. {
  301. flex: 0 1 auto !important;
  302. justify-content: flex-start !important;
  303. }
  304. `;
  305. }
  306.  
  307. if (elementConfig.width === 'max') {
  308. log(DEBUG, 'elementSelector', elementSelector);
  309.  
  310. HEADER_STYLE.textContent += `
  311. @media (min-width: 1012px) {
  312. ${elementSelector.input}
  313. {
  314. width: auto !important
  315. }
  316.  
  317. ${SELECTORS.header.leftAligned}
  318. {
  319. flex: 0 1 auto !important;
  320. }
  321.  
  322. ${SELECTORS.header.rightAligned}
  323. {
  324. flex: 1 1 auto !important;
  325. justify-content: space-between !important;
  326. }
  327.  
  328. ${createId(topDivSelector)}
  329. {
  330. display: block !important;
  331. }
  332.  
  333. ${elementSelector.topDiv}-whenRegular
  334. {
  335. max-width: none !important;
  336. }
  337. }
  338. `;
  339. } else if (elementConfig.width !== '') {
  340. HEADER_STYLE.textContent += `
  341. @media (min-width: 1012px)
  342. {
  343. ${topDivSelector},
  344. ${elementSelector.input}
  345. {
  346. width: ${elementConfig.width} !important
  347. }
  348. }
  349.  
  350. @media (min-width: 768px)
  351. {
  352. ${topDivSelector},
  353. ${elementSelector.input}
  354. {
  355. --feed-sidebar: 320px;
  356. }
  357. }
  358.  
  359. @media (min-width: 1400px)
  360. {
  361. ${topDivSelector},
  362. ${elementSelector.input}
  363. {
  364. --feed-sidebar: 336px;
  365. }
  366. }
  367. `;
  368. }
  369.  
  370. if (elementConfig.margin.left !== '') {
  371. HEADER_STYLE.textContent += `
  372. @media (min-width: 1012px)
  373. {
  374. ${elementSelector.input}
  375. {
  376. margin-left: ${elementConfig.margin.left} !important
  377. }
  378. }
  379. `;
  380. }
  381.  
  382. if (elementConfig.margin.right!== '') {
  383. HEADER_STYLE.textContent += `
  384. @media (min-width: 1012px)
  385. {
  386. ${elementSelector.input}
  387. {
  388. margin-right: ${elementConfig.margin.right} !important
  389. }
  390. }
  391. `;
  392. }
  393.  
  394. if (elementConfig.rightButton !== 'command palette') {
  395. const commandPaletteButton = HEADER.querySelector(elementSelector.commandPalette);
  396. if (!commandPaletteButton) {
  397. logError(`Selector '${elementSelector.commandPalette}' not found`);
  398. } else {
  399. HEADER_STYLE.textContent += cssHideElement(elementSelector.commandPalette);
  400. }
  401. }
  402.  
  403. const placeholderSpan = HEADER.querySelector(elementSelector.placeholderSpan);
  404.  
  405. if (!placeholderSpan) {
  406. logError(`Selector '${elementSelector.placeholderSpan}' not found`);
  407. return;
  408. }
  409.  
  410. if (elementConfig.placeholder.text !== '') {
  411. // Without this, the placeholder text is overwritten by the shadow DOM
  412. // You may see the following error in the console:
  413. // qbsearch-input-element.ts:421 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'innerHTML')
  414. placeholderSpan.setAttribute('data-target', 'avoidShadowDOM');
  415. placeholderSpan.innerText = elementConfig.placeholder.text;
  416. }
  417.  
  418. if (elementConfig.placeholder.color !== '') {
  419. HEADER_STYLE.textContent += `
  420. ${elementSelector.placeholderSpan}
  421. {
  422. color: ${elementConfig.placeholder.color} !important;
  423. }
  424. `;
  425. }
  426.  
  427. const searchButton = HEADER.querySelector(elementSelector.button);
  428.  
  429. if (!searchButton) {
  430. logError(`Selector '${elementSelector.button}' not found`);
  431. return;
  432. }
  433.  
  434. if (elementConfig.backgroundColor !== '') {
  435. HEADER_STYLE.textContent += `
  436. ${elementSelector.button}
  437. {
  438. background-color: ${elementConfig.backgroundColor} !important;
  439. }
  440. `;
  441. }
  442.  
  443. if (elementConfig.borderColor !== '') {
  444. // There are different buttons at different widths
  445. HEADER_STYLE.textContent += `
  446. ${elementSelector.input} button
  447. {
  448. border-color: ${elementConfig.borderColor} !important;
  449. }
  450. `;
  451. }
  452.  
  453. if (elementConfig.boxShadow !== '') {
  454. HEADER_STYLE.textContent += `
  455. ${elementSelector.button}
  456. {
  457. box-shadow: ${elementConfig.boxShadow} !important;
  458. }
  459. `;
  460. }
  461.  
  462. if (elementConfig.magnifyingGlassIcon.remove) {
  463. HEADER_STYLE.textContent += cssHideElement(elementSelector.magnifyingGlassIcon);
  464. }
  465.  
  466. if (elementConfig.modal.width !== '') {
  467. HEADER_STYLE.textContent += `
  468. ${elementSelector.modal}
  469. {
  470. width: ${elementConfig.modal.width} !important;
  471. }
  472. `;
  473. }
  474.  
  475. if (elementConfig.rightButton === 'slash key') {
  476. HEADER_STYLE.textContent += `
  477. ${elementSelector.placeholderSpan}
  478. {
  479. width: 100% !important;
  480. }
  481. `;
  482.  
  483. const parser = new DOMParser();
  484. const svgDoc = parser.parseFromString(
  485. '<svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg>',
  486. 'image/svg+xml',
  487. );
  488. const slashImg = svgDoc.documentElement;
  489. slashImg.alt = 'slash key to search';
  490.  
  491. const placeholderDiv = HEADER.querySelector(elementSelector.placeholderDiv);
  492.  
  493. if (!placeholderDiv) {
  494. logError(`Selector '${elementSelector.placeholderDiv}' not found`);
  495. return;
  496. }
  497.  
  498. HEADER_STYLE.textContent += `
  499. ${elementSelector.placeholderDiv}
  500. {
  501. display: flex !important;
  502. }
  503.  
  504. ${elementSelector.button}
  505. {
  506. padding-inline-start: 8px !important;
  507. }
  508. `;
  509.  
  510. placeholderDiv.appendChild(slashImg);
  511. }
  512.  
  513. log(DEBUG, `Updates applied to ${configKey}`);
  514. }
  515.  
  516. function updateCopilot() {
  517. log(DEBUG, 'updateCopilot()');
  518.  
  519. const configKey = 'copilot';
  520.  
  521. const elementConfig = CONFIG[configKey];
  522. const elementSelector = SELECTORS[configKey];
  523.  
  524. let topDivSelector = elementSelector.id;
  525. const topDiv = HEADER.querySelector(createId(elementSelector.id)) ||
  526. HEADER.querySelector(elementSelector.topDiv);
  527.  
  528. if (!topDiv) {
  529. logError(`Selectors '${createId(elementSelector.id)}' and '${elementSelector.topDiv}' not found`);
  530. return;
  531. }
  532.  
  533. topDiv.setAttribute('id', elementSelector.id);
  534.  
  535. if (elementConfig.remove) {
  536. HEADER_STYLE.textContent += cssHideElement(createId(elementSelector.id));
  537. return;
  538. }
  539.  
  540. if (!elementConfig.tooltip && SELECTORS.toolTips[configKey]?.id) {
  541. HEADER_STYLE.textContent += cssHideElement(createId(SELECTORS.toolTips[configKey].id));
  542. }
  543.  
  544. const button = HEADER.querySelector(elementSelector.button);
  545.  
  546. let textContent = elementConfig.text.content;
  547.  
  548. if (elementConfig.icon.remove) {
  549. const svgId = `${configKey}-svg`;
  550. const svg = button.querySelector('svg');
  551.  
  552. if (!svg) {
  553. logError(`Selector '${configKey} svg' not found`);
  554.  
  555. return;
  556. }
  557.  
  558. svg.setAttribute('id', svgId);
  559.  
  560. HEADER_STYLE.textContent += cssHideElement(createId(svgId));
  561. } else {
  562. button.querySelector('svg').style.setProperty('fill', elementConfig.icon.color);
  563. textContent = UNICODE_NON_BREAKING_SPACE + textContent;
  564. }
  565.  
  566. modifyThenObserve(() => {
  567. HEADER.querySelector(createId(elementSelector.textContent))?.remove();
  568. });
  569.  
  570. if (elementConfig.text.content !== '') {
  571. const spanElement = document.createElement('span');
  572. const spanId = `${configKey}-text-content-span`;
  573. spanElement.setAttribute('id', spanId);
  574.  
  575. const padding = '0.5rem';
  576.  
  577. HEADER_STYLE.textContent += `
  578. ${elementSelector.button}
  579. {
  580. padding-left: ${padding} !important;
  581. padding-right: ${padding} !important;
  582. width: auto !important;
  583. text-decoration: none !important;
  584. display: flex !important;
  585. }
  586. `;
  587.  
  588. if (elementConfig.text.color) {
  589. HEADER_STYLE.textContent += `
  590. ${createId(spanId)}
  591. {
  592. color: ${elementConfig.text.color} !important;
  593. }
  594. `;
  595. }
  596.  
  597. const textNode = document.createTextNode(textContent);
  598. spanElement.appendChild(textNode);
  599.  
  600. button.appendChild(spanElement);
  601. }
  602.  
  603. if (!elementConfig.border) {
  604. HEADER_STYLE.textContent += `
  605. ${createId(topDivSelector)}
  606. {
  607. border: none !important;
  608. }
  609. `;
  610. }
  611.  
  612. if (elementConfig.boxShadow !== '') {
  613. HEADER_STYLE.textContent += `
  614. ${createId(topDivSelector)}
  615. {
  616. box-shadow: ${elementConfig.boxShadow} !important;
  617. }
  618. `;
  619. }
  620.  
  621. if (elementConfig.hover.backgroundColor !== '') {
  622. HEADER_STYLE.textContent += `
  623. ${createId(topDivSelector)}:hover
  624. {
  625. background-color: ${elementConfig.hover.backgroundColor} !important;
  626. }
  627. `;
  628. }
  629.  
  630. if (elementConfig.hover.color !== '') {
  631. HEADER_STYLE.textContent += `
  632. ${createId(topDivSelector)} span:hover
  633. {
  634. color: ${elementConfig.hover.color} !important;
  635. }
  636. `;
  637. }
  638.  
  639. log(DEBUG, `Updates applied to ${configKey}`);
  640. }
  641.  
  642. function removeDivider() {
  643. log(DEBUG, 'removeDivider()');
  644.  
  645. HEADER_STYLE.textContent += `
  646. ${SELECTORS.header.actionsDiv}::before
  647. {
  648. content: none !important;
  649. }
  650. `;
  651. }
  652.  
  653. function updateLink(configKey) {
  654. log(DEBUG, 'updateLink()');
  655.  
  656. const elementConfig = CONFIG[configKey];
  657. const elementSelector = SELECTORS[configKey];
  658.  
  659. let link;
  660. const tooltipElement = SELECTORS.toolTips[configKey];
  661.  
  662. if (tooltipElement) {
  663. link = tooltipElement.previousElementSibling;
  664. } else {
  665. log(DEBUG, `Tooltip for '${configKey}' not found`);
  666.  
  667. const linkId = createId(SELECTORS[configKey].id);
  668. link = HEADER.querySelector(linkId);
  669.  
  670. if (!link) {
  671. logError(`Selector '${linkId}' not found`);
  672.  
  673. return;
  674. }
  675. }
  676.  
  677. let linkSelector = elementSelector.id;
  678. link.setAttribute('id', linkSelector);
  679.  
  680. if (elementConfig.remove) {
  681. HEADER_STYLE.textContent += cssHideElement(createId(configKey));
  682.  
  683. return;
  684. }
  685.  
  686. if (!elementConfig.tooltip && SELECTORS.toolTips[configKey]?.id) {
  687. HEADER_STYLE.textContent += cssHideElement(createId(SELECTORS.toolTips[configKey].id));
  688. }
  689.  
  690. if (elementConfig.alignLeft) {
  691. const response = cloneAndLeftAlignElement(createId(elementSelector.id), elementSelector.id);
  692.  
  693. if (response.length === 0) return;
  694.  
  695. const [cloneId, cloneElement] = response;
  696.  
  697. elementSelector[CONFIG_NAME] = {
  698. leftAlignedId: cloneId,
  699. };
  700. link = cloneElement;
  701.  
  702. linkSelector = createId(cloneId);
  703. }
  704.  
  705. const padding = '0.5rem';
  706. link.style.setProperty('padding-left', padding, 'important');
  707. link.style.setProperty('padding-right', padding, 'important');
  708.  
  709. let textContent = elementConfig.text.content;
  710.  
  711. if (elementConfig.icon.remove) {
  712. const svgId = `${configKey}-svg`;
  713. const svg = link.querySelector('svg');
  714.  
  715. if (!svg) {
  716. logError(`Selector '${configKey} svg' not found`);
  717.  
  718. return;
  719. }
  720.  
  721. svg.setAttribute('id', svgId);
  722.  
  723. HEADER_STYLE.textContent += cssHideElement(createId(svgId));
  724. } else {
  725. link.querySelector('svg').style.setProperty('fill', elementConfig.icon.color);
  726. textContent = UNICODE_NON_BREAKING_SPACE + textContent;
  727. }
  728.  
  729. modifyThenObserve(() => {
  730. HEADER.querySelector(createId(elementSelector.textContent))?.remove();
  731. });
  732.  
  733. if (elementConfig.text.content !== '') {
  734. const spanElement = document.createElement('span');
  735. const spanId = `${configKey}-text-content-span`;
  736. spanElement.setAttribute('id', spanId);
  737.  
  738. if (elementConfig.text.color) {
  739. HEADER_STYLE.textContent += `
  740. ${createId(spanId)}
  741. {
  742. color: ${elementConfig.text.color} !important;
  743. }
  744. `;
  745. }
  746.  
  747. const textNode = document.createTextNode(textContent);
  748. spanElement.appendChild(textNode);
  749.  
  750. link.appendChild(spanElement);
  751. }
  752.  
  753. if (!elementConfig.border) {
  754. HEADER_STYLE.textContent += `
  755. ${linkSelector}
  756. {
  757. border: none !important;
  758. }
  759. `;
  760. }
  761.  
  762. if (elementConfig.boxShadow !== '') {
  763. HEADER_STYLE.textContent += `
  764. ${linkSelector}
  765. {
  766. box-shadow: ${elementConfig.boxShadow} !important;
  767. }
  768. `;
  769. }
  770.  
  771. if (elementConfig.hover.backgroundColor !== '') {
  772. HEADER_STYLE.textContent += `
  773. ${linkSelector}:hover
  774. {
  775. background-color: ${elementConfig.hover.backgroundColor} !important;
  776. }
  777. `;
  778. }
  779.  
  780. if (elementConfig.hover.color !== '') {
  781. HEADER_STYLE.textContent += `
  782. ${linkSelector} span:hover
  783. {
  784. color: ${elementConfig.hover.color} !important;
  785. }
  786. `;
  787. }
  788.  
  789. log(DEBUG, `Updates applied to link ${configKey}`, link);
  790. }
  791.  
  792. function cloneAndFlipElements(firstElementSelector, secondElementSelector, firstElementId, secondElementId) {
  793. log(DEBUG, 'cloneAndFlipElements()');
  794.  
  795. const firstElement = HEADER.querySelector(firstElementSelector);
  796.  
  797. if (!firstElement) {
  798. logError(`Selector '${firstElementSelector}' not found`);
  799. return [];
  800. }
  801.  
  802. const secondElement = HEADER.querySelector(secondElementSelector);
  803.  
  804. if (!secondElement) {
  805. logError(`Selector '${secondElementSelector}' not found`);
  806. return [];
  807. }
  808.  
  809. const firstElementClone = firstElement.cloneNode(true);
  810. const secondElementClone = secondElement.cloneNode(true);
  811.  
  812. const firstElementCloneId = `${firstElementId}-clone`;
  813. const secondElementCloneId = `${secondElementId}-clone`;
  814.  
  815. firstElementClone.setAttribute('id', firstElementCloneId);
  816. secondElementClone.setAttribute('id', secondElementCloneId);
  817.  
  818. firstElementClone.style.setProperty('display', 'none');
  819. secondElementClone.style.setProperty('display', 'none');
  820.  
  821. HEADER_STYLE.textContent = HEADER_STYLE.textContent.replace(
  822. new RegExp(escapeRegExp(firstElementSelector), 'g'),
  823. createId(firstElementCloneId),
  824. );
  825.  
  826. HEADER_STYLE.textContent = HEADER_STYLE.textContent.replace(
  827. new RegExp(escapeRegExp(secondElementSelector), 'g'),
  828. createId(secondElementCloneId),
  829. );
  830.  
  831. HEADER_STYLE.textContent += cssHideElement(firstElementSelector);
  832. HEADER_STYLE.textContent += cssHideElement(secondElementSelector);
  833.  
  834. log(VERBOSE, `#${firstElementCloneId}, #${secondElementCloneId}`);
  835. HEADER_STYLE.textContent += `
  836. #${firstElementCloneId},
  837. #${secondElementCloneId}
  838. {
  839. display: flex !important;
  840. }
  841. `;
  842.  
  843. if (secondElement.nextElementSibling === null) {
  844. secondElement.parentNode.appendChild(firstElementClone);
  845. } else {
  846. secondElement.parentNode.insertBefore(firstElementClone, secondElement.nextElementSibling);
  847. }
  848.  
  849. if (firstElement.nextElementSibling === null) {
  850. firstElement.parentNode.appendChild(secondElementClone);
  851. } else {
  852. firstElement.parentNode.insertBefore(secondElementClone, firstElement.nextElementSibling);
  853. }
  854.  
  855. if (firstElementSelector.includes('clone')) {
  856. firstElement.remove();
  857. }
  858.  
  859. if (secondElementSelector.includes('clone')) {
  860. secondElement.remove();
  861. }
  862.  
  863. NEW_ELEMENTS.push(firstElementClone);
  864. NEW_ELEMENTS.push(secondElementClone);
  865.  
  866. return [firstElementClone, secondElementClone];
  867. }
  868.  
  869. function flipIssuesPullRequests() {
  870. log(DEBUG, 'flipIssuesPullRequest()');
  871.  
  872. const issuesId = SELECTORS.issues[CONFIG_NAME]?.leftAlignedId || SELECTORS.issues.id;
  873. log(VERBOSE, 'issuesId', issuesId);
  874.  
  875. const pullRequestsId = SELECTORS.pullRequests[CONFIG_NAME]?.leftAlignedId || SELECTORS.pullRequests.id;
  876. log(VERBOSE, 'pullRequestsId', pullRequestsId);
  877.  
  878. cloneAndFlipElements(
  879. createId(issuesId),
  880. createId(pullRequestsId),
  881. `${issuesId}-flip-div`,
  882. `${pullRequestsId}-flip-div`,
  883. );
  884. }
  885.  
  886. function createOldLink(configKey, svgString) {
  887. const pullRequestsLink = HEADER.querySelector(SELECTORS.pullRequests.link);
  888.  
  889. if (!pullRequestsLink) {
  890. logError(`Selector '${SELECTORS.pullRequests.link}' not found`);
  891. return;
  892. }
  893.  
  894. const clonedLink = pullRequestsLink.cloneNode(true);
  895.  
  896. const linkId = SELECTORS[configKey].id;
  897. clonedLink.setAttribute('id', linkId);
  898.  
  899. const oldSvg = clonedLink.querySelector('svg');
  900.  
  901. const parser = new DOMParser();
  902. const svgDoc = parser.parseFromString(svgString, 'image/svg+xml');
  903. const newSvg = svgDoc.documentElement;
  904.  
  905. oldSvg.parentNode.replaceChild(newSvg, oldSvg);
  906.  
  907. const ariaId = `tooltip-${configKey}`;
  908.  
  909. clonedLink.setAttribute('href', `/${configKey}`);
  910. clonedLink.setAttribute('aria-labelledby', ariaId);
  911. clonedLink.removeAttribute('data-analytics-event');
  912.  
  913. clonedLink.querySelector('span')?.remove();
  914.  
  915. pullRequestsLink.parentNode.appendChild(clonedLink);
  916.  
  917. NEW_ELEMENTS.push(clonedLink);
  918. }
  919.  
  920. function createMarketplaceLink() {
  921. log(DEBUG, 'createMarketplaceLink()');
  922.  
  923. const svgString = `
  924. <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-gift">
  925. <path d="M2 2.75A2.75 2.75 0 0 1 4.75 0c.983 0 1.873.42 2.57 1.232.268.318.497.668.68 1.042.183-.375.411-.725.68-1.044C9.376.42 10.266 0 11.25 0a2.75 2.75 0 0 1 2.45 4h.55c.966 0 1.75.784 1.75 1.75v2c0 .698-.409 1.301-1 1.582v4.918A1.75 1.75 0 0 1 13.25 16H2.75A1.75 1.75 0 0 1 1 14.25V9.332C.409 9.05 0 8.448 0 7.75v-2C0 4.784.784 4 1.75 4h.55c-.192-.375-.3-.8-.3-1.25ZM7.25 9.5H2.5v4.75c0 .138.112.25.25.25h4.5Zm1.5 0v5h4.5a.25.25 0 0 0 .25-.25V9.5Zm0-4V8h5.5a.25.25 0 0 0 .25-.25v-2a.25.25 0 0 0-.25-.25Zm-7 0a.25.25 0 0 0-.25.25v2c0 .138.112.25.25.25h5.5V5.5h-5.5Zm3-4a1.25 1.25 0 0 0 0 2.5h2.309c-.233-.818-.542-1.401-.878-1.793-.43-.502-.915-.707-1.431-.707ZM8.941 4h2.309a1.25 1.25 0 0 0 0-2.5c-.516 0-1 .205-1.43.707-.337.392-.646.975-.879 1.793Z"></path>
  926. </svg>
  927. `;
  928.  
  929. createOldLink('marketplace', svgString);
  930. }
  931.  
  932. function createExploreLink() {
  933. log(DEBUG, 'createExploreLink()');
  934.  
  935. const svgString = `
  936. <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-telescope">
  937. <path d="M14.184 1.143v-.001l1.422 2.464a1.75 1.75 0 0 1-.757 2.451L3.104 11.713a1.75 1.75 0 0 1-2.275-.702l-.447-.775a1.75 1.75 0 0 1 .53-2.32L11.682.573a1.748 1.748 0 0 1 2.502.57Zm-4.709 9.32h-.001l2.644 3.863a.75.75 0 1 1-1.238.848l-1.881-2.75v2.826a.75.75 0 0 1-1.5 0v-2.826l-1.881 2.75a.75.75 0 1 1-1.238-.848l2.049-2.992a.746.746 0 0 1 .293-.253l1.809-.87a.749.749 0 0 1 .944.252ZM9.436 3.92h-.001l-4.97 3.39.942 1.63 5.42-2.61Zm3.091-2.108h.001l-1.85 1.26 1.505 2.605 2.016-.97a.247.247 0 0 0 .13-.151.247.247 0 0 0-.022-.199l-1.422-2.464a.253.253 0 0 0-.161-.119.254.254 0 0 0-.197.038ZM1.756 9.157a.25.25 0 0 0-.075.33l.447.775a.25.25 0 0 0 .325.1l1.598-.769-.83-1.436-1.465 1Z"></path>
  938. </svg>
  939. `;
  940.  
  941. createOldLink('explore', svgString);
  942. }
  943.  
  944. function updateCreateNewButton() {
  945. log(DEBUG, 'updateCreateNewButton()');
  946.  
  947. const configKey = 'create';
  948. const elementSelector = SELECTORS[configKey];
  949. const tooltipElement = SELECTORS.toolTips[configKey];
  950.  
  951. if (!tooltipElement) {
  952. logError(`Selector '${SELECTORS.toolTips[configKey]}' not found`);
  953. return;
  954. }
  955.  
  956. let button = HEADER.querySelector(elementSelector.button);
  957. let oldButtonId = null;
  958.  
  959. if (!button) {
  960. logError(`Selector '${elementSelector.button}' not found`);
  961.  
  962. oldButtonId = `${elementSelector.button}-old`;
  963. button = HEADER.querySelector(oldButtonId);
  964.  
  965. if (!button) {
  966. logError(`Selector '${oldButtonId}' not found`);
  967. return;
  968. }
  969. }
  970.  
  971. const elementConfig = CONFIG[configKey];
  972.  
  973. if (elementConfig.remove) {
  974. HEADER_STYLE.textContent += cssHideElement(elementSelector.topDiv);
  975.  
  976. return;
  977. } else if (!elementConfig.tooltip) {
  978. HEADER_STYLE.textContent += cssHideElement(createId(tooltipElement.id));
  979. }
  980.  
  981. const topDiv = HEADER.querySelector(elementSelector.topDiv);
  982.  
  983. if (!topDiv) {
  984. logError(`Selector '${elementSelector.topDiv}' not found`);
  985. return;
  986. }
  987.  
  988. topDiv.setAttribute('id', elementSelector.id);
  989.  
  990. const buttonLabel = button.querySelector(elementSelector.dropdownIcon);
  991.  
  992. if (elementConfig.plusIcon.remove) {
  993. HEADER_STYLE.textContent += `
  994. ${oldButtonId || elementSelector.button} ${elementSelector.plusIcon}
  995. {
  996. display: none !important
  997. }
  998. `;
  999. } else {
  1000.  
  1001. if (elementConfig.plusIcon.color !== '') {
  1002. HEADER_STYLE.textContent += `
  1003. ${elementSelector.plusIcon}
  1004. {
  1005. color: ${elementConfig.plusIcon.color} !important;
  1006. }
  1007. `;
  1008. }
  1009.  
  1010. if (elementConfig.plusIcon.hover.color !== '') {
  1011. HEADER_STYLE.textContent += `
  1012. ${elementSelector.plusIcon.split(' ').join(':hover ')} svg path
  1013. {
  1014. fill: ${elementConfig.plusIcon.hover.color} !important;
  1015. }
  1016. `;
  1017. }
  1018.  
  1019. if (elementConfig.plusIcon.marginRight !== '') {
  1020. HEADER_STYLE.textContent += `
  1021. ${elementSelector.plusIcon}
  1022. {
  1023. margin-right: ${elementConfig.plusIcon.marginRight} !important;
  1024. }
  1025. `;
  1026. }
  1027. }
  1028.  
  1029. modifyThenObserve(() => {
  1030. HEADER.querySelector(createId(SELECTORS[configKey].textContent))?.remove();
  1031. });
  1032.  
  1033. if (elementConfig.text.content !== '') {
  1034. // Update the text's font properties to match the others
  1035. HEADER_STYLE.textContent += `
  1036. ${elementSelector.button}
  1037. {
  1038. font-size: var(--text-body-size-medium, 0.875rem) !important;
  1039. font-weight: var(--base-text-weight-medium, 500) !important;
  1040. }
  1041. `;
  1042.  
  1043. const spanElement = document.createElement('span');
  1044. spanElement.setAttribute('id', elementSelector.textContent);
  1045.  
  1046. spanElement.style.setProperty('color', elementConfig.text.color);
  1047. spanElement.textContent = elementConfig.text.content;
  1048.  
  1049. // New span is inserted between the plus sign and dropdown icon
  1050. buttonLabel.parentNode.insertBefore(spanElement, buttonLabel);
  1051. }
  1052.  
  1053. if (elementConfig.dropdownIcon.remove) {
  1054. HEADER_STYLE.textContent += `
  1055. ${elementSelector.dropdownIcon}
  1056. {
  1057. display: none !important
  1058. }
  1059. `;
  1060. } else {
  1061. HEADER_STYLE.textContent += `
  1062. ${elementSelector.dropdownIcon}
  1063. {
  1064. grid-area: initial !important;
  1065. }
  1066. `;
  1067.  
  1068. if (elementConfig.dropdownIcon.color !== '') {
  1069. HEADER_STYLE.textContent += `
  1070. ${elementSelector.dropdownIcon}
  1071. {
  1072. color: ${elementConfig.dropdownIcon.color} !important;
  1073. }
  1074. `;
  1075. }
  1076.  
  1077. if (elementConfig.dropdownIcon.hover.color !== '') {
  1078. HEADER_STYLE.textContent += `
  1079. ${elementSelector.dropdownIcon.split(' ').join(':hover ')} svg path
  1080. {
  1081. fill: ${elementConfig.dropdownIcon.hover.color} !important;
  1082. }
  1083. `;
  1084. }
  1085. }
  1086.  
  1087. if (!elementConfig.border) {
  1088. HEADER_STYLE.textContent += `
  1089. ${elementSelector.button}
  1090. {
  1091. border: none !important;
  1092. }
  1093. `;
  1094. }
  1095.  
  1096. if (elementConfig.boxShadow !== '') {
  1097. HEADER_STYLE.textContent += `
  1098. ${elementSelector.button}
  1099. {
  1100. box-shadow: ${elementConfig.boxShadow} !important;
  1101. }
  1102. `;
  1103. }
  1104.  
  1105. if (elementConfig.hoverBackgroundColor !== '') {
  1106. HEADER_STYLE.textContent += `
  1107. ${elementSelector.button}:hover
  1108. {
  1109. background-color: ${elementConfig.hoverBackgroundColor} !important;
  1110. }
  1111. `;
  1112. }
  1113. }
  1114.  
  1115. function updateInboxLink() {
  1116. log(DEBUG, 'updateInboxLink()');
  1117.  
  1118. const configKey = 'notifications';
  1119.  
  1120. const elementConfig = CONFIG[configKey];
  1121. const elementSelector = SELECTORS[configKey];
  1122.  
  1123. const notificationIndicator = HEADER.querySelector(createId(elementSelector.id)) ||
  1124. HEADER.querySelector(elementSelector.indicator);
  1125.  
  1126. if (!notificationIndicator) {
  1127. logError(`Selectors '${createId(elementSelector.id)}' and '${elementSelector.indicator}' not found`);
  1128. return;
  1129. }
  1130.  
  1131. notificationIndicator.setAttribute('id', elementSelector.id);
  1132.  
  1133. const inboxLink = notificationIndicator.querySelector('a');
  1134.  
  1135. if (!inboxLink) {
  1136. logError(`Selector '${elementSelector.indicator} a' not found`);
  1137. return;
  1138. }
  1139.  
  1140. if (elementConfig.remove) {
  1141. HEADER_STYLE.textContent += cssHideElement(elementSelector.indicator);
  1142. }
  1143.  
  1144. if (!elementConfig.tooltip) {
  1145. HEADER_STYLE.textContent += cssHideElement(createId(SELECTORS.toolTips.notifications.id));
  1146. }
  1147.  
  1148. if (elementConfig.dot.remove) {
  1149. HEADER_STYLE.textContent += `
  1150. ${elementSelector.dot}
  1151. {
  1152. content: none !important;
  1153. }
  1154. `;
  1155. } else {
  1156. if (elementConfig.dot.color !== '') {
  1157. HEADER_STYLE.textContent += `
  1158. ${elementSelector.dot}
  1159. {
  1160. background: ${elementConfig.dot.color} !important;
  1161. }
  1162. `;
  1163. }
  1164.  
  1165. if (elementConfig.dot.boxShadowColor !== '') {
  1166. HEADER_STYLE.textContent += `
  1167. ${elementSelector.dot}
  1168. {
  1169. box-shadow: 0 0 0 calc(var(--base-size-4, 4px)/2) ${elementConfig.dot.boxShadowColor} !important;
  1170. }
  1171. `;
  1172. }
  1173. }
  1174.  
  1175. if (elementConfig.icon.symbol === 'inbox') {
  1176. if (elementConfig.icon.color !== '') {
  1177. HEADER_STYLE.textContent += `
  1178. ${createId(elementSelector.id)} a svg
  1179. {
  1180. fill: elementConfig.icon.color !important;
  1181. }
  1182. `;
  1183. }
  1184. } else {
  1185. const inboxSvgId = 'inbox-svg';
  1186. const inboxSvg = inboxLink.querySelector('svg');
  1187. inboxSvg.setAttribute('id', inboxSvgId);
  1188.  
  1189. HEADER_STYLE.textContent += cssHideElement(createId(inboxSvgId));
  1190. }
  1191.  
  1192. if (elementConfig.icon.symbol === 'bell') {
  1193. // Bell icon from https://gist.github.com
  1194. const bellSvgId = 'bell-svg';
  1195. const bellSvg = `
  1196. <svg id=${bellSvgId} style="display: none;" aria-hidden='true' height='16' viewBox='0 0 16 16' version='1.1' width='16' data-view-component='true' class='octicon octicon-bell'>
  1197. <path d='M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z'></path>
  1198. </svg>
  1199. `;
  1200.  
  1201. inboxLink.insertAdjacentHTML('afterbegin', bellSvg);
  1202.  
  1203. HEADER_STYLE.textContent += `
  1204. ${createId(bellSvgId)}
  1205. {
  1206. display: initial !important;
  1207. }
  1208. `;
  1209.  
  1210. if (elementConfig.icon.color !== '') {
  1211. HEADER_STYLE.textContent += `
  1212. ${createId(bellSvgId)} path
  1213. {
  1214. fill: ${elementConfig.icon.color} !important;
  1215. }
  1216. `;
  1217. }
  1218. }
  1219.  
  1220. if (elementConfig.icon.hover.color !== '') {
  1221. HEADER_STYLE.textContent += `
  1222. ${createId(elementSelector.id)} a:hover svg path
  1223. {
  1224. fill: ${elementConfig.icon.hover.color} !important;
  1225. }
  1226. `;
  1227. }
  1228.  
  1229. modifyThenObserve(() => {
  1230. HEADER.querySelector(createId(SELECTORS[configKey].textContent))?.remove();
  1231. });
  1232.  
  1233. if (elementConfig.text.content !== '') {
  1234. const padding = '0.5rem';
  1235.  
  1236. HEADER_STYLE.textContent += `
  1237. ${createId(elementSelector.id)} a
  1238. {
  1239. padding-left: ${padding} !important;
  1240. padding-right: ${padding} !important;
  1241. width: auto !important;
  1242. text-decoration: none !important;
  1243. display: flex !important;
  1244. }
  1245. `;
  1246.  
  1247. let textContent = elementConfig.text.content;
  1248.  
  1249. if (elementConfig.icon !== '') {
  1250. textContent = UNICODE_NON_BREAKING_SPACE + textContent;
  1251. }
  1252.  
  1253. const spanElement = document.createElement('span');
  1254. spanElement.setAttribute('id', elementSelector.textContent);
  1255.  
  1256. // Update the text's font properties to match the others
  1257. spanElement.style.setProperty('font-size', 'var(--text-body-size-medium, 0.875rem)', 'important');
  1258. spanElement.style.setProperty('font-weight', 'var(--base-text-weight-medium, 500)', 'important');
  1259.  
  1260. if (elementConfig.text.color) spanElement.style.setProperty('color', elementConfig.text.color);
  1261.  
  1262. const textNode = document.createTextNode(textContent);
  1263. spanElement.appendChild(textNode);
  1264.  
  1265. inboxLink.appendChild(spanElement);
  1266. }
  1267.  
  1268. if (!elementConfig.border) {
  1269. HEADER_STYLE.textContent += `
  1270. ${createId(elementSelector.id)} a
  1271. {
  1272. border: none !important;
  1273. }
  1274. `;
  1275. }
  1276.  
  1277. if (elementConfig.boxShadow !== '') {
  1278. HEADER_STYLE.textContent += `
  1279. ${createId(elementSelector.id)} a
  1280. {
  1281. box-shadow: ${elementConfig.boxShadow} !important;
  1282. }
  1283. `;
  1284. }
  1285.  
  1286. if (elementConfig.dot.displayOverIcon) {
  1287. HEADER_STYLE.textContent += `
  1288. ${elementSelector.dot}
  1289. {
  1290. top: 5px !important;
  1291. left: 18px !important;
  1292. }
  1293. `;
  1294. }
  1295.  
  1296. if (elementConfig.hoverBackgroundColor !== '') {
  1297. HEADER_STYLE.textContent += `
  1298. ${createId(elementSelector.id)} a:hover
  1299. {
  1300. background-color: ${elementConfig.hoverBackgroundColor} !important;
  1301. }
  1302. `;
  1303. }
  1304.  
  1305. log(DEBUG, `Updates applied to link ${configKey}: `, inboxLink);
  1306. }
  1307.  
  1308. function insertAvatarDropdown() {
  1309. log(DEBUG, 'insertAvatarDropdown()');
  1310.  
  1311. const elementSelector = SELECTORS.avatar;
  1312. const svgSelector = elementSelector.svg;
  1313.  
  1314. if (HEADER.querySelector(createId(svgSelector))) {
  1315. log(VERBOSE, `Selector ${createId(svgSelector)} not found`);
  1316. return;
  1317. }
  1318.  
  1319. const dropdownSvg = `
  1320. <svg id='${svgSelector}' style="display: none;" height="100%" width="100%" fill="#FFFFFF" class="octicon octicon-triangle-down" aria-hidden="true" viewBox="0 0 16 16" version="1.1" data-view-component="true">
  1321. <path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path>
  1322. </svg>
  1323. `;
  1324.  
  1325. const button = HEADER.querySelector(elementSelector.button);
  1326.  
  1327. if (!button) {
  1328. logError(`Selector '${elementSelector.button}' not found`);
  1329. return;
  1330. }
  1331.  
  1332. const divElement = document.createElement('div');
  1333. divElement.insertAdjacentHTML('afterbegin', dropdownSvg);
  1334.  
  1335. button.appendChild(divElement);
  1336. }
  1337.  
  1338. function updateAvatar() {
  1339. log(DEBUG, 'updateAvatar()');
  1340.  
  1341. const configKey = 'avatar';
  1342.  
  1343. const elementConfig = CONFIG[configKey];
  1344. const elementSelector = SELECTORS[configKey];
  1345.  
  1346. if (elementConfig.remove) {
  1347. HEADER_STYLE.textContent += cssHideElement(elementSelector.topDiv);
  1348.  
  1349. return;
  1350. }
  1351.  
  1352. if (elementConfig.size !== '') {
  1353. HEADER_STYLE.textContent += `
  1354. ${elementSelector.img}
  1355. {
  1356. height: ${elementConfig.size} !important;
  1357. width: ${elementConfig.size} !important;
  1358. }
  1359. `;
  1360. }
  1361.  
  1362. if (elementConfig.dropdownIcon) {
  1363. insertAvatarDropdown();
  1364.  
  1365. HEADER_STYLE.textContent += `
  1366. ${elementSelector.topDiv}
  1367. {
  1368. background-color: transparent !important;
  1369. }
  1370.  
  1371. ${createId(elementSelector.svg)}
  1372. {
  1373. display: initial !important;
  1374. fill: #FFFFFF;
  1375. height: 16px;
  1376. width: 16px;
  1377. margin-bottom: 1.5px;
  1378. }
  1379.  
  1380. ${elementSelector.button}:hover ${createId(elementSelector.svg)} path
  1381. {
  1382. fill: #FFFFFFB3 !important;
  1383. }
  1384.  
  1385. ${elementSelector.button}
  1386. {
  1387. gap: 0px !important;
  1388. }
  1389. `;
  1390. }
  1391. }
  1392.  
  1393. function flipCreateInbox() {
  1394. log(DEBUG, 'flipCreateInbox()');
  1395.  
  1396. cloneAndFlipElements(
  1397. createId(SELECTORS.create.id),
  1398. createId(SELECTORS.notifications.id),
  1399. `${SELECTORS.create.id}-flip`,
  1400. `${SELECTORS.notifications.id}-flip`,
  1401. );
  1402. }
  1403.  
  1404. function updateGlobalBar() {
  1405. log(DEBUG, 'updateGlobalBar()');
  1406.  
  1407. const elementConfig = CONFIG.globalBar;
  1408.  
  1409. if (elementConfig.boxShadowColor !== '') {
  1410. HEADER_STYLE.textContent += `
  1411. ${SELECTORS.header.globalBar}
  1412. {
  1413. box-shadow: inset 0 calc(var(--borderWidth-thin, 1px)*-1) ${elementConfig.boxShadowColor} !important;
  1414. }
  1415. `;
  1416. }
  1417.  
  1418. if (elementConfig.rightAligned.gap !== '') {
  1419. HEADER_STYLE.textContent += `
  1420. ${SELECTORS.header.rightAligned}
  1421. {
  1422. gap: ${elementConfig.rightAligned.gap} !important;
  1423. }
  1424. `;
  1425. }
  1426.  
  1427. if (elementConfig.leftAligned.gap !== '') {
  1428. HEADER_STYLE.textContent += `
  1429. ${SELECTORS.header.leftAligned}
  1430. {
  1431. gap: ${elementConfig.leftAligned.gap} !important;
  1432. }
  1433. `;
  1434. }
  1435. }
  1436.  
  1437. function updateLocalBar() {
  1438. log(DEBUG, 'updateLocalBar()');
  1439.  
  1440. const elementConfig = CONFIG.localBar;
  1441.  
  1442. if (elementConfig.backgroundColor !== '') {
  1443. HEADER_STYLE.textContent += `
  1444. ${SELECTORS.header.localBar.topDiv}
  1445. {
  1446. background-color: ${elementConfig.backgroundColor} !important;
  1447. box-shadow: inset 0 calc(var(--borderWidth-thin, 1px)*-1) var(--borderColor-muted) !important;
  1448. }
  1449. `;
  1450. }
  1451.  
  1452. if (elementConfig.alignCenter) {
  1453. HEADER_STYLE.textContent += `
  1454. ${SELECTORS.header.localBar.underlineNavActions}
  1455. {
  1456. display: contents !important;
  1457. padding-right: 0px !important;
  1458. }
  1459.  
  1460. ${SELECTORS.header.localBar.topDiv} nav
  1461. {
  1462. max-width: 1280px;
  1463. margin-right: auto;
  1464. margin-left: auto;
  1465. }
  1466.  
  1467. @media (min-width: 768px) {
  1468. ${SELECTORS.header.localBar.topDiv} nav
  1469. {
  1470. padding-right: var(--base-size-24, 24px) !important;
  1471. padding-left: var(--base-size-24, 24px) !important;
  1472. }
  1473. }
  1474.  
  1475. @media (min-width: 1012px) {
  1476. ${SELECTORS.header.localBar.topDiv} nav
  1477. {
  1478. padding-right: var(--base-size-32, 32px) !important;
  1479. padding-left: var(--base-size-32, 32px) !important;
  1480. }
  1481.  
  1482. .notification-shelf > div
  1483. {
  1484. padding-right: var(--base-size-32, 32px) !important;
  1485. padding-left: var(--base-size-32, 32px) !important;
  1486. max-width: 1280px;
  1487. margin-right: auto;
  1488. margin-left: auto;
  1489. }
  1490. }
  1491. `;
  1492. }
  1493.  
  1494. if (elementConfig.boxShadow.consistentColor) {
  1495. HEADER_STYLE.textContent += `
  1496. .UnderlineNav
  1497. {
  1498. box-shadow: none !important;
  1499. }
  1500. `;
  1501. }
  1502.  
  1503. if (elementConfig.links.color !== '') {
  1504. HEADER_STYLE.textContent += `
  1505. ${SELECTORS.header.localBar.topDiv} a,
  1506. ${SELECTORS.header.localBar.topDiv} a span
  1507. {
  1508. color: ${elementConfig.links.color} !important;
  1509. }
  1510. `;
  1511. }
  1512. }
  1513.  
  1514. function preloadLeftSidebar(elementSelector) {
  1515. log(DEBUG, 'preloadLeftSidebar()');
  1516.  
  1517. if (!LEFT_SIDEBAR_PRELOADED) return;
  1518.  
  1519. const leftModalDialog = HEADER.querySelector(elementSelector.left.modalDialog).remove();
  1520.  
  1521. if (!leftModalDialog) {
  1522. logError(`Selector '${elementSelector.left.modalDialog}' not found`);
  1523. preloadLeftSidebar(elementSelector);
  1524. return;
  1525. }
  1526.  
  1527. window.addEventListener('load', () => {
  1528. HEADER.querySelector(`${SELECTORS.hamburgerButton} button`).click();
  1529. log(INFO, 'Left sidebar preloaded');
  1530. });
  1531.  
  1532. LEFT_SIDEBAR_PRELOADED = true;
  1533. }
  1534.  
  1535. function updateSidebars() {
  1536. log(DEBUG, 'updateSidebars()');
  1537.  
  1538. const configKey = 'sidebars';
  1539.  
  1540. const elementConfig = CONFIG[configKey];
  1541. const elementSelector = SELECTORS[configKey];
  1542.  
  1543. if (elementConfig.backdrop.color !== '') {
  1544. HEADER_STYLE.textContent += `
  1545. ${elementSelector.left.backdrop},
  1546. ${elementSelector.right.backdrop}
  1547. {
  1548. background: ${CONFIG.sidebars.backdrop.color} !important;
  1549. }
  1550. `;
  1551. }
  1552.  
  1553. if (elementConfig.left.preload) preloadLeftSidebar(elementSelector);
  1554.  
  1555. if (elementConfig.right.floatUnderneath) {
  1556. HEADER_STYLE.textContent += `
  1557. body:has(${elementSelector.right.modalDialog})
  1558. {
  1559. overflow: scroll !important;
  1560. }
  1561.  
  1562. ${elementSelector.right.backdrop}
  1563. {
  1564. position: relative;
  1565. align-items: baseline;
  1566. width: 100vw;
  1567. height: 100vh;
  1568. top: 0;
  1569. left: 0;
  1570. }
  1571.  
  1572. ${elementSelector.right.modalDialog}
  1573. {
  1574. pointer-events: all;
  1575. margin-top: 55px;
  1576. margin-right: 20px;
  1577. animation: .2s cubic-bezier(.33,1,.68,1) !important;
  1578. border-top-right-radius: 0.75rem !important;
  1579. border-bottom-right-radius: 0.75rem !important;
  1580. }
  1581. `;
  1582. }
  1583.  
  1584. if (elementConfig.right.maxHeight) {
  1585. HEADER_STYLE.textContent += `
  1586. ${elementSelector.right.modalDialog}
  1587. {
  1588. max-height: ${elementConfig.right.maxHeight} !important;
  1589. }
  1590. `;
  1591. }
  1592.  
  1593. if (elementConfig.right.width !== '') {
  1594. HEADER_STYLE.textContent += `
  1595. ${elementSelector.right.modalDialog}.Overlay.Overlay--size-small-portrait
  1596. {
  1597. --overlay-width: ${elementConfig.right.width};
  1598. }
  1599. `;
  1600. }
  1601. }
  1602.  
  1603. function importRepositoryHeader() {
  1604. log(DEBUG, 'importRepositoryHeader()');
  1605.  
  1606. const configKey = 'repositoryHeader';
  1607. const repositoryHeader = document.querySelector(SELECTORS[configKey].id);
  1608.  
  1609. if (!repositoryHeader) {
  1610. // This is expected on pages that aren't repositories
  1611. log(DEBUG, `Selector '${SELECTORS[configKey].id}' not found`);
  1612. return;
  1613. }
  1614.  
  1615. const topRepositoryHeaderElement = document.createElement('div');
  1616. topRepositoryHeaderElement.style.setProperty('display', 'flex');
  1617. topRepositoryHeaderElement.style.setProperty('padding', '0px');
  1618. topRepositoryHeaderElement.style.setProperty('box-shadow', 'none');
  1619.  
  1620. const elementConfig = CONFIG[configKey];
  1621.  
  1622. if (elementConfig.backgroundColor !== '') {
  1623. topRepositoryHeaderElement.style.setProperty('background-color', elementConfig.backgroundColor);
  1624. }
  1625.  
  1626. if (repositoryHeader.hidden) {
  1627. log(DEBUG, `Selector '${SELECTORS[configKey].id}' is hidden`);
  1628.  
  1629. if (!HEADER.querySelector(SELECTORS.pageTitle.separator)) {
  1630. log(DEBUG, `Selector '${SELECTORS.pageTitle.separator}' not found, not creating a repository header`);
  1631.  
  1632. return;
  1633. }
  1634.  
  1635. // A repo tab other than Code is being loaded for the first time
  1636. const pageTitle = HEADER.querySelector(SELECTORS.pageTitle.topDiv);
  1637.  
  1638. if (!pageTitle) {
  1639. logError(`Selector '${SELECTORS.pageTitle.topDiv}' not found`);
  1640. return;
  1641. }
  1642.  
  1643. const repositoryHeaderElement = document.createElement('div');
  1644. repositoryHeaderElement.setAttribute('id', TEMP_REPOSITORY_HEADER_FLAG);
  1645. repositoryHeaderElement.classList.add(REPOSITORY_HEADER_CLASS, 'pt-3', 'mb-2', 'px-md-4');
  1646.  
  1647. const clonedPageTitle = pageTitle.cloneNode(true);
  1648. repositoryHeaderElement.appendChild(clonedPageTitle);
  1649.  
  1650. topRepositoryHeaderElement.appendChild(repositoryHeaderElement);
  1651. insertNewGlobalBar(topRepositoryHeaderElement);
  1652. } else if (HEADER.querySelector(createId(TEMP_REPOSITORY_HEADER_FLAG))) {
  1653. log(DEBUG, `Selector '${createId(TEMP_REPOSITORY_HEADER_FLAG)}' found`);
  1654.  
  1655. // The Code tab is being loaded from another tab which has a temporary header
  1656. const tempRepositoryHeader = HEADER.querySelector(createId(TEMP_REPOSITORY_HEADER_FLAG));
  1657.  
  1658. NEW_ELEMENTS = NEW_ELEMENTS.filter(element => element !== tempRepositoryHeader);
  1659. tempRepositoryHeader.remove();
  1660.  
  1661. insertPermanentRepositoryHeader(topRepositoryHeaderElement, repositoryHeader);
  1662. } else {
  1663. log(
  1664. DEBUG,
  1665. `'${SELECTORS[configKey].id}' is hidden and selector '${createId(TEMP_REPOSITORY_HEADER_FLAG)}' not found`,
  1666. );
  1667.  
  1668. // The Code tab being loaded for the first time
  1669. insertPermanentRepositoryHeader(topRepositoryHeaderElement, repositoryHeader);
  1670. }
  1671.  
  1672. updateRepositoryHeaderName();
  1673.  
  1674. if (elementConfig.backgroundColor !== '') {
  1675. HEADER_STYLE.textContent += `
  1676. .${REPOSITORY_HEADER_CLASS},
  1677. .notification-shelf
  1678. {
  1679. background-color: ${elementConfig.backgroundColor} !important;
  1680. }
  1681. `;
  1682. }
  1683.  
  1684. if (elementConfig.alignCenter) {
  1685. HEADER_STYLE.textContent += `
  1686. .${REPOSITORY_HEADER_CLASS}
  1687. {
  1688. max-width: 1280px;
  1689. margin-right: auto;
  1690. margin-left: auto;
  1691. }
  1692.  
  1693. .${REPOSITORY_HEADER_CLASS} .rgh-ci-link
  1694. {
  1695. align-items: center;
  1696. display: flex;
  1697. margin-right: var(--base-size-24, 24px);
  1698. }
  1699.  
  1700. .${REPOSITORY_HEADER_CLASS} .rgh-ci-link summary
  1701. {
  1702. display: flex;
  1703. }
  1704.  
  1705. .${REPOSITORY_HEADER_CLASS} .commit-build-statuses
  1706. {
  1707. position: absolute;
  1708. }
  1709.  
  1710. @media (min-width: 768px) {
  1711. .${REPOSITORY_HEADER_CLASS}
  1712. {
  1713. padding-right: var(--base-size-24, 24px) !important;
  1714. padding-left: var(--base-size-24, 24px) !important;
  1715. }
  1716. }
  1717.  
  1718. @media (min-width: 1012px) {
  1719. .${REPOSITORY_HEADER_CLASS}
  1720. {
  1721. padding-right: var(--base-size-32, 32px) !important;
  1722. padding-left: var(--base-size-32, 32px) !important;
  1723. }
  1724. }
  1725. `;
  1726. }
  1727.  
  1728. if (elementConfig.link.color !== '') {
  1729. HEADER_STYLE.textContent += `
  1730. ${SELECTORS.repositoryHeader.links}
  1731. {
  1732. color: ${elementConfig.link.color} !important;
  1733. }
  1734. `;
  1735. }
  1736.  
  1737. if (elementConfig.link.hover.color !== '') {
  1738. HEADER_STYLE.textContent += `
  1739. ${SELECTORS.repositoryHeader.links}:hover
  1740. {
  1741. color: ${elementConfig.link.hover.color} !important;
  1742. }
  1743. `;
  1744. }
  1745.  
  1746. if (elementConfig.link.hover.backgroundColor !== '') {
  1747. HEADER_STYLE.textContent += `
  1748. ${SELECTORS.repositoryHeader.links}:hover
  1749. {
  1750. background-color: ${elementConfig.link.hover.backgroundColor} !important;
  1751. }
  1752. `;
  1753. }
  1754.  
  1755. if (elementConfig.link.hover.textDecoration !== '') {
  1756. HEADER_STYLE.textContent += `
  1757. ${SELECTORS.repositoryHeader.links}:hover
  1758. {
  1759. text-decoration: ${elementConfig.link.hover.textDecoration} !important;
  1760. }
  1761. `;
  1762. }
  1763.  
  1764. HEADER_STYLE.textContent += `
  1765. .${REPOSITORY_HEADER_CLASS}
  1766. {
  1767. flex: auto !important;
  1768. }
  1769.  
  1770. ${SELECTORS.repositoryHeader.details}
  1771. {
  1772. display: flex;
  1773. align-items: center;
  1774. }
  1775.  
  1776. ${SELECTORS.pageTitle.topDiv}
  1777. {
  1778. flex: 0 1 auto !important;
  1779. height: auto !important;
  1780. min-width: 0 !important;
  1781. }
  1782.  
  1783. .AppHeader-context .AppHeader-context-compact
  1784. {
  1785. display: none !important;
  1786. }
  1787.  
  1788. .AppHeader-context .AppHeader-context-full
  1789. {
  1790. display: inline-flex !important;
  1791. width: 100% !important;
  1792. min-width: 0 !important;
  1793. max-width: 100% !important;
  1794. overflow: hidden !important;
  1795. }
  1796.  
  1797. .AppHeader-context .AppHeader-context-full ul {
  1798. display: flex;
  1799. flex-direction: row;
  1800. }
  1801.  
  1802. .AppHeader-context .AppHeader-context-full li:first-child {
  1803. flex: 0 100 max-content;
  1804. }
  1805.  
  1806. .AppHeader-context .AppHeader-context-full li {
  1807. display: inline-grid;
  1808. grid-auto-flow: column;
  1809. align-items: center;
  1810. flex: 0 99999 auto;
  1811. }
  1812.  
  1813. .AppHeader-context .AppHeader-context-full ul, .AppHeader .AppHeader-globalBar .AppHeader-context .AppHeader-context-full li {
  1814. list-style: none;
  1815. }
  1816.  
  1817. .AppHeader-context .AppHeader-context-item {
  1818. display: flex;
  1819. align-items: center;
  1820. min-width: 3ch;
  1821. line-height: var(--text-body-lineHeight-medium, 1.4285714286);
  1822. text-decoration: none !important;
  1823. border-radius: var(--borderRadius-medium, 6px);
  1824. padding-inline: var(--control-medium-paddingInline-condensed, 8px);
  1825. padding-block: var(--control-medium-paddingBlock, 6px);
  1826. }
  1827.  
  1828. .AppHeader-context .AppHeader-context-full li:last-child .AppHeader-context-item {
  1829. font-weight: var(--base-text-weight-semibold, 600);
  1830. }
  1831.  
  1832. .AppHeader-context .AppHeader-context-item-separator {
  1833. color: var(--fgColor-muted, var(--color-fg-muted));
  1834. white-space: nowrap;
  1835. }
  1836.  
  1837. ${SELECTORS.header.globalBar}
  1838. {
  1839. padding: 16px !important;
  1840. }
  1841. `;
  1842.  
  1843. if (elementConfig.removePageTitle) removePageTitle();
  1844.  
  1845. return true;
  1846. }
  1847.  
  1848. function insertPermanentRepositoryHeader(topRepositoryHeaderElement, repositoryHeader) {
  1849. log(DEBUG, 'insertPermanentRepositoryHeader()');
  1850.  
  1851. const clonedRepositoryHeader = repositoryHeader.cloneNode(true);
  1852.  
  1853. // This is needed to prevent pop-in via Turbo when navigating between tabs on a repo
  1854. repositoryHeader.removeAttribute('data-turbo-replace');
  1855. clonedRepositoryHeader.removeAttribute('data-turbo-replace');
  1856.  
  1857. repositoryHeader.style.setProperty('display', 'none', 'important');
  1858.  
  1859. clonedRepositoryHeader.classList.add(REPOSITORY_HEADER_SUCCESS_FLAG, REPOSITORY_HEADER_CLASS);
  1860.  
  1861. topRepositoryHeaderElement.appendChild(clonedRepositoryHeader);
  1862.  
  1863. insertNewGlobalBar(topRepositoryHeaderElement);
  1864.  
  1865. clonedRepositoryHeader.firstElementChild.classList.remove('container-xl', 'px-lg-5');
  1866.  
  1867. NEW_ELEMENTS.push(clonedRepositoryHeader);
  1868. }
  1869.  
  1870. function updateRepositoryHeaderName() {
  1871. log(DEBUG, 'updateRepositoryHeaderName()');
  1872.  
  1873. const elementConfig = CONFIG.repositoryHeader;
  1874.  
  1875. const name = document.querySelector(SELECTORS.repositoryHeader.name);
  1876.  
  1877. if (!name) {
  1878. // When not in a repo, this is expected
  1879. log(DEBUG, `Selector '${SELECTORS.repositoryHeader.name}' not found`);
  1880. return;
  1881. }
  1882.  
  1883. name.style.setProperty('display', 'none', 'important');
  1884.  
  1885. const pageTitle = HEADER.querySelector(SELECTORS.pageTitle.topDiv);
  1886.  
  1887. if (!pageTitle) {
  1888. logError(`Selector '${SELECTORS.pageTitle.topDiv}' not found`);
  1889. return;
  1890. }
  1891.  
  1892. const ownerImg = document.querySelector(SELECTORS.repositoryHeader.ownerImg);
  1893.  
  1894. if (!ownerImg) {
  1895. log(INFO, `Selector '${SELECTORS.repositoryHeader.ownerImg}' not found`);
  1896. return;
  1897. }
  1898.  
  1899. const clonedPageTitle = pageTitle.cloneNode(true);
  1900. clonedPageTitle.style.display = '';
  1901.  
  1902. const pageTitleId = `${REPOSITORY_HEADER_CLASS}_pageTitle`;
  1903. clonedPageTitle.setAttribute('id', pageTitleId);
  1904. clonedPageTitle.querySelector('img')?.remove();
  1905.  
  1906. HEADER_STYLE.textContent += `
  1907. ${createId(pageTitleId)}
  1908. {
  1909. display: initial !important;
  1910. }
  1911.  
  1912. ${SELECTORS.repositoryHeader.nav} context-region
  1913. {
  1914. display: flex !important;
  1915. }
  1916.  
  1917. ${SELECTORS.repositoryHeader.nav} context-region context-region-crumb
  1918. {
  1919. display: flex !important;
  1920. align-items: center !important;
  1921. }
  1922.  
  1923. ${SELECTORS.repositoryHeader.nav} context-region-crumb:last-child context-region-divider
  1924. {
  1925. display: none !important;
  1926. }
  1927. `;
  1928.  
  1929. clonedPageTitle.querySelectorAll('svg.octicon-lock').forEach(svg => svg.remove());
  1930. clonedPageTitle.querySelectorAll('a[href$="/stargazers"]').forEach(link => link.remove());
  1931.  
  1932. ownerImg.parentNode.insertBefore(clonedPageTitle, ownerImg.nextSibling);
  1933. NEW_ELEMENTS.push(clonedPageTitle);
  1934.  
  1935. if (elementConfig.avatar.remove) {
  1936. ownerImg.remove();
  1937. } else if (elementConfig.avatar.customSvg !== '') {
  1938. if (isValidURL(elementConfig.avatar.customSvg)) {
  1939. ownerImg.src = elementConfig.avatar.customSvg;
  1940. } else {
  1941. const divElement = document.createElement('div');
  1942. divElement.style.setProperty('display', 'flex');
  1943. divElement.style.setProperty('align-items', 'center');
  1944.  
  1945. divElement.innerHTML = elementConfig.avatar.customSvg;
  1946.  
  1947. ownerImg.parentNode.replaceChild(divElement, ownerImg);
  1948. }
  1949. }
  1950.  
  1951. HEADER_STYLE.textContent += cssHideElement(SELECTORS.repositoryHeader.bottomBorder);
  1952. }
  1953.  
  1954. function cloneAndLeftAlignElement(elementSelector, elementId) {
  1955. log(DEBUG, 'cloneAndLeftAlignElement()');
  1956.  
  1957. const leftAlignedDiv = HEADER.querySelector(SELECTORS.header.leftAligned);
  1958.  
  1959. if (!leftAlignedDiv) {
  1960. logError(`Selector '${SELECTORS.header.leftAligned}' not found`);
  1961. return [];
  1962. }
  1963.  
  1964. const element = HEADER.querySelector(elementSelector);
  1965.  
  1966. if (!element) {
  1967. logError(`Selector '${elementSelector}' not found`);
  1968. return [];
  1969. }
  1970.  
  1971. const elementClone = element.cloneNode(true);
  1972. const elementCloneId = `${elementId}-clone`;
  1973.  
  1974. elementClone.setAttribute('id', elementCloneId);
  1975.  
  1976. elementClone.style.setProperty('display', 'none');
  1977.  
  1978. HEADER_STYLE.textContent += cssHideElement(elementSelector);
  1979.  
  1980. HEADER_STYLE.textContent += `
  1981. ${createId(elementCloneId)}
  1982. {
  1983. display: flex !important;
  1984. }
  1985. `;
  1986.  
  1987. leftAlignedDiv.appendChild(elementClone);
  1988.  
  1989. NEW_ELEMENTS.push(elementClone);
  1990.  
  1991. return [elementCloneId, elementClone];
  1992. }
  1993.  
  1994. function insertNewGlobalBar(element) {
  1995. log(DEBUG, 'insertNewGlobalBar()');
  1996.  
  1997. const elementToInsertAfter = HEADER.querySelector(SELECTORS.header.globalBar);
  1998.  
  1999. elementToInsertAfter.parentNode.insertBefore(element, elementToInsertAfter.nextSibling);
  2000. }
  2001.  
  2002. function createId(string) {
  2003. log(TRACE, 'createId()');
  2004.  
  2005. if (string.startsWith('#')) return string;
  2006.  
  2007. if (string.startsWith('.')) {
  2008. logError(`Attempted to create an id from a class: "${string}"`);
  2009. return;
  2010. }
  2011.  
  2012. if (string.startsWith('[')) {
  2013. logError(`Attempted to create an id from an attribute selector: "${string}"`);
  2014. return;
  2015. }
  2016.  
  2017. return `#${string}`;
  2018. }
  2019.  
  2020. function cssHideElement(elementSelector) {
  2021. log(TRACE, 'cssHideElement()');
  2022.  
  2023. return `
  2024. ${elementSelector}
  2025. {
  2026. display: none !important;
  2027. }
  2028. `;
  2029. }
  2030.  
  2031. function isValidURL(string) {
  2032. log(DEBUG, 'isValidURL()');
  2033.  
  2034. const urlPattern = /^(https?:\/\/)?([\w.]+)\.([a-z]{2,6}\.?)(\/[\w.]*)*\/?$/i;
  2035. return urlPattern.test(string);
  2036. }
  2037.  
  2038. function escapeRegExp(string) {
  2039. log(DEBUG, 'escapeRegExp()');
  2040.  
  2041. return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  2042. }
  2043.  
  2044. function compareObjects(firstObject, secondObject, firstName, secondName) {
  2045. log(DEBUG, 'compareObjects()');
  2046.  
  2047. if (typeof firstObject !== 'object' || typeof secondObject !== 'object') {
  2048. return 'Invalid input. Please provide valid objects.';
  2049. }
  2050.  
  2051. const differences = [];
  2052.  
  2053. function findKeyDifferences(obj1, obj2, path = '') {
  2054. const keys1 = Object.keys(obj1);
  2055. const keys2 = Object.keys(obj2);
  2056.  
  2057. keys1.forEach(key => {
  2058. const nestedPath = path ? `${path}.${key}` : key;
  2059. if (!keys2.includes(key)) {
  2060. differences.push(`Found "${nestedPath}" in ${firstName} but not in ${secondName}`);
  2061. } else if (typeof obj1[key] === 'object' && typeof obj2[key] === 'object') {
  2062. findKeyDifferences(obj1[key], obj2[key], nestedPath);
  2063. }
  2064. });
  2065.  
  2066. keys2.forEach(key => {
  2067. const nestedPath = path ? `${path}.${key}` : key;
  2068. if (!keys1.includes(key)) {
  2069. differences.push(`Found "${nestedPath}" in ${secondName} but not in ${firstName}`);
  2070. }
  2071. });
  2072. }
  2073.  
  2074. findKeyDifferences(firstObject, secondObject);
  2075. return differences.length > 0 ? differences : [];
  2076. }
  2077.  
  2078. // eslint-disable-next-line no-unused-vars
  2079. function checkConfigConsistency(configs) {
  2080. log(DEBUG, 'checkConfigConsistency()');
  2081.  
  2082. const lightDarkDifference = compareObjects(
  2083. configs.happyMedium.light,
  2084. configs.happyMedium.dark,
  2085. 'Happy Medium Light',
  2086. 'Happy Medium Dark',
  2087. );
  2088.  
  2089. if (lightDarkDifference.length > 0) {
  2090. logError('lightDarkDifference', lightDarkDifference);
  2091.  
  2092. return false;
  2093. }
  2094.  
  2095. const typeDifference = compareObjects(
  2096. configs.happyMedium,
  2097. configs.oldSchool,
  2098. 'Happy Medium',
  2099. 'Old School',
  2100. );
  2101.  
  2102. if (typeDifference.length > 0) {
  2103. logError('typeDifference', typeDifference);
  2104.  
  2105. return false;
  2106. }
  2107.  
  2108. return true;
  2109. }
  2110.  
  2111. function updateSelectors() {
  2112. log(DEBUG, 'updateSelectors()');
  2113.  
  2114. const toolTips = Array.from(HEADER.querySelectorAll('tool-tip'));
  2115. SELECTORS.toolTips = {
  2116. copilot: toolTips.find(
  2117. tooltip => tooltip.getAttribute('for') === 'copilot-chat-header-button',
  2118. ),
  2119. create: toolTips.find(
  2120. tooltip => tooltip.textContent.includes('Create new'),
  2121. ),
  2122. pullRequests: toolTips.find(
  2123. tooltip => tooltip.textContent.includes('Your pull requests'),
  2124. ),
  2125. issues: toolTips.find(
  2126. tooltip => tooltip.textContent.includes('Your issues'),
  2127. ),
  2128. notifications: toolTips.find(
  2129. tooltip => tooltip.getAttribute('data-target') === 'notification-indicator.tooltip',
  2130. ),
  2131. };
  2132. }
  2133.  
  2134. function waitForFeaturePreviewButton() {
  2135. log(VERBOSE, 'waitForFeaturePreviewButton()');
  2136.  
  2137. if (!HEADER) return;
  2138.  
  2139. const liElementId = 'custom-global-navigation-menu-item';
  2140.  
  2141. if (HEADER.querySelector(createId(liElementId))) return;
  2142.  
  2143. const featurePreviewSearch = Array.from(
  2144. document.querySelectorAll('[data-position-regular="right"] span'),
  2145. )?.find(element => element.textContent === 'Feature preview') || null;
  2146.  
  2147. if (featurePreviewSearch) {
  2148. const featurePreviewSpan = featurePreviewSearch;
  2149. const featurePreviewLabelDiv = featurePreviewSpan.parentNode;
  2150. const featurePreviewLi = featurePreviewLabelDiv.parentNode;
  2151.  
  2152. const newLiElement = featurePreviewLi.cloneNode(true);
  2153. newLiElement.setAttribute('id', liElementId);
  2154.  
  2155. newLiElement.onclick = () => {
  2156. const closeButton = document.querySelector(SELECTORS.sidebars.right.closeButton);
  2157. if (!closeButton) {
  2158. logError(`Selector '${SELECTORS.sidebars.right.closeButton}' not found`);
  2159. } else {
  2160. closeButton.click();
  2161. }
  2162.  
  2163. GMC.open();
  2164. };
  2165.  
  2166. const textElement = newLiElement.querySelector('button > span > span');
  2167. textElement.textContent = gmcGet('menu_item_title');
  2168.  
  2169. const oldSvg = newLiElement.querySelector('svg');
  2170.  
  2171. const menuItemIcon = gmcGet('menu_item_icon');
  2172. if (menuItemIcon === 'logo') {
  2173. const newSvg = document.createElement('img');
  2174. newSvg.setAttribute('height', '16px');
  2175. newSvg.setAttribute('width', '16px');
  2176. newSvg.src = `https://raw.githubusercontent.com/blakegearin/github-custom-global-navigation/main/img/${THEME}_logo.svg`;
  2177.  
  2178. oldSvg.parentNode.replaceChild(newSvg, oldSvg);
  2179. } else {
  2180. let svgString;
  2181.  
  2182. if (menuItemIcon === 'cog') {
  2183. svgString = `
  2184. <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-gear">
  2185. <path d="M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.103-.303c.644-.176 1.392.021 1.82.63.27.385.506.792.704 1.218.315.675.111 1.422-.364 1.891l-.814.806c-.049.048-.098.147-.088.294.016.257.016.515 0 .772-.01.147.038.246.088.294l.814.806c.475.469.679 1.216.364 1.891a7.977 7.977 0 0 1-.704 1.217c-.428.61-1.176.807-1.82.63l-1.102-.302c-.067-.019-.177-.011-.3.071a5.909 5.909 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.106c-.168.646-.715 1.196-1.458 1.26a8.006 8.006 0 0 1-1.402 0c-.743-.064-1.289-.614-1.458-1.26l-.289-1.106c-.018-.066-.079-.158-.212-.224a5.738 5.738 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.103.303c-.644.176-1.392-.021-1.82-.63a8.12 8.12 0 0 1-.704-1.218c-.315-.675-.111-1.422.363-1.891l.815-.806c.05-.048.098-.147.088-.294a6.214 6.214 0 0 1 0-.772c.01-.147-.038-.246-.088-.294l-.815-.806C.635 6.045.431 5.298.746 4.623a7.92 7.92 0 0 1 .704-1.217c.428-.61 1.176-.807 1.82-.63l1.102.302c.067.019.177.011.3-.071.214-.143.437-.272.668-.386.133-.066.194-.158.211-.224l.29-1.106C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm-.571 1.525c-.036.003-.108.036-.137.146l-.289 1.105c-.147.561-.549.967-.998 1.189-.173.086-.34.183-.5.29-.417.278-.97.423-1.529.27l-1.103-.303c-.109-.03-.175.016-.195.045-.22.312-.412.644-.573.99-.014.031-.021.11.059.19l.815.806c.411.406.562.957.53 1.456a4.709 4.709 0 0 0 0 .582c.032.499-.119 1.05-.53 1.456l-.815.806c-.081.08-.073.159-.059.19.162.346.353.677.573.989.02.03.085.076.195.046l1.102-.303c.56-.153 1.113-.008 1.53.27.161.107.328.204.501.29.447.222.85.629.997 1.189l.289 1.105c.029.109.101.143.137.146a6.6 6.6 0 0 0 1.142 0c.036-.003.108-.036.137-.146l.289-1.105c.147-.561.549-.967.998-1.189.173-.086.34-.183.5-.29.417-.278.97-.423 1.529-.27l1.103.303c.109.029.175-.016.195-.045.22-.313.411-.644.573-.99.014-.031.021-.11-.059-.19l-.815-.806c-.411-.406-.562-.957-.53-1.456a4.709 4.709 0 0 0 0-.582c-.032-.499.119-1.05.53-1.456l.815-.806c.081-.08.073-.159.059-.19a6.464 6.464 0 0 0-.573-.989c-.02-.03-.085-.076-.195-.046l-1.102.303c-.56.153-1.113.008-1.53-.27a4.44 4.44 0 0 0-.501-.29c-.447-.222-.85-.629-.997-1.189l-.289-1.105c-.029-.11-.101-.143-.137-.146a6.6 6.6 0 0 0-1.142 0ZM11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM9.5 8a1.5 1.5 0 1 0-3.001.001A1.5 1.5 0 0 0 9.5 8Z"></path>
  2186. </svg>
  2187. `;
  2188. } else if (menuItemIcon === 'compass') {
  2189. svgString = `
  2190. <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512">
  2191. <!--! Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. -->
  2192. <path d="M464 256A208 208 0 1 0 48 256a208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm306.7 69.1L162.4 380.6c-19.4 7.5-38.5-11.6-31-31l55.5-144.3c3.3-8.5 9.9-15.1 18.4-18.4l144.3-55.5c19.4-7.5 38.5 11.6 31 31L325.1 306.7c-3.2 8.5-9.9 15.1-18.4 18.4zM288 256a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"/>
  2193. </svg>
  2194. `;
  2195. }
  2196.  
  2197. const parser = new DOMParser();
  2198. const svgDoc = parser.parseFromString(svgString, 'image/svg+xml');
  2199. const newSvg = svgDoc.documentElement;
  2200.  
  2201. oldSvg.parentNode.replaceChild(newSvg, oldSvg);
  2202. }
  2203.  
  2204. const parentUl = featurePreviewLi.parentNode;
  2205. const settingsLi = document.querySelector('[data-position-regular="right"] a[href="/settings/profile"]').parentNode;
  2206.  
  2207. parentUl.insertBefore(newLiElement, settingsLi.nextSibling);
  2208.  
  2209. const divider = featurePreviewLi.parentNode.querySelector(SELECTORS.sidebars.right.divider);
  2210. if (!divider) {
  2211. logError(`Selector '${SELECTORS.sidebars.right.divider}' not found`);
  2212. return;
  2213. }
  2214. const newDivider = divider.cloneNode(true);
  2215.  
  2216. parentUl.insertBefore(newDivider, settingsLi.nextSibling);
  2217. } else {
  2218. setTimeout(waitForFeaturePreviewButton, 100);
  2219. }
  2220. }
  2221.  
  2222. function generateCustomConfig() {
  2223. log(DEBUG, 'generateCustomConfig()');
  2224.  
  2225. const customConfig = {
  2226. light: {},
  2227. dark: {},
  2228. };
  2229.  
  2230. function recursivelyGenerateCustomConfig(obj, customObj, themePrefix, parentKey = '') {
  2231. for (const key in obj) {
  2232. const currentKey = parentKey ? `${parentKey}.${key}` : key;
  2233. if (typeof obj[key] === 'object') {
  2234. customObj[key] = {};
  2235. recursivelyGenerateCustomConfig(obj[key], customObj[key], themePrefix, currentKey);
  2236. } else {
  2237. const gmcKey = `${themePrefix}_${currentKey.replace(/\./g, '_')}`;
  2238.  
  2239. if (gmcKey in GMC.fields) {
  2240. customObj[key] = gmcGet(gmcKey);
  2241. } else {
  2242. logError(`GMC field not found for key: ${gmcKey}`);
  2243. return;
  2244. }
  2245. }
  2246. }
  2247. }
  2248.  
  2249. recursivelyGenerateCustomConfig(configs.happyMedium.light, customConfig.light, 'light');
  2250. recursivelyGenerateCustomConfig(configs.happyMedium.dark, customConfig.dark, 'dark');
  2251.  
  2252. return customConfig;
  2253. }
  2254.  
  2255. function setTheme() {
  2256. log(DEBUG, 'setTheme()');
  2257.  
  2258. const dataColorMode = document.querySelector('html').getAttribute('data-color-mode');
  2259.  
  2260. if (dataColorMode === 'auto') {
  2261. if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
  2262. THEME = 'dark';
  2263. }
  2264. } else if (dataColorMode === 'dark') {
  2265. THEME = 'dark';
  2266. } else if (dataColorMode !== 'light') {
  2267. logError('Unknown color mode');
  2268. }
  2269.  
  2270. log(VERBOSE, `THEME: ${THEME}`);
  2271. }
  2272.  
  2273. function gmcInitialized() {
  2274. log(DEBUG, 'gmcInitialized()');
  2275.  
  2276. updateLogLevel();
  2277.  
  2278. log(QUIET, 'Running');
  2279.  
  2280. GMC.css.basic = '';
  2281.  
  2282. startObserving();
  2283. }
  2284.  
  2285. function gmcAddSavedSpan(div) {
  2286. log(DEBUG, 'gmcAddSavedSpan()');
  2287.  
  2288. const savedDiv = document.createElement('div');
  2289. savedDiv.setAttribute('id', 'gmc-saved');
  2290.  
  2291. const iconSpan = document.createElement('span');
  2292. iconSpan.style = 'margin-right: 4px;';
  2293.  
  2294. iconSpan.innerHTML = `
  2295. <svg aria-hidden="true" focusable="false" role="img" class="octicon octicon-check-circle-fill" viewBox="0 0 12 12" width="12" height="12" fill="currentColor" style="display: inline-block;user-select: none;vertical-align: text-bottom;">
  2296. <path d="M6 0a6 6 0 1 1 0 12A6 6 0 0 1 6 0Zm-.705 8.737L9.63 4.403 8.392 3.166 5.295 6.263l-1.7-1.702L2.356 5.8l2.938 2.938Z"></path>
  2297. </svg>
  2298. `;
  2299.  
  2300. const textSpan = document.createElement('span');
  2301. textSpan.innerText = 'Saved';
  2302.  
  2303. savedDiv.appendChild(iconSpan);
  2304. savedDiv.appendChild(textSpan);
  2305.  
  2306. div.insertBefore(savedDiv, div.firstChild);
  2307. }
  2308.  
  2309. function gmcAddNewIssueButton(div) {
  2310. log(DEBUG, 'gmcAddNewIssueButton()');
  2311.  
  2312. const small = document.createElement('small');
  2313. small.classList.add('left-aligned');
  2314. small.setAttribute('title', 'Submit bug or feature request');
  2315.  
  2316. const link = document.createElement('a');
  2317. link.href = 'https://github.com/blakegearin/github-custom-global-navigation/issues';
  2318. link.innerText = 'submit bug or feature request';
  2319.  
  2320. small.appendChild(link);
  2321.  
  2322. div.insertBefore(small, div.firstChild);
  2323. }
  2324.  
  2325. function gmcOpened() {
  2326. log(DEBUG, 'gmcOpened()');
  2327.  
  2328. function updateCheckboxes() {
  2329. log(DEBUG, 'updateCheckboxes()');
  2330.  
  2331. const checkboxes = document.querySelectorAll('#gmc-frame input[type="checkbox"]');
  2332.  
  2333. if (checkboxes.length > 0) {
  2334. checkboxes.forEach(checkbox => {
  2335. checkbox.classList.add('gmc-checkbox');
  2336. });
  2337. } else {
  2338. setTimeout(updateCheckboxes, 100);
  2339. }
  2340. }
  2341.  
  2342. updateCheckboxes();
  2343.  
  2344. const configVars = document.querySelectorAll('.config_var');
  2345.  
  2346. configVars.forEach(configVar => {
  2347. const label = configVar.querySelector('.field_label');
  2348. const input = configVar.querySelector('input');
  2349.  
  2350. if (label && input && input.type === 'text') label.style.lineHeight = '33px';
  2351.  
  2352. const select = configVar.querySelector('select');
  2353.  
  2354. if (label && select) label.style.lineHeight = '33px';
  2355. });
  2356.  
  2357. modifyThenObserve(() => {
  2358. document.querySelector('#gmc-frame .reset_holder').remove();
  2359.  
  2360. const buttonHolderSelector = '#gmc-frame_buttons_holder';
  2361. const parentDiv = document.querySelector(buttonHolderSelector);
  2362.  
  2363. if (!parentDiv) {
  2364. logError(`Selector ${buttonHolderSelector} not found`);
  2365. return;
  2366. }
  2367.  
  2368. gmcAddSavedSpan(parentDiv);
  2369. gmcAddNewIssueButton(parentDiv);
  2370. });
  2371.  
  2372. document.querySelector('#gmc').classList.remove('hidden');
  2373. }
  2374.  
  2375. function gmcRefreshTab() {
  2376. location.reload();
  2377. }
  2378.  
  2379. function gmcRunScript() {
  2380. applyCustomizations(true);
  2381. }
  2382.  
  2383. function gmcGet(key) {
  2384. log(DEBUG, 'gmcGet()');
  2385.  
  2386. try {
  2387. return GMC.get(key);
  2388. } catch (error) {
  2389. logError(`Error setting GMC, key=${key}`, error);
  2390. }
  2391. }
  2392.  
  2393. function gmcSet(key, value) {
  2394. log(DEBUG, 'gmcSet()');
  2395.  
  2396. try {
  2397. return GMC.set(key, value);
  2398. } catch (error) {
  2399. logError(`Error setting GMC, key=${key}, value=${value}`, error);
  2400. }
  2401. }
  2402.  
  2403. function gmcSave() {
  2404. log(DEBUG, 'gmcSave()');
  2405.  
  2406. try {
  2407. return gmcSave();
  2408. } catch (error) {
  2409. logError('Error saving GMC', error);
  2410. }
  2411. }
  2412.  
  2413. function updateLogLevel() {
  2414. CURRENT_LOG_LEVEL = LOG_LEVELS.getValue(gmcGet('log_level'));
  2415.  
  2416. if (LOG_LEVEL_OVERRIDE) CURRENT_LOG_LEVEL = LOG_LEVEL_OVERRIDE;
  2417. }
  2418.  
  2419. function gmcSaved() {
  2420. log(DEBUG, 'gmcSaved()');
  2421.  
  2422. const gmcSaved = document.getElementById('gmc-saved');
  2423.  
  2424. gmcSaved.style.display = 'block';
  2425.  
  2426. setTimeout(
  2427. () => gmcSaved.style.display = 'none',
  2428. 2750,
  2429. );
  2430.  
  2431. updateLogLevel();
  2432.  
  2433. switch (gmcGet('on_save')) {
  2434. case 'refresh tab':
  2435. gmcRefreshTab();
  2436. break;
  2437. case 'refresh tab and close':
  2438. gmcRefreshTab();
  2439. GMC.close();
  2440. break;
  2441. case 'run script':
  2442. gmcRunScript();
  2443. break;
  2444. case 'run script and close':
  2445. gmcRunScript();
  2446. GMC.close();
  2447. break;
  2448. }
  2449. }
  2450.  
  2451. function gmcClosed() {
  2452. log(DEBUG, 'gmcClosed()');
  2453.  
  2454. switch (gmcGet('on_close')) {
  2455. case 'refresh tab':
  2456. gmcRefreshTab();
  2457. break;
  2458. case 'run script':
  2459. gmcRunScript();
  2460. break;
  2461. }
  2462.  
  2463. document.querySelector('#gmc').classList.add('hidden');
  2464. }
  2465.  
  2466. function gmcClearCustom() {
  2467. log(DEBUG, 'gmcClearCustom()');
  2468.  
  2469. const confirmed = confirm('Are you sure you want to clear your custom configuration? This is irreversible.');
  2470.  
  2471. if (confirmed) {
  2472. const currentType = gmcGet('type');
  2473. GMC.reset();
  2474. gmcSave();
  2475.  
  2476. gmcSet('type', currentType);
  2477. gmcSave();
  2478. }
  2479. }
  2480.  
  2481. function configsToGMC(config, path = []) {
  2482. log(DEBUG, 'configsToGMC()');
  2483.  
  2484. for (const key in config) {
  2485. if (typeof config[key] === 'object' && !Array.isArray(config[key])) {
  2486. configsToGMC(config[key], path.concat(key));
  2487. } else {
  2488. const fieldName = path.concat(key).join('_');
  2489. const fieldValue = config[key];
  2490.  
  2491. log(VERBOSE, 'fieldName', fieldName);
  2492. gmcSet(fieldName, fieldValue);
  2493. }
  2494. }
  2495. }
  2496.  
  2497. function gmcApplyCustomHappyMediumConfig() {
  2498. log(DEBUG, 'gmcApplyCustomHappyMediumConfig()');
  2499.  
  2500. const confirmed = confirm('Are you sure you want to overwrite your custom configuration with Happy Medium? This is irreversible.');
  2501.  
  2502. if (confirmed) {
  2503. configsToGMC(configs.happyMedium);
  2504. gmcSave();
  2505. }
  2506. }
  2507.  
  2508. function gmcApplyCustomOldSchoolConfig() {
  2509. log(DEBUG, 'gmcApplyCustomOldSchoolConfig()');
  2510.  
  2511. const confirmed = confirm('Are you sure you want to overwrite your custom configuration with Old School? This is irreversible.');
  2512.  
  2513. if (confirmed) {
  2514. configsToGMC(configs.oldSchool);
  2515. gmcSave();
  2516. }
  2517. }
  2518.  
  2519. function gmcBuildStyle() {
  2520. log(DEBUG, 'gmcBuildStyle()');
  2521.  
  2522. const headerIdPartials = [
  2523. 'hamburgerButton_remove_var',
  2524. 'logo_remove_var',
  2525. 'pageTitle_remove_var',
  2526. 'search_remove_var',
  2527. 'divider_remove_var',
  2528. 'create_remove_var',
  2529. 'issues_remove_var',
  2530. 'pullRequests_remove_var',
  2531. 'marketplace_add_var',
  2532. 'explore_add_var',
  2533. 'notifications_remove_var',
  2534. 'light_avatar_remove_var',
  2535. 'dark_avatar_remove_var',
  2536. 'globalBar_boxShadowColor_var',
  2537. 'localBar_backgroundColor_var',
  2538. 'sidebars_backdrop_color_var',
  2539. 'repositoryHeader_import_var',
  2540. 'flipCreateInbox_var',
  2541. 'flipIssuesPullRequests_var',
  2542. ];
  2543.  
  2544. const sectionSelectors = headerIdPartials
  2545. .map(varName => `#gmc-frame .config_var[id*='${varName}']`)
  2546. .join(',\n');
  2547.  
  2548. const gmcFrameStyle = document.createElement('style');
  2549. gmcFrameStyle.textContent += `
  2550. /* Modal */
  2551.  
  2552. #gmc
  2553. {
  2554. display: inline-flex !important;
  2555. justify-content: center !important;
  2556. align-items: center !important;
  2557. position: fixed !important;
  2558. top: 0 !important;
  2559. left: 0 !important;
  2560. width: 100vw !important;
  2561. height: 100vh !important;
  2562. z-index: 9999;
  2563. background: none !important;
  2564.  
  2565. pointer-events: none;
  2566. }
  2567.  
  2568. #gmc.hidden
  2569. {
  2570. display: none !important;
  2571. }
  2572.  
  2573. #gmc-frame
  2574. {
  2575. font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
  2576. text-align: left;
  2577.  
  2578. inset: initial !important;
  2579. border: none !important;
  2580. max-height: initial !important;
  2581. max-width: initial !important;
  2582. opacity: 1 !important;
  2583. position: static !important;
  2584. z-index: initial !important;
  2585.  
  2586. width: 85% !important;
  2587. height: 75% !important;
  2588. overflow-y: auto !important;
  2589.  
  2590. border: none !important;
  2591. border-radius: 0.375rem !important;
  2592.  
  2593. pointer-events: auto;
  2594. }
  2595.  
  2596. #gmc-frame_wrapper
  2597. {
  2598. display: flow-root !important;
  2599. padding: 2rem !important;
  2600. }
  2601.  
  2602. /* Sections */
  2603.  
  2604. #gmc-frame #gmc-frame_section_0
  2605. {
  2606. width: 100%;
  2607. border-radius: 6px;
  2608. display: table;
  2609. }
  2610.  
  2611. #gmc-frame #gmc-frame_section_1,
  2612. #gmc-frame #gmc-frame_section_2,
  2613. #gmc-frame #gmc-frame_section_3,
  2614. #gmc-frame #gmc-frame_section_4
  2615. {
  2616. margin-top: 2rem;
  2617. width: 49%;
  2618. box-sizing: border-box;
  2619. }
  2620.  
  2621. #gmc-frame #gmc-frame_section_1
  2622. {
  2623. border-radius: 6px;
  2624. float: left;
  2625. }
  2626.  
  2627. #gmc-frame #gmc-frame_section_2
  2628. {
  2629. border-radius: 6px;
  2630. float: right;
  2631. }
  2632.  
  2633. #gmc-frame #gmc-frame_section_3
  2634. {
  2635. width: 49%;
  2636. margin-top: 2rem;
  2637. box-sizing: border-box;
  2638. border-radius: 6px;
  2639. float: left;
  2640. }
  2641.  
  2642. #gmc-frame #gmc-frame_section_4
  2643. {
  2644. display: inline-grid;
  2645. width: 49%;
  2646. margin-top: 2rem;
  2647. box-sizing: border-box;
  2648. border-radius: 6px;
  2649. float: right
  2650. }
  2651.  
  2652. #gmc-frame #gmc-frame_section_3 .config_var:not(:last-child),
  2653. #gmc-frame #gmc-frame_section_4 .config_var:not(:last-child)
  2654. {
  2655. padding-bottom: 1rem;
  2656. }
  2657.  
  2658. /* Fields */
  2659.  
  2660. #gmc-frame .config_header
  2661. {
  2662. font-size: 2em;
  2663. font-weight: 400;
  2664. line-height: 1.25;
  2665.  
  2666. padding-bottom: 0.3em;
  2667. margin-bottom: 16px;
  2668. }
  2669.  
  2670. #gmc-frame #gmc-frame_type_var
  2671. {
  2672. display: inline-flex;
  2673. }
  2674.  
  2675. #gmc-frame .section_header
  2676. {
  2677. font-size: 1.5em;
  2678. font-weight: 600;
  2679. line-height: 1.25;
  2680.  
  2681. margin-bottom: 16px;
  2682. padding: 1rem 1.5rem;
  2683. }
  2684.  
  2685. #gmc-frame .section_desc,
  2686. #gmc-frame h3
  2687. {
  2688. background: none;
  2689. border: none;
  2690. font-size: 1.25em;
  2691.  
  2692. margin-bottom: 16px;
  2693. font-weight: 600;
  2694. line-height: 1.25;
  2695. text-align: left;
  2696. }
  2697.  
  2698. #gmc-frame .config_var
  2699. {
  2700. padding: 0rem 1.5rem;
  2701. margin-bottom: 1rem;
  2702. display: flex;
  2703. }
  2704.  
  2705. ${sectionSelectors}
  2706. {
  2707. display: flow;
  2708. padding-top: 1rem;
  2709. }
  2710.  
  2711. #gmc-frame .config_var[id*='flipCreateInbox_var'],
  2712. #gmc-frame .config_var[id*='flipIssuesPullRequests_var']
  2713. {
  2714. display: flex;
  2715. }
  2716.  
  2717. #gmc-frame .field_label
  2718. {
  2719. font-weight: 600;
  2720. margin-right: 0.5rem;
  2721. }
  2722.  
  2723. #gmc-frame .field_label,
  2724. #gmc-frame .gmc-label
  2725. {
  2726. width: 15vw;
  2727. }
  2728.  
  2729. #gmc-frame .radio_label:not(:last-child)
  2730. {
  2731. margin-right: 4rem;
  2732. }
  2733.  
  2734. #gmc-frame .radio_label
  2735. {
  2736. line-height: 17px;
  2737. }
  2738.  
  2739. #gmc-frame .gmc-label
  2740. {
  2741. display: table-caption;
  2742. line-height: 17px;
  2743. }
  2744.  
  2745. #gmc-frame input[type="radio"]
  2746. {
  2747. appearance: none;
  2748. border-style: solid;
  2749. cursor: pointer;
  2750. height: 1rem;
  2751. place-content: center;
  2752. position: relative;
  2753. width: 1rem;
  2754. border-radius: 624rem;
  2755. transition: background-color 0s ease 0s, border-color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s;
  2756. margin-right: 0.5rem;
  2757. flex: none;
  2758. }
  2759.  
  2760. #gmc-frame input[type="checkbox"]
  2761. {
  2762. appearance: none;
  2763. border-style: solid;
  2764. border-width: 1px;
  2765. cursor: pointer;
  2766. place-content: center;
  2767. position: relative;
  2768. height: 17px;
  2769. width: 17px;
  2770. border-radius: 3px;
  2771. transition: background-color 0s ease 0s, border-color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s;
  2772. }
  2773.  
  2774. #gmc-frame #gmc-frame_field_type
  2775. {
  2776. display: flex;
  2777. }
  2778.  
  2779. #gmc-frame input[type="radio"]:checked
  2780. {
  2781. border-width: 0.25rem;
  2782. }
  2783.  
  2784. #gmc-frame input[type="radio"]:checked,
  2785. #gmc-frame .gmc-checkbox:checked
  2786. {
  2787. border-color: #2f81f7;
  2788. }
  2789.  
  2790. #gmc-frame .gmc-checkbox:checked
  2791. {
  2792. background-color: #2f81f7;
  2793. }
  2794.  
  2795. #gmc-frame .gmc-checkbox:checked::before
  2796. {
  2797. visibility: visible;
  2798. transition: visibility 0s linear 0s;
  2799. }
  2800.  
  2801. #gmc-frame .gmc-checkbox::before,
  2802. #gmc-frame .gmc-checkbox:indeterminate::before
  2803. {
  2804. animation: 80ms cubic-bezier(0.65, 0, 0.35, 1) 80ms 1 normal forwards running checkmarkIn;
  2805. }
  2806.  
  2807. #gmc-frame .gmc-checkbox::before
  2808. {
  2809. width: 1rem;
  2810. height: 1rem;
  2811. visibility: hidden;
  2812. content: "";
  2813. background-color: #FFFFFF;
  2814. clip-path: inset(1rem 0 0 0);
  2815. -webkit-mask-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iOSIgdmlld0JveD0iMCAwIDEyIDkiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMTEuNzgwMyAwLjIxOTYyNUMxMS45MjEgMC4zNjA0MjcgMTIgMC41NTEzMDUgMTIgMC43NTAzMTNDMTIgMC45NDkzMjEgMTEuOTIxIDEuMTQwMTkgMTEuNzgwMyAxLjI4MUw0LjUxODYgOC41NDA0MkM0LjM3Nzc1IDguNjgxIDQuMTg2ODIgOC43NiAzLjk4Nzc0IDguNzZDMy43ODg2NyA4Ljc2IDMuNTk3NzMgOC42ODEgMy40NTY4OSA4LjU0MDQyTDAuMjAxNjIyIDUuMjg2MkMwLjA2ODkyNzcgNS4xNDM4MyAtMC4wMDMzMDkwNSA0Ljk1NTU1IDAuMDAwMTE2NDkzIDQuNzYwOThDMC4wMDM1NTIwNSA0LjU2NjQzIDAuMDgyMzg5NCA0LjM4MDgxIDAuMjIwMDMyIDQuMjQzMjFDMC4zNTc2NjUgNC4xMDU2MiAwLjU0MzM1NSA0LjAyNjgxIDAuNzM3OTcgNC4wMjMzOEMwLjkzMjU4NCA0LjAxOTk0IDEuMTIwOTMgNC4wOTIxNyAxLjI2MzM0IDQuMjI0ODJMMy45ODc3NCA2Ljk0ODM1TDEwLjcxODYgMC4yMTk2MjVDMTAuODU5NSAwLjA3ODk5MjMgMTEuMDUwNCAwIDExLjI0OTUgMEMxMS40NDg1IDAgMTEuNjM5NSAwLjA3ODk5MjMgMTEuNzgwMyAwLjIxOTYyNVoiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPgo=");
  2816. -webkit-mask-size: 75%;
  2817. -webkit-mask-repeat: no-repeat;
  2818. -webkit-mask-position: center center;
  2819. display: block;
  2820. }
  2821.  
  2822. #gmc-frame .gmc-checkbox
  2823. {
  2824. appearance: none;
  2825. border-style: solid;
  2826. border-width: 1px;
  2827. cursor: pointer;
  2828.  
  2829. height: var(--base-size-16,16px);
  2830. margin: 0.125rem 0px 0px;
  2831. place-content: center;
  2832. position: relative;
  2833. width: var(--base-size-16,16px);
  2834. border-radius: 3px;
  2835. transition: background-color 0s ease 0s, border-color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s;
  2836. }
  2837.  
  2838. #gmc-frame input
  2839. {
  2840. color: fieldtext;
  2841. letter-spacing: normal;
  2842. word-spacing: normal;
  2843. text-transform: none;
  2844. text-indent: 0px;
  2845. text-shadow: none;
  2846. display: inline-block;
  2847. text-align: start;
  2848. appearance: auto;
  2849. -webkit-rtl-ordering: logical;
  2850. }
  2851.  
  2852. #gmc-frame .gmc-checkbox:checked
  2853. {
  2854. transition: background-color 0s ease 0s, border-color 80ms cubic-bezier(0.32, 0, 0.67, 0) 0ms;
  2855. }
  2856.  
  2857. #gmc-frame input[type="text"],
  2858. #gmc-frame textarea,
  2859. #gmc-frame select
  2860. {
  2861. padding: 5px 12px;
  2862. border-radius: 6px;
  2863. }
  2864.  
  2865. #gmc-frame input[type="text"]:focus,
  2866. #gmc-frame textarea:focus,
  2867. #gmc-frame select:focus
  2868. {
  2869. border-color: #2f81f7;
  2870. outline: 1px solid #2f81f7;
  2871. }
  2872.  
  2873. #gmc-frame svg
  2874. {
  2875. height: 17px;
  2876. width: 17px;
  2877. margin-left: 0.5rem;
  2878. }
  2879.  
  2880. #gmc small
  2881. {
  2882. font-size: x-small;
  2883. font-weight: 600;
  2884. margin-left: 3px;
  2885. }
  2886.  
  2887. /* Button bar */
  2888.  
  2889. #gmc-frame #gmc-frame_buttons_holder
  2890. {
  2891. position: fixed;
  2892. width: 85%;
  2893. text-align: right;
  2894.  
  2895. left: 50%;
  2896. bottom: 2%;
  2897. transform: translate(-50%, 0%);
  2898. padding: 1rem;
  2899.  
  2900. border-radius: 0.375rem;
  2901.  
  2902. display: flex;
  2903. align-items: center;
  2904. }
  2905.  
  2906. #gmc-frame #gmc-frame_buttons_holder .left-aligned
  2907. {
  2908. order: 1;
  2909. margin-right: auto;
  2910. }
  2911.  
  2912. #gmc-frame #gmc-frame_buttons_holder > *
  2913. {
  2914. order: 2;
  2915. }
  2916.  
  2917. #gmc-frame .saveclose_buttons
  2918. {
  2919. margin-left: 0.5rem;
  2920. }
  2921.  
  2922. #gmc-frame [type=button],
  2923. #gmc-frame .saveclose_buttons
  2924. {
  2925. position: relative;
  2926. display: inline-block;
  2927. padding: 5px 16px;
  2928. font-size: 14px;
  2929. font-weight: 500;
  2930. line-height: 20px;
  2931. white-space: nowrap;
  2932. vertical-align: middle;
  2933. cursor: pointer;
  2934. -webkit-user-select: none;
  2935. user-select: none;
  2936. border: 1px solid;
  2937. border-radius: 6px;
  2938. -webkit-appearance: none;
  2939. appearance: none;
  2940.  
  2941. font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
  2942. }
  2943.  
  2944. @keyframes fadeOut
  2945. {
  2946. from {
  2947. opacity: 1;
  2948. }
  2949. to {
  2950. opacity: 0;
  2951. }
  2952. }
  2953.  
  2954. #gmc-saved
  2955. {
  2956. display: none;
  2957. margin-right: 10px;
  2958. animation: fadeOut 0.75s ease 2s forwards;
  2959. }
  2960. `;
  2961.  
  2962. if (THEME === 'light') {
  2963. gmcFrameStyle.textContent += `
  2964. #gmc-frame
  2965. {
  2966. background-color: #F6F8FA;
  2967. color: #1F2328;
  2968. box-shadow: 0 0 0 1px #D0D7DE, 0 16px 32px rgba(1,4,9,0.2) !important;
  2969. }
  2970.  
  2971. #gmc-frame .section_header_holder
  2972. {
  2973. background-color: #FFFFFF;
  2974. border: 1px solid #D0D7DE;
  2975. }
  2976.  
  2977. #gmc-frame_buttons_holder
  2978. {
  2979. background-color: #FFFFFF;
  2980. box-shadow: 0 0 0 1px #D0D7DE, 0 16px 32px rgba(1,4,9,0.2) !important;
  2981. }
  2982.  
  2983. #gmc-frame input[type="text"],
  2984. #gmc-frame textarea,
  2985. #gmc-frame select
  2986. {
  2987. border: 1px solid #D0D7DE;
  2988. }
  2989.  
  2990. #gmc-frame select
  2991. {
  2992. background-color: #F6F8FA;
  2993. }
  2994.  
  2995. #gmc-frame select:hover
  2996. {
  2997. background-color: #F3F4F6;
  2998. border-color: #1F232826;
  2999. }
  3000.  
  3001. #gmc-frame input[type="text"],
  3002. #gmc-frame textarea
  3003. {
  3004. background-color: #F6F8FA;
  3005. color: #1F2328;
  3006. }
  3007.  
  3008. #gmc-frame input[type="text"]:focus,
  3009. #gmc-frame textarea:focus
  3010. {
  3011. background-color: #FFFFFF;
  3012. }
  3013.  
  3014. #gmc-frame [type=button],
  3015. #gmc-frame .saveclose_buttons
  3016. {
  3017. background-color: #f6f8fa;
  3018. border-color: #1f232826;
  3019. box-shadow: 0 1px 0 rgba(31,35,40,0.04), inset 0 1px 0 rgba(255,255,255,0.25);
  3020. color: #24292f;
  3021. }
  3022.  
  3023. #gmc-frame [type=button]:hover,
  3024. #gmc-frame .saveclose_buttons:hover
  3025. {
  3026. background-color: #f3f4f6;
  3027. border-color: #1f232826;
  3028. }
  3029.  
  3030. #gmc-frame .gmc-checkbox
  3031. {
  3032. border-color: #6E7781;
  3033. }
  3034.  
  3035. #gmc-frame input[type="radio"]
  3036. {
  3037. color: #6E7781;
  3038. }
  3039.  
  3040. #gmc-frame svg
  3041. {
  3042. fill: #000000;
  3043. }
  3044.  
  3045. #gmc-frame .section_header
  3046. {
  3047. border-bottom: 1px solid #D0D7DE;
  3048. }
  3049.  
  3050. ${sectionSelectors}
  3051. {
  3052. border-top: 1px solid #D0D7DE;
  3053. }
  3054.  
  3055. #gmc-frame #gmc-frame_section_3 .config_var:not(:last-child),
  3056. #gmc-frame #gmc-frame_section_4 .config_var:not(:last-child)
  3057. {
  3058. border-bottom: 1px solid #D0D7DE;
  3059. }
  3060.  
  3061. #gmc-frame #gmc-frame_saveBtn
  3062. {
  3063. background-color: #1F883D;
  3064. border-color: rgba(31, 35, 40, 0.15);
  3065. box-shadow: rgba(31, 35, 40, 0.1) 0px 1px 0px;
  3066. color: #FFFFFF;
  3067. }
  3068.  
  3069. #gmc-frame #gmc-frame_saveBtn:hover
  3070. {
  3071. background-color: rgb(26, 127, 55);
  3072. }
  3073.  
  3074. #gmc-frame #gmc-frame_section_4
  3075. {
  3076. border: 1px solid #FF818266;
  3077. }
  3078.  
  3079. #gmc-frame #gmc-frame_section_4 input
  3080. {
  3081. background-color: #F6F8FA;
  3082. border-color: #1F232826;
  3083. box-shadow: 0 1px 0 rgba(31,35,40,0.04), inset 0 1px 0 rgba(255,255,255,0.25);
  3084. color: #CF222E;
  3085. }
  3086.  
  3087. #gmc-frame #gmc-frame_section_4 input:hover
  3088. {
  3089. background-color: #A40E26;
  3090. border-color: #1F232826;
  3091. box-shadow: 0 1px 0 rgba(31,35,40,0.04);
  3092. color: #ffffff;
  3093. }
  3094.  
  3095. #gmc-saved
  3096. {
  3097. color: #1a7f37;
  3098. }
  3099.  
  3100. #gmc-saved svg path
  3101. {
  3102. fill: #1a7f37;
  3103. }
  3104. `;
  3105. } else if (THEME === 'dark') {
  3106. gmcFrameStyle.textContent += `
  3107. #gmc-frame
  3108. {
  3109. background-color: #161B22;
  3110. color: #E6EDF3;
  3111. box-shadow: 0 0 0 1px #30363D, 0 16px 32px #010409 !important;
  3112. }
  3113.  
  3114. #gmc-frame .section_header_holder
  3115. {
  3116. background-color: #0D1117;
  3117. border: 1px solid #30363D;
  3118. }
  3119.  
  3120. #gmc-frame_buttons_holder
  3121. {
  3122. background-color: #161B22;
  3123. box-shadow: 0 0 0 1px #30363D, 0 16px 32px #010409 !important;
  3124. }
  3125.  
  3126. #gmc-frame input[type="text"],
  3127. #gmc-frame textarea,
  3128. #gmc-frame select
  3129. {
  3130. border: 1px solid #5B626C;
  3131. }
  3132.  
  3133. #gmc-frame input[type="text"],
  3134. #gmc-frame textarea
  3135. {
  3136. background-color: #010409;
  3137. color: #FFFFFF;
  3138. }
  3139.  
  3140. #gmc-frame [type=button]:hover,
  3141. #gmc-frame .saveclose_buttons:hover
  3142. {
  3143. background-color: #30363d;
  3144. border-color: #8b949e;
  3145. }
  3146.  
  3147. #gmc-frame .gmc-checkbox
  3148. {
  3149. border-color: #6E7681;
  3150. }
  3151.  
  3152. #gmc-frame input[type="radio"]
  3153. {
  3154. color: #6D7681;
  3155. }
  3156.  
  3157. #gmc-frame input[type="text"]:focus,
  3158. textarea:focus
  3159. {
  3160. background-color: #0D1117;
  3161. }
  3162.  
  3163. #gmc-frame [type=button],
  3164. #gmc-frame .saveclose_buttons
  3165. {
  3166. color: #c9d1d9;
  3167. background-color: #21262d;
  3168. border-color: #f0f6fc1a;
  3169. }
  3170.  
  3171. #gmc-frame svg
  3172. {
  3173. fill: #E6EDF3;
  3174. }
  3175.  
  3176. #gmc-frame .section_header
  3177. {
  3178. border-bottom: 1px solid #30363D;
  3179. }
  3180.  
  3181. ${sectionSelectors}
  3182. {
  3183. border-top: 1px solid #30363D;
  3184. }
  3185.  
  3186. #gmc-frame #gmc-frame_section_3 .config_var:not(:last-child),
  3187. #gmc-frame #gmc-frame_section_4 .config_var:not(:last-child)
  3188. {
  3189. padding-bottom: 1rem;
  3190. border-bottom: 1px solid #30363D;
  3191. }
  3192.  
  3193. #gmc-frame #gmc-frame_saveBtn
  3194. {
  3195. background-color: #238636;
  3196. border-color: #F0F6FC1A;
  3197. box-shadow: 0 0 transparent;
  3198. color: #FFFFFF;
  3199. }
  3200.  
  3201. #gmc-frame #gmc-frame_saveBtn:hover
  3202. {
  3203. background-color: #2EA043;
  3204. border-color: #F0F6FC1A;
  3205. }
  3206.  
  3207. #gmc-frame #gmc-frame_section_4
  3208. {
  3209. border: 1px solid #f8514966;
  3210. }
  3211.  
  3212. #gmc-frame #gmc-frame_section_4 input
  3213. {
  3214. background-color: #21262D;
  3215. border-color: #F0F6FC1A;
  3216. }
  3217.  
  3218. #gmc-frame #gmc-frame_section_4 input
  3219. {
  3220. color: #F85149;
  3221. }
  3222.  
  3223. #gmc-frame #gmc-frame_section_4 input:hover
  3224. {
  3225. background-color: #DA3633;
  3226. border-color: #F85149;
  3227. color: #FFFFFF;
  3228. }
  3229.  
  3230. #gmc-saved
  3231. {
  3232. color: #3FB950;
  3233. }
  3234.  
  3235. #gmc-saved svg path
  3236. {
  3237. fill: #3FB950;
  3238. }
  3239. `;
  3240. }
  3241.  
  3242. document.head.appendChild(gmcFrameStyle);
  3243. }
  3244.  
  3245. function gmcBuildFrame() {
  3246. log(DEBUG, 'gmcBuildFrame()');
  3247.  
  3248. const body = document.querySelector('body');
  3249. const gmcDiv = document.createElement('div');
  3250.  
  3251. gmcDiv.setAttribute('id', 'gmc');
  3252. gmcDiv.classList.add('hidden');
  3253.  
  3254. body.appendChild(gmcDiv);
  3255.  
  3256. const gmcFrameDiv = document.createElement('div');
  3257. gmcFrameDiv.setAttribute('id', 'gmc-frame');
  3258.  
  3259. gmcDiv.appendChild(gmcFrameDiv);
  3260.  
  3261. gmcBuildStyle();
  3262.  
  3263. return gmcFrameDiv;
  3264. }
  3265.  
  3266. function applyCustomizations(refresh = false) {
  3267. log(DEBUG, 'applyCustomizations()');
  3268.  
  3269. log(DEBUG, 'refresh', refresh);
  3270.  
  3271. HEADER = document.querySelector(SELECTORS.header.self);
  3272.  
  3273. if (!HEADER) return 'continue';
  3274.  
  3275. const featurePreviewButton = document.querySelector(SELECTORS.avatar.button);
  3276.  
  3277. if (!featurePreviewButton) {
  3278. logError(`Selector ${SELECTORS.avatar.button} not found`);
  3279. return 'break';
  3280. }
  3281.  
  3282. featurePreviewButton.addEventListener('click', waitForFeaturePreviewButton);
  3283.  
  3284. CONFIG_NAME = {
  3285. 'Off': 'off',
  3286. 'Happy Medium': 'happyMedium',
  3287. 'Old School': 'oldSchool',
  3288. 'Custom': 'custom',
  3289. }[gmcGet('type')];
  3290.  
  3291. log(DEBUG, 'CONFIG_NAME', CONFIG_NAME);
  3292.  
  3293. if (CONFIG_NAME === 'off') return 'break';
  3294.  
  3295. if (CONFIG_NAME === 'custom') configs.custom = generateCustomConfig();
  3296.  
  3297. CONFIG = configs[CONFIG_NAME][THEME];
  3298.  
  3299. log(VERBOSE, 'CONFIG', CONFIG);
  3300.  
  3301. const headerSuccessFlag = 'customizedHeader';
  3302.  
  3303. const foundHeaderSuccessFlag = document.getElementById(headerSuccessFlag);
  3304. log(DEBUG, 'foundHeaderSuccessFlag', foundHeaderSuccessFlag);
  3305.  
  3306. const configurationApplied = HEADER.classList.contains(CONFIG_NAME);
  3307.  
  3308. if (!configurationApplied && (foundHeaderSuccessFlag === null || refresh)) {
  3309. updateSelectors();
  3310.  
  3311. if (refresh) {
  3312. modifyThenObserve(() => {
  3313. document.querySelector(createId(SELECTORS.header.style))?.remove();
  3314. HEADER_STYLE.textContent = '';
  3315.  
  3316. HEADER.classList.remove(OLD_CONFIG_NAME);
  3317. NEW_ELEMENTS.forEach((element) => element.remove());
  3318. });
  3319. }
  3320.  
  3321. if (CONFIG_NAME === 'oldSchool') {
  3322. HEADER_STYLE.textContent += `
  3323. @media (max-width: 767.98px)
  3324. {
  3325. action-menu
  3326. {
  3327. display: none !important;
  3328. }
  3329. }
  3330.  
  3331. .AppHeader .AppHeader-globalBar .AppHeader-search input[type=search],
  3332. .AppHeader .AppHeader-globalBar .AppHeader-search .AppHeader-searchButton
  3333. {
  3334. padding-right: 4px;
  3335. }
  3336. `;
  3337. }
  3338.  
  3339. HEADER_UPDATES_COUNT++;
  3340. updateHeader();
  3341.  
  3342. HEADER.setAttribute('id', headerSuccessFlag);
  3343. HEADER.classList.add(CONFIG_NAME);
  3344.  
  3345. OLD_CONFIG_NAME = CONFIG_NAME;
  3346.  
  3347. log(QUIET, 'Complete');
  3348.  
  3349. return 'break';
  3350. } else {
  3351. if (CONFIG.avatar.dropdownIcon) insertAvatarDropdown();
  3352.  
  3353. if (CONFIG.repositoryHeader.import) {
  3354. // When starting in a repository tab like Issues, the proper repository header
  3355. // (including Unwatch, Star, and Fork) is not present per GitHub's design.
  3356. // If page title is removed, the page will be missing any location context in the header.
  3357. // To improve this experience, a temporary repository header is created with the
  3358. // page title or breadcrumbs.
  3359. // The proper repository header replaces the temporary one when navigating to the Code tab.
  3360. if (
  3361. !document.querySelector(SELECTORS.repositoryHeader.id)?.hidden &&
  3362. (
  3363. document.querySelector(createId(TEMP_REPOSITORY_HEADER_FLAG)) ||
  3364. !document.querySelector(`.${REPOSITORY_HEADER_SUCCESS_FLAG}`)
  3365. )
  3366. ) {
  3367. const updated = importRepositoryHeader();
  3368.  
  3369. if (updated) {
  3370. HEADER_UPDATES_COUNT++;
  3371. log(QUIET, 'Repository header updated');
  3372. } else {
  3373. IDLE_MUTATION_COUNT++;
  3374. }
  3375.  
  3376. return 'break';
  3377. }
  3378. }
  3379. }
  3380.  
  3381. if (CONFIG.avatar.dropdownIcon) insertAvatarDropdown();
  3382. }
  3383.  
  3384. function startObserving() {
  3385. log(DEBUG, 'startObserving()');
  3386.  
  3387. OBSERVER.observe(
  3388. document.body,
  3389. {
  3390. childList: true,
  3391. subtree: true,
  3392. },
  3393. );
  3394. }
  3395.  
  3396. function modifyThenObserve(callback) {
  3397. log(DEBUG, 'modifyThenObserve()');
  3398. OBSERVER.disconnect();
  3399.  
  3400. callback();
  3401.  
  3402. startObserving();
  3403. }
  3404.  
  3405. function observeAndModify(mutationsList) {
  3406. log(VERBOSE, 'observeAndModify()');
  3407.  
  3408. if (IDLE_MUTATION_COUNT > MAX_IDLE_MUTATIONS) {
  3409. // This is a failsafe to prevent infinite loops
  3410. logError('MAX_IDLE_MUTATIONS exceeded');
  3411. OBSERVER.disconnect();
  3412.  
  3413. return;
  3414. } else if (HEADER_UPDATES_COUNT >= MAX_HEADER_UPDATES) {
  3415. // This is a failsafe to prevent infinite loops
  3416. logError('MAX_HEADER_UPDATES exceeded');
  3417. OBSERVER.disconnect();
  3418.  
  3419. return;
  3420. }
  3421.  
  3422. for (const mutation of mutationsList) {
  3423. // Use header id to determine if updates have already been applied
  3424. if (mutation.type !== 'childList') return;
  3425.  
  3426. log(TRACE, 'mutation', mutation);
  3427.  
  3428. const outcome = applyCustomizations();
  3429.  
  3430. log(DEBUG, 'outcome', outcome);
  3431.  
  3432. if (outcome === 'continue') continue;
  3433. if (outcome === 'break') break;
  3434. }
  3435. }
  3436.  
  3437. const UNICODE_NON_BREAKING_SPACE = '\u00A0';
  3438. const REPOSITORY_HEADER_SUCCESS_FLAG = 'permCustomizedRepositoryHeader';
  3439. const TEMP_REPOSITORY_HEADER_FLAG = 'tempCustomizedRepositoryHeader';
  3440. const REPOSITORY_HEADER_CLASS = 'customizedRepositoryHeader';
  3441. const MAX_IDLE_MUTATIONS = 1000;
  3442. const MAX_HEADER_UPDATES = 100;
  3443.  
  3444. let CONFIG;
  3445. let CONFIG_NAME;
  3446. let OLD_CONFIG_NAME;
  3447. let HEADER;
  3448.  
  3449. let HEADER_STYLE = document.createElement('style');
  3450. let THEME = 'light';
  3451. let NEW_ELEMENTS = [];
  3452. let LEFT_SIDEBAR_PRELOADED = false;
  3453. let IDLE_MUTATION_COUNT = 0;
  3454. let HEADER_UPDATES_COUNT = 0;
  3455. let SELECTORS = {
  3456. header: {
  3457. self: 'header.AppHeader',
  3458. actionsDiv: '.AppHeader-actions',
  3459. globalBar: '.AppHeader-globalBar',
  3460. localBar: {
  3461. topDiv: '.AppHeader-localBar',
  3462. underlineNavActions: '.UnderlineNav-actions',
  3463. },
  3464. leftAligned: '.AppHeader-globalBar-start',
  3465. rightAligned: '.AppHeader-globalBar-end',
  3466. style: 'customHeaderStyle',
  3467. },
  3468. logo: {
  3469. topDiv: '.AppHeader-globalBar-start .AppHeader-logo',
  3470. svg: '.AppHeader-logo svg',
  3471. },
  3472. hamburgerButton: '.AppHeader-globalBar-start deferred-side-panel',
  3473. pageTitle: {
  3474. id: 'custom-page-title',
  3475. topDiv: '.AppHeader-context',
  3476. links: '.AppHeader-context a',
  3477. separator: '.AppHeader-context-item-separator',
  3478. },
  3479. search: {
  3480. id: 'search-div',
  3481. topDiv: '.AppHeader-search',
  3482. input: '.search-input',
  3483. button: '[data-target="qbsearch-input.inputButton"]',
  3484. magnifyingGlassIcon: '.AppHeader-search-control label',
  3485. commandPalette: '#AppHeader-commandPalette-button',
  3486. placeholderSpan: '#qb-input-query',
  3487. placeholderDiv: '.AppHeader-search-control .overflow-hidden',
  3488. modal: '[data-target="qbsearch-input.queryBuilderContainer"]',
  3489. },
  3490. copilot: {
  3491. id: 'copilot-div',
  3492. topDiv: '.AppHeader-CopilotChat',
  3493. button: '#copilot-chat-header-button',
  3494. textContent: 'copilot-text-content-span',
  3495. },
  3496. create: {
  3497. id: 'create-div',
  3498. topDiv: '.AppHeader-actions react-partial-anchor',
  3499. button: '#global-create-menu-anchor',
  3500. overlay: '#global-create-menu-overlay',
  3501. plusIcon: '#global-create-menu-anchor .Button-visual.Button-leadingVisual',
  3502. dropdownIcon: '#global-create-menu-anchor .Button-label',
  3503. textContent: 'create-text-content-span',
  3504. },
  3505. issues: {
  3506. id: 'issues',
  3507. textContent: 'issues-text-content-span',
  3508. },
  3509. pullRequests: {
  3510. id: 'pullRequests',
  3511. link: '.AppHeader-globalBar-end .AppHeader-actions a[href="/pulls"]',
  3512. textContent: 'pullRequests-text-content-span',
  3513. },
  3514. marketplace: {
  3515. id: 'marketplace',
  3516. link: '.AppHeader-globalBar-end .AppHeader-actions a[href="/marketplace"]',
  3517. textContent: 'marketplace-text-content-span',
  3518. },
  3519. explore: {
  3520. id: 'explore',
  3521. link: '.AppHeader-globalBar-end .AppHeader-actions a[href="/explore"]',
  3522. textContent: 'explore-text-content-span',
  3523. },
  3524. notifications: {
  3525. id: 'custom-notifications',
  3526. indicator: 'notification-indicator',
  3527. dot: '.AppHeader-button.AppHeader-button--hasIndicator::before',
  3528. textContent: 'textContent-text-content-spa',
  3529. },
  3530. avatar: {
  3531. topDiv: '.AppHeader-user',
  3532. button: '.AppHeader-user button',
  3533. img: '.AppHeader-user button img.avatar',
  3534. svg: 'avatar-dropdown',
  3535. },
  3536. repositoryHeader: {
  3537. id: '#repository-container-header',
  3538. ownerImg: `.${REPOSITORY_HEADER_CLASS} img`,
  3539. name: `.${REPOSITORY_HEADER_CLASS} strong`,
  3540. nav: `.${REPOSITORY_HEADER_CLASS} nav[role="navigation"]`,
  3541. links: `.${REPOSITORY_HEADER_CLASS} nav[role="navigation"] a`,
  3542. details: '#repository-details-container',
  3543. bottomBorder: `.${REPOSITORY_HEADER_CLASS} .border-bottom.mx-xl-5`,
  3544. },
  3545. sidebars: {
  3546. left: {
  3547. backdrop: 'dialog[data-target="deferred-side-panel.panel"]::backdrop',
  3548. modalDialog: '.Overlay--placement-left',
  3549. },
  3550. right: {
  3551. topDiv: '#__primerPortalRoot__',
  3552. wrapper: '#__primerPortalRoot__ > div',
  3553. backdrop: '#__primerPortalRoot__ > div > [data-position-regular="right"]',
  3554. modalDialog: '#__primerPortalRoot__ > div > [data-position-regular="right"] > div',
  3555. closeButton: '#__primerPortalRoot__ button[aria-label="Close"]',
  3556. divider: 'li[data-component="ActionList.Divider"]',
  3557. },
  3558. },
  3559. };
  3560.  
  3561. HEADER_STYLE.setAttribute('id', SELECTORS.header.style);
  3562.  
  3563. setTheme();
  3564.  
  3565. const oldSchoolColor = '#F0F6FC';
  3566. const oldSchoolHoverColor = '#FFFFFFB3';
  3567. const oldSchoolHoverBackgroundColor = 'transparent';
  3568. let configs = {
  3569. happyMedium: {
  3570. light: {
  3571. backgroundColor: '',
  3572. hamburgerButton: {
  3573. remove: false,
  3574. },
  3575. logo: {
  3576. remove: false,
  3577. color: '',
  3578. customSvg: '',
  3579. },
  3580. pageTitle: {
  3581. remove: false,
  3582. color: '',
  3583. hover: {
  3584. backgroundColor: '',
  3585. color: '',
  3586. },
  3587. },
  3588. search: {
  3589. remove: false,
  3590. backgroundColor: '',
  3591. borderColor: '',
  3592. boxShadow: '',
  3593. alignLeft: false,
  3594. width: 'max',
  3595. margin: {
  3596. left: '',
  3597. right: '',
  3598. },
  3599. magnifyingGlassIcon: {
  3600. remove: false,
  3601. },
  3602. placeholder: {
  3603. text: '',
  3604. color: '',
  3605. },
  3606. rightButton: 'command palette',
  3607. modal: {
  3608. width: '',
  3609. },
  3610. },
  3611. copilot: {
  3612. remove: false,
  3613. border: true,
  3614. tooltip: false,
  3615. alignLeft: false,
  3616. boxShadow: '',
  3617. icon: {
  3618. remove: false,
  3619. color: '',
  3620. },
  3621. text: {
  3622. content: 'Copilot',
  3623. color: '',
  3624. },
  3625. hover: {
  3626. backgroundColor: '',
  3627. color: '',
  3628. },
  3629. },
  3630. divider: {
  3631. remove: true,
  3632. },
  3633. flipCreateInbox: false,
  3634. create: {
  3635. remove: false,
  3636. border: true,
  3637. tooltip: false,
  3638. boxShadow: '',
  3639. hoverBackgroundColor: '',
  3640. plusIcon: {
  3641. remove: false,
  3642. color: '',
  3643. marginRight: '0.25rem',
  3644. hover: {
  3645. color: '',
  3646. },
  3647. },
  3648. text: {
  3649. content: 'Create',
  3650. color: '',
  3651. },
  3652. dropdownIcon: {
  3653. remove: false,
  3654. color: '',
  3655. hover: {
  3656. color: '',
  3657. },
  3658. },
  3659. },
  3660. flipIssuesPullRequests: true,
  3661. issues: {
  3662. remove: false,
  3663. border: true,
  3664. tooltip: false,
  3665. alignLeft: false,
  3666. boxShadow: '',
  3667. icon: {
  3668. remove: false,
  3669. color: '',
  3670. },
  3671. text: {
  3672. content: 'Issues',
  3673. color: '',
  3674. },
  3675. hover: {
  3676. backgroundColor: '',
  3677. color: '',
  3678. },
  3679. },
  3680. pullRequests: {
  3681. remove: false,
  3682. border: true,
  3683. tooltip: false,
  3684. alignLeft: false,
  3685. boxShadow: '',
  3686. icon: {
  3687. remove: false,
  3688. color: '',
  3689. },
  3690. text: {
  3691. content: 'Pull requests',
  3692. color: '',
  3693. },
  3694. hover: {
  3695. backgroundColor: '',
  3696. color: '',
  3697. },
  3698. },
  3699. marketplace: {
  3700. add: false,
  3701. border: false,
  3702. alignLeft: false,
  3703. boxShadow: '',
  3704. icon: {
  3705. remove: false,
  3706. color: '',
  3707. },
  3708. text: {
  3709. content: 'Marketplace',
  3710. color: '',
  3711. },
  3712. hover: {
  3713. backgroundColor: '',
  3714. color: '',
  3715. },
  3716. },
  3717. explore: {
  3718. add: false,
  3719. border: false,
  3720. alignLeft: false,
  3721. boxShadow: '',
  3722. icon: {
  3723. remove: false,
  3724. color: '',
  3725. },
  3726. text: {
  3727. content: 'Explore',
  3728. color: '',
  3729. },
  3730. hover: {
  3731. backgroundColor: '',
  3732. color: '',
  3733. },
  3734. },
  3735. notifications: {
  3736. remove: false,
  3737. border: true,
  3738. tooltip: false,
  3739. boxShadow: '',
  3740. hoverBackgroundColor: '',
  3741. icon: {
  3742. symbol: 'bell', // Accepts 'inbox', 'bell', or ''
  3743. color: '',
  3744. hover: {
  3745. color: '',
  3746. },
  3747. },
  3748. text: {
  3749. content: 'Inbox',
  3750. color: '',
  3751. },
  3752. dot: {
  3753. remove: false,
  3754. boxShadowColor: '',
  3755. color: '',
  3756. displayOverIcon: true,
  3757. },
  3758. },
  3759. avatar: {
  3760. remove: false,
  3761. size: '',
  3762. dropdownIcon: false,
  3763. },
  3764. globalBar: {
  3765. boxShadowColor: '',
  3766. leftAligned: {
  3767. gap: '',
  3768. },
  3769. rightAligned: {
  3770. gap: '',
  3771. },
  3772. },
  3773. localBar: {
  3774. backgroundColor: '#F6F8FA',
  3775. alignCenter: false,
  3776. boxShadow: {
  3777. consistentColor: true,
  3778. },
  3779. links: {
  3780. color: '',
  3781. },
  3782. },
  3783. sidebars: {
  3784. backdrop: {
  3785. color: 'transparent',
  3786. },
  3787. left: {
  3788. preload: true,
  3789. },
  3790. right: {
  3791. preload: true,
  3792. floatUnderneath: false,
  3793. width: '',
  3794. maxHeight: '',
  3795. },
  3796. },
  3797. repositoryHeader: {
  3798. import: true,
  3799. alignCenter: false,
  3800. removePageTitle: true,
  3801. backgroundColor: '#F6F8FA',
  3802. avatar: {
  3803. remove: false,
  3804. customSvg: '',
  3805. },
  3806. link: {
  3807. color: '',
  3808. hover: {
  3809. backgroundColor: 'transparent',
  3810. color: 'var(--color-accent-fg)',
  3811. textDecoration: 'underline',
  3812. },
  3813. },
  3814. },
  3815. },
  3816. dark: {
  3817. backgroundColor: '',
  3818. hamburgerButton: {
  3819. remove: false,
  3820. },
  3821. logo: {
  3822. remove: false,
  3823. color: '',
  3824. customSvg: '',
  3825. },
  3826. pageTitle: {
  3827. remove: false,
  3828. color: '',
  3829. hover: {
  3830. backgroundColor: '',
  3831. color: '',
  3832. },
  3833. },
  3834. search: {
  3835. remove: false,
  3836. backgroundColor: '',
  3837. borderColor: '',
  3838. boxShadow: '',
  3839. alignLeft: false,
  3840. width: 'max',
  3841. margin: {
  3842. left: '',
  3843. right: '',
  3844. },
  3845. magnifyingGlassIcon: {
  3846. remove: false,
  3847. },
  3848. placeholder: {
  3849. text: '',
  3850. color: '',
  3851. },
  3852. rightButton: 'command palette',
  3853. modal: {
  3854. width: '',
  3855. },
  3856. },
  3857. copilot: {
  3858. remove: false,
  3859. border: true,
  3860. tooltip: false,
  3861. alignLeft: false,
  3862. boxShadow: '',
  3863. icon: {
  3864. remove: false,
  3865. color: '',
  3866. },
  3867. text: {
  3868. content: 'Copilot',
  3869. color: '',
  3870. },
  3871. hover: {
  3872. backgroundColor: '',
  3873. color: '',
  3874. },
  3875. },
  3876. divider: {
  3877. remove: true,
  3878. },
  3879. flipCreateInbox: false,
  3880. create: {
  3881. remove: false,
  3882. border: true,
  3883. tooltip: false,
  3884. boxShadow: '',
  3885. hoverBackgroundColor: '',
  3886. plusIcon: {
  3887. remove: false,
  3888. color: '',
  3889. marginRight: '0.25rem',
  3890. hover: {
  3891. color: '',
  3892. },
  3893. },
  3894. text: {
  3895. content: 'Create',
  3896. color: '',
  3897. },
  3898. dropdownIcon: {
  3899. remove: false,
  3900. color: '',
  3901. hover: {
  3902. color: '',
  3903. },
  3904. },
  3905. },
  3906. flipIssuesPullRequests: true,
  3907. issues: {
  3908. remove: false,
  3909. border: true,
  3910. tooltip: false,
  3911. alignLeft: false,
  3912. boxShadow: '',
  3913. icon: {
  3914. remove: false,
  3915. color: '',
  3916. },
  3917. text: {
  3918. content: 'Issues',
  3919. color: '',
  3920. },
  3921. hover: {
  3922. backgroundColor: '',
  3923. color: '',
  3924. },
  3925. },
  3926. pullRequests: {
  3927. remove: false,
  3928. border: true,
  3929. tooltip: false,
  3930. alignLeft: false,
  3931. boxShadow: '',
  3932. icon: {
  3933. remove: false,
  3934. color: '',
  3935. },
  3936. text: {
  3937. content: 'Pull requests',
  3938. color: '',
  3939. },
  3940. hover: {
  3941. backgroundColor: '',
  3942. color: '',
  3943. },
  3944. },
  3945. marketplace: {
  3946. add: false,
  3947. border: false,
  3948. alignLeft: false,
  3949. boxShadow: '',
  3950. icon: {
  3951. remove: false,
  3952. color: '',
  3953. },
  3954. text: {
  3955. content: 'Marketplace',
  3956. color: '',
  3957. },
  3958. hover: {
  3959. backgroundColor: '',
  3960. color: '',
  3961. },
  3962. },
  3963. explore: {
  3964. add: false,
  3965. border: false,
  3966. alignLeft: false,
  3967. boxShadow: '',
  3968. icon: {
  3969. remove: false,
  3970. color: '',
  3971. },
  3972. text: {
  3973. content: 'Explore',
  3974. color: '',
  3975. },
  3976. hover: {
  3977. backgroundColor: '',
  3978. color: '',
  3979. },
  3980. },
  3981. notifications: {
  3982. remove: false,
  3983. border: true,
  3984. tooltip: false,
  3985. boxShadow: '',
  3986. hoverBackgroundColor: '',
  3987. icon: {
  3988. symbol: 'bell', // Accepts 'inbox', 'bell', or ''
  3989. color: '',
  3990. hover: {
  3991. color: '',
  3992. },
  3993. },
  3994. text: {
  3995. content: 'Inbox',
  3996. color: '',
  3997. },
  3998. dot: {
  3999. remove: false,
  4000. boxShadowColor: '',
  4001. color: '',
  4002. displayOverIcon: true,
  4003. },
  4004. },
  4005. avatar: {
  4006. remove: false,
  4007. size: '',
  4008. dropdownIcon: false,
  4009. },
  4010. globalBar: {
  4011. boxShadowColor: '',
  4012. leftAligned: {
  4013. gap: '',
  4014. },
  4015. rightAligned: {
  4016. gap: '',
  4017. },
  4018. },
  4019. localBar: {
  4020. backgroundColor: '#02040A',
  4021. alignCenter: false,
  4022. boxShadow: {
  4023. consistentColor: true,
  4024. },
  4025. links: {
  4026. color: '',
  4027. },
  4028. },
  4029. sidebars: {
  4030. backdrop: {
  4031. color: 'transparent',
  4032. },
  4033. left: {
  4034. preload: true,
  4035. },
  4036. right: {
  4037. preload: true,
  4038. floatUnderneath: false,
  4039. width: '',
  4040. maxHeight: '',
  4041. },
  4042. },
  4043. repositoryHeader: {
  4044. import: true,
  4045. alignCenter: false,
  4046. removePageTitle: true,
  4047. backgroundColor: '#02040A',
  4048. avatar: {
  4049. remove: false,
  4050. customSvg: '',
  4051. },
  4052. link: {
  4053. color: '#6AAFF9',
  4054. hover: {
  4055. backgroundColor: 'transparent',
  4056. color: 'var(--color-accent-fg)',
  4057. textDecoration: 'underline',
  4058. },
  4059. },
  4060. },
  4061. },
  4062. },
  4063. oldSchool: {
  4064. light: {
  4065. backgroundColor: '#161C20',
  4066. hamburgerButton: {
  4067. remove: true,
  4068. },
  4069. logo: {
  4070. remove: false,
  4071. color: '#e6edf3',
  4072. customSvg: '',
  4073. },
  4074. pageTitle: {
  4075. remove: true,
  4076. color: oldSchoolColor,
  4077. hover: {
  4078. backgroundColor: oldSchoolHoverBackgroundColor,
  4079. color: oldSchoolHoverColor,
  4080. },
  4081. },
  4082. search: {
  4083. remove: false,
  4084. backgroundColor: '#494D54',
  4085. borderColor: '#30363d',
  4086. boxShadow: 'none',
  4087. alignLeft: true,
  4088. width: 'calc(var(--feed-sidebar) - 67px)',
  4089. margin: {
  4090. left: '',
  4091. right: '',
  4092. },
  4093. magnifyingGlassIcon: {
  4094. remove: true,
  4095. },
  4096. placeholder: {
  4097. text: 'Search or jump to...',
  4098. color: '#B3B3B5',
  4099. },
  4100. rightButton: 'slash key',
  4101. modal: {
  4102. width: '450px',
  4103. },
  4104. },
  4105. copilot: {
  4106. remove: true,
  4107. border: false,
  4108. tooltip: false,
  4109. alignLeft: true,
  4110. boxShadow: 'none',
  4111. icon: {
  4112. remove: false,
  4113. color: '',
  4114. },
  4115. text: {
  4116. content: 'Copilot',
  4117. color: oldSchoolColor,
  4118. },
  4119. hover: {
  4120. backgroundColor: oldSchoolHoverBackgroundColor,
  4121. color: oldSchoolHoverColor,
  4122. },
  4123. },
  4124. divider: {
  4125. remove: true,
  4126. },
  4127. flipCreateInbox: true,
  4128. create: {
  4129. remove: false,
  4130. border: false,
  4131. tooltip: false,
  4132. boxShadow: 'none',
  4133. hoverBackgroundColor: oldSchoolHoverBackgroundColor,
  4134. plusIcon: {
  4135. remove: false,
  4136. color: oldSchoolColor,
  4137. marginRight: '0px',
  4138. hover: {
  4139. color: oldSchoolHoverColor,
  4140. },
  4141. },
  4142. text: {
  4143. content: '',
  4144. color: '',
  4145. },
  4146. dropdownIcon: {
  4147. remove: false,
  4148. color: oldSchoolColor,
  4149. hover: {
  4150. color: oldSchoolHoverColor,
  4151. },
  4152. },
  4153. },
  4154. flipIssuesPullRequests: true,
  4155. issues: {
  4156. remove: false,
  4157. border: false,
  4158. tooltip: false,
  4159. alignLeft: true,
  4160. boxShadow: 'none',
  4161. icon: {
  4162. remove: true,
  4163. color: '',
  4164. },
  4165. text: {
  4166. content: 'Issues',
  4167. color: oldSchoolColor,
  4168. },
  4169. hover: {
  4170. backgroundColor: oldSchoolHoverBackgroundColor,
  4171. color: oldSchoolHoverColor,
  4172. },
  4173. },
  4174. pullRequests: {
  4175. remove: false,
  4176. border: false,
  4177. tooltip: false,
  4178. alignLeft: true,
  4179. boxShadow: 'none',
  4180. icon: {
  4181. remove: true,
  4182. color: '',
  4183. },
  4184. text: {
  4185. content: 'Pull requests',
  4186. color: oldSchoolColor,
  4187. },
  4188. hover: {
  4189. backgroundColor: oldSchoolHoverBackgroundColor,
  4190. color: oldSchoolHoverColor,
  4191. },
  4192. },
  4193. marketplace: {
  4194. add: true,
  4195. border: false,
  4196. tooltip: false,
  4197. alignLeft: true,
  4198. boxShadow: 'none',
  4199. icon: {
  4200. remove: true,
  4201. color: '',
  4202. },
  4203. text: {
  4204. content: 'Marketplace',
  4205. color: oldSchoolColor,
  4206. },
  4207. hover: {
  4208. backgroundColor: oldSchoolHoverBackgroundColor,
  4209. color: oldSchoolHoverColor,
  4210. },
  4211. },
  4212. explore: {
  4213. add: true,
  4214. border: false,
  4215. tooltip: false,
  4216. alignLeft: true,
  4217. boxShadow: 'none',
  4218. icon: {
  4219. remove: true,
  4220. color: '',
  4221. },
  4222. text: {
  4223. content: 'Explore',
  4224. color: oldSchoolColor,
  4225. },
  4226. hover: {
  4227. backgroundColor: oldSchoolHoverBackgroundColor,
  4228. color: oldSchoolHoverColor,
  4229. },
  4230. },
  4231. notifications: {
  4232. remove: false,
  4233. border: false,
  4234. tooltip: false,
  4235. boxShadow: 'none',
  4236. hoverBackgroundColor: oldSchoolHoverBackgroundColor,
  4237. icon: {
  4238. symbol: 'bell',
  4239. color: oldSchoolColor,
  4240. hover: {
  4241. color: oldSchoolHoverColor,
  4242. },
  4243. },
  4244. text: {
  4245. content: '',
  4246. color: '',
  4247. },
  4248. dot: {
  4249. remove: false,
  4250. boxShadowColor: '#161C20',
  4251. color: '#2f81f7',
  4252. displayOverIcon: true,
  4253. },
  4254. },
  4255. avatar: {
  4256. remove: false,
  4257. size: '24px',
  4258. dropdownIcon: true,
  4259. },
  4260. globalBar: {
  4261. boxShadowColor: '#21262D',
  4262. leftAligned: {
  4263. gap: '0.75rem',
  4264. },
  4265. rightAligned: {
  4266. gap: '2px',
  4267. },
  4268. },
  4269. localBar: {
  4270. backgroundColor: '#FAFBFD',
  4271. alignCenter: true,
  4272. boxShadow: {
  4273. consistentColor: true,
  4274. },
  4275. links: {
  4276. color: '',
  4277. },
  4278. },
  4279. sidebars: {
  4280. backdrop: {
  4281. color: oldSchoolHoverBackgroundColor,
  4282. },
  4283. left: {
  4284. preload: true,
  4285. },
  4286. right: {
  4287. preload: true,
  4288. floatUnderneath: true,
  4289. width: '',
  4290. maxHeight: '60vh',
  4291. },
  4292. },
  4293. repositoryHeader: {
  4294. import: true,
  4295. alignCenter: true,
  4296. removePageTitle: true,
  4297. backgroundColor: '#FAFBFD',
  4298. avatar: {
  4299. remove: false,
  4300. customSvg: '<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo mr-1 color-fg-muted"><path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg>',
  4301. },
  4302. link: {
  4303. color: '#2F81F7',
  4304. hover: {
  4305. backgroundColor: 'transparent',
  4306. color: '#0969da',
  4307. textDecoration: 'underline',
  4308. },
  4309. },
  4310. },
  4311. },
  4312. dark: {
  4313. backgroundColor: '#161C20',
  4314. hamburgerButton: {
  4315. remove: true,
  4316. },
  4317. logo: {
  4318. remove: false,
  4319. color: '#e6edf3',
  4320. customSvg: '',
  4321. },
  4322. pageTitle: {
  4323. remove: true,
  4324. color: oldSchoolColor,
  4325. hover: {
  4326. backgroundColor: oldSchoolHoverBackgroundColor,
  4327. color: oldSchoolHoverColor,
  4328. },
  4329. },
  4330. search: {
  4331. remove: false,
  4332. backgroundColor: '#0E1217',
  4333. borderColor: '#30363d',
  4334. boxShadow: 'none',
  4335. alignLeft: true,
  4336. width: 'calc(var(--feed-sidebar) - 67px)',
  4337. margin: {
  4338. left: '',
  4339. right: '',
  4340. },
  4341. magnifyingGlassIcon: {
  4342. remove: true,
  4343. },
  4344. placeholder: {
  4345. text: 'Search or jump to...',
  4346. color: '#B3B3B5',
  4347. },
  4348. rightButton: 'slash key',
  4349. modal: {
  4350. width: '450px',
  4351. },
  4352. },
  4353. copilot: {
  4354. remove: true,
  4355. border: false,
  4356. tooltip: false,
  4357. alignLeft: true,
  4358. boxShadow: 'none',
  4359. icon: {
  4360. remove: false,
  4361. color: '',
  4362. },
  4363. text: {
  4364. content: 'Copilot',
  4365. color: oldSchoolColor,
  4366. },
  4367. hover: {
  4368. backgroundColor: oldSchoolHoverBackgroundColor,
  4369. color: oldSchoolHoverColor,
  4370. },
  4371. },
  4372. divider: {
  4373. remove: true,
  4374. },
  4375. flipCreateInbox: true,
  4376. create: {
  4377. remove: false,
  4378. border: false,
  4379. tooltip: false,
  4380. boxShadow: 'none',
  4381. hoverBackgroundColor: oldSchoolHoverBackgroundColor,
  4382. plusIcon: {
  4383. remove: false,
  4384. color: oldSchoolColor,
  4385. marginRight: '0px',
  4386. hover: {
  4387. color: oldSchoolHoverColor,
  4388. },
  4389. },
  4390. text: {
  4391. content: '',
  4392. color: '',
  4393. },
  4394. dropdownIcon: {
  4395. remove: false,
  4396. color: oldSchoolColor,
  4397. hover: {
  4398. color: oldSchoolHoverColor,
  4399. },
  4400. },
  4401. },
  4402. flipIssuesPullRequests: true,
  4403. issues: {
  4404. remove: false,
  4405. border: false,
  4406. tooltip: false,
  4407. alignLeft: true,
  4408. boxShadow: 'none',
  4409. icon: {
  4410. remove: true,
  4411. color: '',
  4412. },
  4413. text: {
  4414. content: 'Issues',
  4415. color: oldSchoolColor,
  4416. },
  4417. hover: {
  4418. backgroundColor: oldSchoolHoverBackgroundColor,
  4419. color: oldSchoolHoverColor,
  4420. },
  4421. },
  4422. pullRequests: {
  4423. remove: false,
  4424. border: false,
  4425. tooltip: false,
  4426. alignLeft: true,
  4427. boxShadow: 'none',
  4428. icon: {
  4429. remove: true,
  4430. color: '',
  4431. },
  4432. text: {
  4433. content: 'Pull requests',
  4434. color: oldSchoolColor,
  4435. },
  4436. hover: {
  4437. backgroundColor: oldSchoolHoverBackgroundColor,
  4438. color: oldSchoolHoverColor,
  4439. },
  4440. },
  4441. marketplace: {
  4442. add: true,
  4443. border: false,
  4444. alignLeft: true,
  4445. boxShadow: 'none',
  4446. icon: {
  4447. remove: true,
  4448. color: '',
  4449. },
  4450. text: {
  4451. content: 'Marketplace',
  4452. color: oldSchoolColor,
  4453. },
  4454. hover: {
  4455. backgroundColor: oldSchoolHoverBackgroundColor,
  4456. color: oldSchoolHoverColor,
  4457. },
  4458. },
  4459. explore: {
  4460. add: true,
  4461. border: false,
  4462. alignLeft: true,
  4463. boxShadow: 'none',
  4464. icon: {
  4465. remove: true,
  4466. color: '',
  4467. },
  4468. text: {
  4469. content: 'Explore',
  4470. color: oldSchoolColor,
  4471. },
  4472. hover: {
  4473. backgroundColor: oldSchoolHoverBackgroundColor,
  4474. color: oldSchoolHoverColor,
  4475. },
  4476. },
  4477. notifications: {
  4478. remove: false,
  4479. border: false,
  4480. tooltip: false,
  4481. boxShadow: 'none',
  4482. hoverBackgroundColor: oldSchoolHoverBackgroundColor,
  4483. icon: {
  4484. symbol: 'bell',
  4485. color: oldSchoolColor,
  4486. hover: {
  4487. color: oldSchoolHoverColor,
  4488. },
  4489. },
  4490. text: {
  4491. content: '',
  4492. color: '',
  4493. },
  4494. dot: {
  4495. remove: false,
  4496. boxShadowColor: '#161C20',
  4497. color: '#2f81f7',
  4498. displayOverIcon: true,
  4499. },
  4500. },
  4501. avatar: {
  4502. remove: false,
  4503. size: '24px',
  4504. dropdownIcon: true,
  4505. },
  4506. globalBar: {
  4507. boxShadowColor: '#21262D',
  4508. leftAligned: {
  4509. gap: '0.75rem',
  4510. },
  4511. rightAligned: {
  4512. gap: '2px',
  4513. },
  4514. },
  4515. localBar: {
  4516. backgroundColor: '#0D1117',
  4517. alignCenter: true,
  4518. boxShadow: {
  4519. consistentColor: true,
  4520. },
  4521. links: {
  4522. color: '#e6edf3',
  4523. },
  4524. },
  4525. sidebars: {
  4526. backdrop: {
  4527. color: oldSchoolHoverBackgroundColor,
  4528. },
  4529. left: {
  4530. preload: true,
  4531. },
  4532. right: {
  4533. preload: true,
  4534. floatUnderneath: true,
  4535. width: '',
  4536. maxHeight: '60vh',
  4537. },
  4538. },
  4539. repositoryHeader: {
  4540. import: true,
  4541. alignCenter: true,
  4542. removePageTitle: true,
  4543. backgroundColor: '#0D1116',
  4544. avatar: {
  4545. remove: false,
  4546. customSvg: '<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo mr-1 color-fg-muted"><path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg>',
  4547. },
  4548. link: {
  4549. color: '#58A6FF',
  4550. hover: {
  4551. backgroundColor: 'transparent',
  4552. color: '#2F81F7',
  4553. textDecoration: 'underline',
  4554. },
  4555. },
  4556. },
  4557. },
  4558. },
  4559. };
  4560.  
  4561. // For testing purposes
  4562. // if (!checkConfigConsistency(configs)) return;
  4563.  
  4564. let OBSERVER = new MutationObserver(observeAndModify);
  4565.  
  4566. let GMC = new GM_config({
  4567. id: 'gmc-frame',
  4568. title: `
  4569. Custom Global Navigation
  4570. <small>
  4571. <a
  4572. href="https://github.com/blakegearin/github-custom-global-navigation"
  4573. target="_blank"
  4574. >
  4575. source
  4576. </a>
  4577. </small>
  4578. `,
  4579. events: {
  4580. init: gmcInitialized,
  4581. open: gmcOpened,
  4582. save: gmcSaved,
  4583. close: gmcClosed,
  4584. },
  4585. frame: gmcBuildFrame(),
  4586. fields: {
  4587. type: {
  4588. section: [
  4589. `
  4590. Configuration Type
  4591. <small>
  4592. <a
  4593. href="https://github.com/blakegearin/github-custom-global-navigation#configurations"
  4594. target="_blank"
  4595. >
  4596. learn more
  4597. </a>
  4598. </small>
  4599. `,
  4600. ],
  4601. type: 'radio',
  4602. options: [
  4603. 'Off',
  4604. 'Happy Medium',
  4605. 'Old School',
  4606. 'Custom',
  4607. ],
  4608. default: 'Old School',
  4609. },
  4610. light_backgroundColor: {
  4611. label: 'Background color',
  4612. section: [
  4613. 'Custom Light',
  4614. ],
  4615. type: 'text',
  4616. default: '',
  4617. },
  4618. light_hamburgerButton_remove: {
  4619. label: '<h3>Hamburger button</h3><div class="gmc-label">Remove</div>',
  4620. type: 'checkbox',
  4621. default: false,
  4622. },
  4623. light_logo_remove: {
  4624. label: '<h3>Logo</h3><div class="gmc-label">Remove</div>',
  4625. type: 'checkbox',
  4626. default: false,
  4627. },
  4628. light_logo_color: {
  4629. label: 'Color',
  4630. type: 'text',
  4631. default: '',
  4632. },
  4633. light_logo_customSvg: {
  4634. label: 'Custom SVG (URL or text)',
  4635. type: 'textarea',
  4636. default: '',
  4637. },
  4638. light_pageTitle_remove: {
  4639. label: '<h3>Page title</h3><div class="gmc-label">Remove</div>',
  4640. type: 'checkbox',
  4641. default: false,
  4642. },
  4643. light_pageTitle_color: {
  4644. label: 'Color',
  4645. type: 'text',
  4646. default: '',
  4647. },
  4648. light_pageTitle_hover_backgroundColor: {
  4649. label: 'Hover background color',
  4650. type: 'text',
  4651. default: '',
  4652. },
  4653. light_pageTitle_hover_color: {
  4654. label: 'Hover color',
  4655. type: 'text',
  4656. default: '',
  4657. },
  4658. light_search_remove: {
  4659. label: '<h3>Search</h3><div class="gmc-label">Remove</div>',
  4660. type: 'checkbox',
  4661. default: false,
  4662. },
  4663. light_search_backgroundColor: {
  4664. label: 'Background color',
  4665. type: 'text',
  4666. default: '',
  4667. },
  4668. light_search_borderColor: {
  4669. label: 'Border color',
  4670. type: 'text',
  4671. default: '',
  4672. },
  4673. light_search_boxShadow: {
  4674. label: 'Box shadow',
  4675. type: 'text',
  4676. default: '',
  4677. },
  4678. light_search_alignLeft: {
  4679. label: 'Left aligned',
  4680. type: 'checkbox',
  4681. default: false,
  4682. },
  4683. light_search_width: {
  4684. label: 'Width',
  4685. type: 'text',
  4686. default: '',
  4687. },
  4688. light_search_margin_left: {
  4689. label: 'Margin left',
  4690. type: 'text',
  4691. default: '',
  4692. },
  4693. light_search_margin_right: {
  4694. label: 'Margin right',
  4695. type: 'text',
  4696. default: '',
  4697. },
  4698. light_search_magnifyingGlassIcon_remove: {
  4699. label: 'Magnifying glass icon remove',
  4700. type: 'checkbox',
  4701. default: false,
  4702. },
  4703. light_search_placeholder_text: {
  4704. label: 'Placeholder text',
  4705. type: 'text',
  4706. default: '',
  4707. },
  4708. light_search_placeholder_color: {
  4709. label: 'Placeholder color',
  4710. type: 'text',
  4711. default: '',
  4712. },
  4713. light_search_rightButton: {
  4714. label: 'Right button',
  4715. type: 'select',
  4716. options: [
  4717. 'none',
  4718. 'command palette',
  4719. 'slash key',
  4720. ],
  4721. default: 'command palette',
  4722. },
  4723. light_search_modal_width: {
  4724. label: 'Modal width',
  4725. type: 'text',
  4726. default: '',
  4727. },
  4728. light_divider_remove: {
  4729. label: '<h3>Divider</h3><div class="gmc-label">Remove</div>',
  4730. type: 'checkbox',
  4731. default: false,
  4732. },
  4733. light_flipCreateInbox: {
  4734. label: 'Flip the order of Create and Notifications',
  4735. type: 'checkbox',
  4736. default: false,
  4737. },
  4738. light_create_remove: {
  4739. label: '<h3>Create button</h3><div class="gmc-label">Remove</div>',
  4740. type: 'checkbox',
  4741. default: false,
  4742. },
  4743. light_create_border: {
  4744. label: 'Border',
  4745. type: 'checkbox',
  4746. default: true,
  4747. },
  4748. light_create_tooltip: {
  4749. label: 'Tooltip',
  4750. type: 'checkbox',
  4751. default: true,
  4752. },
  4753. light_create_boxShadow: {
  4754. label: 'Box shadow',
  4755. type: 'text',
  4756. default: '',
  4757. },
  4758. light_create_hoverBackgroundColor: {
  4759. label: 'Hover background color',
  4760. type: 'text',
  4761. default: '',
  4762. },
  4763. light_create_plusIcon_remove: {
  4764. label: 'Plus icon remove',
  4765. type: 'checkbox',
  4766. default: false,
  4767. },
  4768. light_create_plusIcon_color: {
  4769. label: 'Plus icon color',
  4770. type: 'text',
  4771. default: '',
  4772. },
  4773. light_create_plusIcon_marginRight: {
  4774. label: 'Plus icon margin right',
  4775. type: 'text',
  4776. default: '',
  4777. },
  4778. light_create_plusIcon_hover_color: {
  4779. label: 'Plus icon hover color',
  4780. type: 'text',
  4781. default: '',
  4782. },
  4783. light_create_text_content: {
  4784. label: 'Text content',
  4785. type: 'text',
  4786. default: '',
  4787. },
  4788. light_create_text_color: {
  4789. label: 'Text color',
  4790. type: 'text',
  4791. default: '',
  4792. },
  4793. light_create_dropdownIcon_remove: {
  4794. label: 'Dropdown icon remove',
  4795. type: 'checkbox',
  4796. default: false,
  4797. },
  4798. light_create_dropdownIcon_color: {
  4799. label: 'Dropdown icon color',
  4800. type: 'text',
  4801. default: '',
  4802. },
  4803. light_create_dropdownIcon_hover_color: {
  4804. label: 'Dropdown icon hover color',
  4805. type: 'text',
  4806. default: '',
  4807. },
  4808. light_flipIssuesPullRequests: {
  4809. label: 'Flip the order of Issues and Pull requests',
  4810. type: 'checkbox',
  4811. default: false,
  4812. },
  4813. light_issues_remove: {
  4814. label: '<h3>Issues button</h3><div class="gmc-label">Remove</div>',
  4815. type: 'checkbox',
  4816. default: false,
  4817. },
  4818. light_issues_border: {
  4819. label: 'Border',
  4820. type: 'checkbox',
  4821. default: true,
  4822. },
  4823. light_issues_tooltip: {
  4824. label: 'Tooltip',
  4825. type: 'checkbox',
  4826. default: true,
  4827. },
  4828. light_issues_alignLeft: {
  4829. label: 'Align left',
  4830. type: 'checkbox',
  4831. default: false,
  4832. },
  4833. light_issues_boxShadow: {
  4834. label: 'Box shadow',
  4835. type: 'text',
  4836. default: '',
  4837. },
  4838. light_issues_icon_remove: {
  4839. label: 'Icon remove',
  4840. type: 'checkbox',
  4841. default: false,
  4842. },
  4843. light_issues_icon_color: {
  4844. label: 'Icon color',
  4845. type: 'text',
  4846. default: '',
  4847. },
  4848. light_issues_text_content: {
  4849. label: 'Text content',
  4850. type: 'text',
  4851. default: '',
  4852. },
  4853. light_issues_text_color: {
  4854. label: 'Text color',
  4855. type: 'text',
  4856. default: '',
  4857. },
  4858. light_issues_hover_backgroundColor: {
  4859. label: 'Hover background color',
  4860. type: 'text',
  4861. default: '',
  4862. },
  4863. light_issues_hover_color: {
  4864. label: 'Hover color',
  4865. type: 'text',
  4866. default: '',
  4867. },
  4868. light_pullRequests_remove: {
  4869. label: '<h3>Pull requests button</h3><div class="gmc-label">Remove</div>',
  4870. type: 'checkbox',
  4871. default: false,
  4872. },
  4873. light_pullRequests_border: {
  4874. label: 'Border',
  4875. type: 'checkbox',
  4876. default: true,
  4877. },
  4878. light_pullRequests_tooltip: {
  4879. label: 'Tooltip',
  4880. type: 'checkbox',
  4881. default: true,
  4882. },
  4883. light_pullRequests_alignLeft: {
  4884. label: 'Align left',
  4885. type: 'checkbox',
  4886. default: false,
  4887. },
  4888. light_pullRequests_boxShadow: {
  4889. label: 'Box shadow',
  4890. type: 'text',
  4891. default: '',
  4892. },
  4893. light_pullRequests_icon_remove: {
  4894. label: 'Icon remove',
  4895. type: 'checkbox',
  4896. default: false,
  4897. },
  4898. light_pullRequests_icon_color: {
  4899. label: 'Icon color',
  4900. type: 'text',
  4901. default: '',
  4902. },
  4903. light_pullRequests_text_content: {
  4904. label: 'Text content',
  4905. type: 'text',
  4906. default: '',
  4907. },
  4908. light_pullRequests_text_color: {
  4909. label: 'Text color',
  4910. type: 'text',
  4911. default: '',
  4912. },
  4913. light_pullRequests_hover_backgroundColor: {
  4914. label: 'Hover background color',
  4915. type: 'text',
  4916. default: '',
  4917. },
  4918. light_pullRequests_hover_color: {
  4919. label: 'Hover color',
  4920. type: 'text',
  4921. default: '',
  4922. },
  4923. light_marketplace_add: {
  4924. label: '<h3>Marketplace</h3><div class="gmc-label">Add</div>',
  4925. type: 'checkbox',
  4926. default: false,
  4927. },
  4928. light_marketplace_border: {
  4929. label: 'Border',
  4930. type: 'checkbox',
  4931. default: true,
  4932. },
  4933. light_marketplace_alignLeft: {
  4934. label: 'Align left',
  4935. type: 'checkbox',
  4936. default: false,
  4937. },
  4938. light_marketplace_boxShadow: {
  4939. label: 'Box shadow',
  4940. type: 'text',
  4941. default: '',
  4942. },
  4943. light_marketplace_icon_remove: {
  4944. label: 'Icon remove',
  4945. type: 'checkbox',
  4946. default: false,
  4947. },
  4948. light_marketplace_icon_color: {
  4949. label: 'Icon color',
  4950. type: 'text',
  4951. default: '',
  4952. },
  4953. light_marketplace_text_content: {
  4954. label: 'Text content',
  4955. type: 'text',
  4956. default: '',
  4957. },
  4958. light_marketplace_text_color: {
  4959. label: 'Text color',
  4960. type: 'text',
  4961. default: '',
  4962. },
  4963. light_marketplace_hover_backgroundColor: {
  4964. label: 'Hover background color',
  4965. type: 'text',
  4966. default: '',
  4967. },
  4968. light_marketplace_hover_color: {
  4969. label: 'Hover color',
  4970. type: 'text',
  4971. default: '',
  4972. },
  4973. light_explore_add: {
  4974. label: '<h3>Explore</h3><div class="gmc-label">Add</div>',
  4975. type: 'checkbox',
  4976. default: false,
  4977. },
  4978. light_explore_border: {
  4979. label: 'Border',
  4980. type: 'checkbox',
  4981. default: true,
  4982. },
  4983. light_explore_alignLeft: {
  4984. label: 'Align left',
  4985. type: 'checkbox',
  4986. default: false,
  4987. },
  4988. light_explore_boxShadow: {
  4989. label: 'Box shadow',
  4990. type: 'text',
  4991. default: '',
  4992. },
  4993. light_explore_icon_remove: {
  4994. label: 'Icon remove',
  4995. type: 'checkbox',
  4996. default: false,
  4997. },
  4998. light_explore_icon_color: {
  4999. label: 'Icon color',
  5000. type: 'text',
  5001. default: '',
  5002. },
  5003. light_explore_text_content: {
  5004. label: 'Text content',
  5005. type: 'text',
  5006. default: '',
  5007. },
  5008. light_explore_text_color: {
  5009. label: 'Text color',
  5010. type: 'text',
  5011. default: '',
  5012. },
  5013. light_explore_hover_backgroundColor: {
  5014. label: 'Hover background color',
  5015. type: 'text',
  5016. default: '',
  5017. },
  5018. light_explore_hover_color: {
  5019. label: 'Hover color',
  5020. type: 'text',
  5021. default: '',
  5022. },
  5023. light_notifications_remove: {
  5024. label: '<h3>Notifications button</h3><div class="gmc-label">Remove</div>',
  5025. type: 'checkbox',
  5026. default: false,
  5027. },
  5028. light_notifications_border: {
  5029. label: 'Border',
  5030. type: 'checkbox',
  5031. default: true,
  5032. },
  5033. light_notifications_tooltip: {
  5034. label: 'Tooltip',
  5035. type: 'checkbox',
  5036. default: true,
  5037. },
  5038. light_notifications_boxShadow: {
  5039. label: 'Box shadow',
  5040. type: 'text',
  5041. default: '',
  5042. },
  5043. light_notifications_hoverBackgroundColor: {
  5044. label: 'Hover background color',
  5045. type: 'text',
  5046. default: '',
  5047. },
  5048. light_notifications_icon_symbol: {
  5049. label: 'Icon symbol',
  5050. type: 'select',
  5051. options: [
  5052. 'none',
  5053. 'inbox',
  5054. 'bell',
  5055. ],
  5056. default: 'inbox',
  5057. },
  5058. light_notifications_icon_color: {
  5059. label: 'Icon color',
  5060. type: 'text',
  5061. default: '',
  5062. },
  5063. light_notifications_icon_hover_color: {
  5064. label: 'Icon hover color',
  5065. type: 'text',
  5066. default: '',
  5067. },
  5068. light_notifications_text_content: {
  5069. label: 'Text content',
  5070. type: 'text',
  5071. default: '',
  5072. },
  5073. light_notifications_text_color: {
  5074. label: 'Text color',
  5075. type: 'text',
  5076. default: '',
  5077. },
  5078. light_notifications_dot_remove: {
  5079. label: 'Dot remove',
  5080. type: 'checkbox',
  5081. default: false,
  5082. },
  5083. light_notifications_dot_boxShadowColor: {
  5084. label: 'Dot hover color',
  5085. type: 'text',
  5086. default: '',
  5087. },
  5088. light_notifications_dot_color: {
  5089. label: 'Dot color',
  5090. type: 'text',
  5091. default: '',
  5092. },
  5093. light_notifications_dot_displayOverIcon: {
  5094. label: 'Dot display over icon',
  5095. type: 'checkbox',
  5096. default: false,
  5097. },
  5098. light_avatar_remove: {
  5099. label: '<h3>Avatar</h3><div class="gmc-label">Remove</div>',
  5100. type: 'checkbox',
  5101. default: false,
  5102. },
  5103. light_avatar_size: {
  5104. label: 'Size',
  5105. type: 'text',
  5106. default: '',
  5107. },
  5108. light_avatar_dropdownIcon: {
  5109. label: 'Dropdown icon',
  5110. type: 'checkbox',
  5111. default: false,
  5112. },
  5113. light_globalBar_boxShadowColor: {
  5114. label: '<h3>Global bar</h3><div class="gmc-label">Box shadow color</div>',
  5115. type: 'text',
  5116. default: '',
  5117. },
  5118. light_globalBar_leftAligned_gap: {
  5119. label: 'Left aligned gap',
  5120. type: 'text',
  5121. default: '',
  5122. },
  5123. light_globalBar_rightAligned_gap: {
  5124. label: 'Right aligned gap',
  5125. type: 'text',
  5126. default: '',
  5127. },
  5128. light_localBar_backgroundColor: {
  5129. label: '<h3>Local bar</h3><div class="gmc-label">Background color</div>',
  5130. type: 'text',
  5131. default: '',
  5132. },
  5133. light_localBar_alignCenter: {
  5134. label: 'Align center',
  5135. type: 'checkbox',
  5136. default: false,
  5137. },
  5138. light_localBar_boxShadow_consistentColor: {
  5139. label: 'Box shadow consistent color',
  5140. type: 'checkbox',
  5141. default: false,
  5142. },
  5143. light_localBar_links_color: {
  5144. label: 'Links color',
  5145. type: 'text',
  5146. default: '',
  5147. },
  5148. light_sidebars_backdrop_color: {
  5149. label: '<h3>Sidebars</h3><div class="gmc-label">Backdrop color</div>',
  5150. type: 'text',
  5151. default: '',
  5152. },
  5153. light_sidebars_left_preload: {
  5154. label: 'Left preload',
  5155. type: 'checkbox',
  5156. default: false,
  5157. },
  5158. light_sidebars_right_preload: {
  5159. label: 'Right preload',
  5160. type: 'checkbox',
  5161. default: false,
  5162. },
  5163. light_sidebars_right_floatUnderneath: {
  5164. label: 'Right float underneath',
  5165. type: 'checkbox',
  5166. default: false,
  5167. },
  5168. light_sidebars_right_width: {
  5169. label: 'Right width',
  5170. type: 'text',
  5171. default: '',
  5172. },
  5173. light_sidebars_right_maxHeight: {
  5174. label: 'Right max height',
  5175. type: 'text',
  5176. default: '',
  5177. },
  5178. light_repositoryHeader_import: {
  5179. label: '<h3>Repository header</h3><div class="gmc-label">Import</div>',
  5180. type: 'checkbox',
  5181. default: false,
  5182. },
  5183. light_repositoryHeader_alignCenter: {
  5184. label: 'Align center',
  5185. type: 'checkbox',
  5186. default: false,
  5187. },
  5188. light_repositoryHeader_removePageTitle: {
  5189. label: 'Remove page title',
  5190. type: 'checkbox',
  5191. default: false,
  5192. },
  5193. light_repositoryHeader_backgroundColor: {
  5194. label: 'Background color',
  5195. type: 'text',
  5196. default: '',
  5197. },
  5198. light_repositoryHeader_avatar_remove: {
  5199. label: 'Avatar remove',
  5200. type: 'checkbox',
  5201. default: false,
  5202. },
  5203. light_repositoryHeader_avatar_customSvg: {
  5204. label: 'Custom SVG (URL or text)',
  5205. type: 'textarea',
  5206. default: '',
  5207. },
  5208. light_repositoryHeader_link_color: {
  5209. label: 'Link color',
  5210. type: 'text',
  5211. default: '',
  5212. },
  5213. light_repositoryHeader_link_hover_backgroundColor: {
  5214. label: 'Link hover background color',
  5215. type: 'text',
  5216. default: '',
  5217. },
  5218. light_repositoryHeader_link_hover_color: {
  5219. label: 'Link hover color',
  5220. type: 'text',
  5221. default: '',
  5222. },
  5223. light_repositoryHeader_link_hover_textDecoration: {
  5224. label: 'Link hover text decoration',
  5225. type: 'text',
  5226. default: '',
  5227. },
  5228. dark_backgroundColor: {
  5229. label: 'Background color',
  5230. section: [
  5231. 'Custom Dark',
  5232. ],
  5233. type: 'text',
  5234. default: '',
  5235. },
  5236. dark_hamburgerButton_remove: {
  5237. label: '<h3>Hamburger button</h3><div class="gmc-label">Remove</div>',
  5238. type: 'checkbox',
  5239. default: false,
  5240. },
  5241. dark_logo_remove: {
  5242. label: '<h3>Logo</h3><div class="gmc-label">Remove</div>',
  5243. type: 'checkbox',
  5244. default: false,
  5245. },
  5246. dark_logo_color: {
  5247. label: 'Color',
  5248. type: 'text',
  5249. default: '',
  5250. },
  5251. dark_logo_customSvg: {
  5252. label: 'Custom SVG (URL or text)',
  5253. type: 'textarea',
  5254. default: '',
  5255. },
  5256. dark_pageTitle_remove: {
  5257. label: '<h3>Page title</h3><div class="gmc-label">Remove</div>',
  5258. type: 'checkbox',
  5259. default: false,
  5260. },
  5261. dark_pageTitle_color: {
  5262. label: 'Color',
  5263. type: 'text',
  5264. default: '',
  5265. },
  5266. dark_pageTitle_hover_backgroundColor: {
  5267. label: 'Hover background color',
  5268. type: 'text',
  5269. default: '',
  5270. },
  5271. dark_pageTitle_hover_color: {
  5272. label: 'Hover color',
  5273. type: 'text',
  5274. default: '',
  5275. },
  5276. dark_search_remove: {
  5277. label: '<h3>Search</h3><div class="gmc-label">Remove</div>',
  5278. type: 'checkbox',
  5279. default: false,
  5280. },
  5281. dark_search_backgroundColor: {
  5282. label: 'Background color',
  5283. type: 'text',
  5284. default: '',
  5285. },
  5286. dark_search_borderColor: {
  5287. label: 'Border color',
  5288. type: 'text',
  5289. default: '',
  5290. },
  5291. dark_search_boxShadow: {
  5292. label: 'Box shadow',
  5293. type: 'text',
  5294. default: '',
  5295. },
  5296. dark_search_alignLeft: {
  5297. label: 'Left aligned',
  5298. type: 'checkbox',
  5299. default: false,
  5300. },
  5301. dark_search_width: {
  5302. label: 'Width',
  5303. type: 'text',
  5304. default: '',
  5305. },
  5306. dark_search_margin_left: {
  5307. label: 'Margin left',
  5308. type: 'text',
  5309. default: '',
  5310. },
  5311. dark_search_margin_right: {
  5312. label: 'Margin right',
  5313. type: 'text',
  5314. default: '',
  5315. },
  5316. dark_search_magnifyingGlassIcon_remove: {
  5317. label: 'Magnifying glass icon remove',
  5318. type: 'checkbox',
  5319. default: false,
  5320. },
  5321. dark_search_placeholder_text: {
  5322. label: 'Placeholder text',
  5323. type: 'text',
  5324. default: '',
  5325. },
  5326. dark_search_placeholder_color: {
  5327. label: 'Placeholder color',
  5328. type: 'text',
  5329. default: '',
  5330. },
  5331. dark_search_rightButton: {
  5332. label: 'Right button',
  5333. type: 'select',
  5334. options: [
  5335. 'none',
  5336. 'command palette',
  5337. 'slash key',
  5338. ],
  5339. default: 'command palette',
  5340. },
  5341. dark_search_modal_width: {
  5342. label: 'Modal width',
  5343. type: 'text',
  5344. default: '',
  5345. },
  5346. dark_divider_remove: {
  5347. label: '<h3>Divider</h3><div class="gmc-label">Remove</div>',
  5348. type: 'checkbox',
  5349. default: false,
  5350. },
  5351. dark_flipCreateInbox: {
  5352. label: 'Flip the order of Create and Notifications',
  5353. type: 'checkbox',
  5354. default: false,
  5355. },
  5356. dark_create_remove: {
  5357. label: '<h3>Create button</h3><div class="gmc-label">Remove</div>',
  5358. type: 'checkbox',
  5359. default: false,
  5360. },
  5361. dark_create_border: {
  5362. label: 'Border',
  5363. type: 'checkbox',
  5364. default: true,
  5365. },
  5366. dark_create_tooltip: {
  5367. label: 'Tooltip',
  5368. type: 'checkbox',
  5369. default: true,
  5370. },
  5371. dark_create_boxShadow: {
  5372. label: 'Box shadow',
  5373. type: 'text',
  5374. default: '',
  5375. },
  5376. dark_create_hoverBackgroundColor: {
  5377. label: 'Hover background color',
  5378. type: 'text',
  5379. default: '',
  5380. },
  5381. dark_create_plusIcon_remove: {
  5382. label: 'Plus icon remove',
  5383. type: 'checkbox',
  5384. default: false,
  5385. },
  5386. dark_create_plusIcon_color: {
  5387. label: 'Plus icon color',
  5388. type: 'text',
  5389. default: '',
  5390. },
  5391. dark_create_plusIcon_marginRight: {
  5392. label: 'Plus icon margin right',
  5393. type: 'text',
  5394. default: '',
  5395. },
  5396. dark_create_plusIcon_hover_color: {
  5397. label: 'Plus icon hover color',
  5398. type: 'text',
  5399. default: '',
  5400. },
  5401. dark_create_text_content: {
  5402. label: 'Text content',
  5403. type: 'text',
  5404. default: '',
  5405. },
  5406. dark_create_text_color: {
  5407. label: 'Text color',
  5408. type: 'text',
  5409. default: '',
  5410. },
  5411. dark_create_dropdownIcon_remove: {
  5412. label: 'Dropdown icon remove',
  5413. type: 'checkbox',
  5414. default: false,
  5415. },
  5416. dark_create_dropdownIcon_color: {
  5417. label: 'Dropdown icon color',
  5418. type: 'text',
  5419. default: '',
  5420. },
  5421. dark_create_dropdownIcon_hover_color: {
  5422. label: 'Dropdown icon hover color',
  5423. type: 'text',
  5424. default: '',
  5425. },
  5426. dark_flipIssuesPullRequests: {
  5427. label: 'Flip the order of Issues and Pull requests',
  5428. type: 'checkbox',
  5429. default: false,
  5430. },
  5431. dark_issues_remove: {
  5432. label: '<h3>Issues button</h3><div class="gmc-label">Remove</div>',
  5433. type: 'checkbox',
  5434. default: false,
  5435. },
  5436. dark_issues_border: {
  5437. label: 'Border',
  5438. type: 'checkbox',
  5439. default: true,
  5440. },
  5441. dark_issues_tooltip: {
  5442. label: 'Tooltip',
  5443. type: 'checkbox',
  5444. default: true,
  5445. },
  5446. dark_issues_boxShadow: {
  5447. label: 'Box shadow',
  5448. type: 'text',
  5449. default: '',
  5450. },
  5451. dark_issues_alignLeft: {
  5452. label: 'Align left',
  5453. type: 'checkbox',
  5454. default: false,
  5455. },
  5456. dark_issues_icon_remove: {
  5457. label: 'Icon remove',
  5458. type: 'checkbox',
  5459. default: false,
  5460. },
  5461. dark_issues_icon_color: {
  5462. label: 'Icon color',
  5463. type: 'text',
  5464. default: '',
  5465. },
  5466. dark_issues_text_content: {
  5467. label: 'Text content',
  5468. type: 'text',
  5469. default: '',
  5470. },
  5471. dark_issues_text_color: {
  5472. label: 'Text color',
  5473. type: 'text',
  5474. default: '',
  5475. },
  5476. dark_issues_hover_backgroundColor: {
  5477. label: 'Hover background color',
  5478. type: 'text',
  5479. default: '',
  5480. },
  5481. dark_issues_hover_color: {
  5482. label: 'Hover color',
  5483. type: 'text',
  5484. default: '',
  5485. },
  5486. dark_pullRequests_remove: {
  5487. label: '<h3>Pull requests button</h3><div class="gmc-label">Remove</div>',
  5488. type: 'checkbox',
  5489. default: false,
  5490. },
  5491. dark_pullRequests_border: {
  5492. label: 'Border',
  5493. type: 'checkbox',
  5494. default: true,
  5495. },
  5496. dark_pullRequests_tooltip: {
  5497. label: 'Tooltip',
  5498. type: 'checkbox',
  5499. default: true,
  5500. },
  5501. dark_pullRequests_alignLeft: {
  5502. label: 'Align left',
  5503. type: 'checkbox',
  5504. default: false,
  5505. },
  5506. dark_pullRequests_boxShadow: {
  5507. label: 'Box shadow',
  5508. type: 'text',
  5509. default: '',
  5510. },
  5511. dark_pullRequests_icon_remove: {
  5512. label: 'Icon remove',
  5513. type: 'checkbox',
  5514. default: false,
  5515. },
  5516. dark_pullRequests_icon_color: {
  5517. label: 'Icon color',
  5518. type: 'text',
  5519. default: '',
  5520. },
  5521. dark_pullRequests_text_content: {
  5522. label: 'Text content',
  5523. type: 'text',
  5524. default: '',
  5525. },
  5526. dark_pullRequests_text_color: {
  5527. label: 'Text color',
  5528. type: 'text',
  5529. default: '',
  5530. },
  5531. dark_pullRequests_hover_backgroundColor: {
  5532. label: 'Hover background color',
  5533. type: 'text',
  5534. default: '',
  5535. },
  5536. dark_pullRequests_hover_color: {
  5537. label: 'Hover color',
  5538. type: 'text',
  5539. default: '',
  5540. },
  5541. dark_marketplace_add: {
  5542. label: '<h3>Marketplace</h3><div class="gmc-label">Add</div>',
  5543. type: 'checkbox',
  5544. default: false,
  5545. },
  5546. dark_marketplace_border: {
  5547. label: 'Border',
  5548. type: 'checkbox',
  5549. default: true,
  5550. },
  5551. dark_marketplace_alignLeft: {
  5552. label: 'Align left',
  5553. type: 'checkbox',
  5554. default: false,
  5555. },
  5556. dark_marketplace_boxShadow: {
  5557. label: 'Box shadow',
  5558. type: 'text',
  5559. default: '',
  5560. },
  5561. dark_marketplace_icon_remove: {
  5562. label: 'Icon remove',
  5563. type: 'checkbox',
  5564. default: false,
  5565. },
  5566. dark_marketplace_icon_color: {
  5567. label: 'Icon color',
  5568. type: 'text',
  5569. default: '',
  5570. },
  5571. dark_marketplace_text_content: {
  5572. label: 'Text content',
  5573. type: 'text',
  5574. default: '',
  5575. },
  5576. dark_marketplace_text_color: {
  5577. label: 'Text color',
  5578. type: 'text',
  5579. default: '',
  5580. },
  5581. dark_marketplace_hover_backgroundColor: {
  5582. label: 'Hover background color',
  5583. type: 'text',
  5584. default: '',
  5585. },
  5586. dark_marketplace_hover_color: {
  5587. label: 'Hover color',
  5588. type: 'text',
  5589. default: '',
  5590. },
  5591. dark_explore_add: {
  5592. label: '<h3>Explore</h3><div class="gmc-label">Add</div>',
  5593. type: 'checkbox',
  5594. default: false,
  5595. },
  5596. dark_explore_border: {
  5597. label: 'Border',
  5598. type: 'checkbox',
  5599. default: true,
  5600. },
  5601. dark_explore_alignLeft: {
  5602. label: 'Align left',
  5603. type: 'checkbox',
  5604. default: false,
  5605. },
  5606. dark_explore_boxShadow: {
  5607. label: 'Box shadow',
  5608. type: 'text',
  5609. default: '',
  5610. },
  5611. dark_explore_icon_remove: {
  5612. label: 'Icon remove',
  5613. type: 'checkbox',
  5614. default: false,
  5615. },
  5616. dark_explore_icon_color: {
  5617. label: 'Icon color',
  5618. type: 'text',
  5619. default: '',
  5620. },
  5621. dark_explore_text_content: {
  5622. label: 'Text content',
  5623. type: 'text',
  5624. default: '',
  5625. },
  5626. dark_explore_text_color: {
  5627. label: 'Text color',
  5628. type: 'text',
  5629. default: '',
  5630. },
  5631. dark_explore_hover_backgroundColor: {
  5632. label: 'Hover background color',
  5633. type: 'text',
  5634. default: '',
  5635. },
  5636. dark_explore_hover_color: {
  5637. label: 'Hover color',
  5638. type: 'text',
  5639. default: '',
  5640. },
  5641. dark_notifications_remove: {
  5642. label: '<h3>Notifications button</h3><div class="gmc-label">Remove</div>',
  5643. type: 'checkbox',
  5644. default: false,
  5645. },
  5646. dark_notifications_border: {
  5647. label: 'Border',
  5648. type: 'checkbox',
  5649. default: true,
  5650. },
  5651. dark_notifications_tooltip: {
  5652. label: 'Tooltip',
  5653. type: 'checkbox',
  5654. default: true,
  5655. },
  5656. dark_notifications_boxShadow: {
  5657. label: 'Box shadow',
  5658. type: 'text',
  5659. default: '',
  5660. },
  5661. dark_notifications_hoverBackgroundColor: {
  5662. label: 'Hover background color',
  5663. type: 'text',
  5664. default: '',
  5665. },
  5666. dark_notifications_icon_symbol: {
  5667. label: 'Icon symbol',
  5668. type: 'select',
  5669. options: [
  5670. 'none',
  5671. 'inbox',
  5672. 'bell',
  5673. ],
  5674. default: 'inbox',
  5675. },
  5676. dark_notifications_icon_color: {
  5677. label: 'Icon color',
  5678. type: 'text',
  5679. default: '',
  5680. },
  5681. dark_notifications_icon_hover_color: {
  5682. label: 'Icon hover color',
  5683. type: 'text',
  5684. default: '',
  5685. },
  5686. dark_notifications_text_content: {
  5687. label: 'Text content',
  5688. type: 'text',
  5689. default: '',
  5690. },
  5691. dark_notifications_text_color: {
  5692. label: 'Text color',
  5693. type: 'text',
  5694. default: '',
  5695. },
  5696. dark_notifications_dot_remove: {
  5697. label: 'Dot remove',
  5698. type: 'checkbox',
  5699. default: false,
  5700. },
  5701. dark_notifications_dot_boxShadowColor: {
  5702. label: 'Dot hover color',
  5703. type: 'text',
  5704. default: '',
  5705. },
  5706. dark_notifications_dot_color: {
  5707. label: 'Dot color',
  5708. type: 'text',
  5709. default: '',
  5710. },
  5711. dark_notifications_dot_displayOverIcon: {
  5712. label: 'Dot display over icon',
  5713. type: 'checkbox',
  5714. default: false,
  5715. },
  5716. dark_avatar_remove: {
  5717. label: '<h3>Avatar</h3><div class="gmc-label">Remove</div>',
  5718. type: 'checkbox',
  5719. default: false,
  5720. },
  5721. dark_avatar_size: {
  5722. label: 'Size',
  5723. type: 'text',
  5724. default: '',
  5725. },
  5726. dark_avatar_dropdownIcon: {
  5727. label: 'Dropdown icon',
  5728. type: 'checkbox',
  5729. default: false,
  5730. },
  5731. dark_globalBar_boxShadowColor: {
  5732. label: '<h3>Global bar</h3><div class="gmc-label">Box shadow color</div>',
  5733. type: 'text',
  5734. default: '',
  5735. },
  5736. dark_globalBar_leftAligned_gap: {
  5737. label: 'Left aligned gap',
  5738. type: 'text',
  5739. default: '',
  5740. },
  5741. dark_globalBar_rightAligned_gap: {
  5742. label: 'Right aligned gap',
  5743. type: 'text',
  5744. default: '',
  5745. },
  5746. dark_localBar_backgroundColor: {
  5747. label: '<h3>Local bar</h3><div class="gmc-label">Background color</div>',
  5748. type: 'text',
  5749. default: '',
  5750. },
  5751. dark_localBar_alignCenter: {
  5752. label: 'Align center',
  5753. type: 'checkbox',
  5754. default: false,
  5755. },
  5756. dark_localBar_boxShadow_consistentColor: {
  5757. label: 'Box shadow consistent color',
  5758. type: 'checkbox',
  5759. default: false,
  5760. },
  5761. dark_localBar_links_color: {
  5762. label: 'Links color',
  5763. type: 'text',
  5764. default: '',
  5765. },
  5766. dark_sidebars_backdrop_color: {
  5767. label: '<h3>Sidebars</h3><div class="gmc-label">Backdrop color</div>',
  5768. type: 'text',
  5769. default: '',
  5770. },
  5771. dark_sidebars_left_preload: {
  5772. label: 'Left preload',
  5773. type: 'checkbox',
  5774. default: false,
  5775. },
  5776. dark_sidebars_right_preload: {
  5777. label: 'Right preload',
  5778. type: 'checkbox',
  5779. default: false,
  5780. },
  5781. dark_sidebars_right_floatUnderneath: {
  5782. label: 'Right float underneath',
  5783. type: 'checkbox',
  5784. default: false,
  5785. },
  5786. dark_sidebars_right_width: {
  5787. label: 'Right width',
  5788. type: 'text',
  5789. default: '',
  5790. },
  5791. dark_sidebars_right_maxHeight: {
  5792. label: 'Right max height',
  5793. type: 'text',
  5794. default: '',
  5795. },
  5796. dark_repositoryHeader_import: {
  5797. label: '<h3>Repository header</h3><div class="gmc-label">Import</div>',
  5798. type: 'checkbox',
  5799. default: false,
  5800. },
  5801. dark_repositoryHeader_alignCenter: {
  5802. label: 'Align enter',
  5803. type: 'checkbox',
  5804. default: false,
  5805. },
  5806. dark_repositoryHeader_removePageTitle: {
  5807. label: 'Remove page title',
  5808. type: 'checkbox',
  5809. default: false,
  5810. },
  5811. dark_repositoryHeader_backgroundColor: {
  5812. label: 'Background color',
  5813. type: 'text',
  5814. default: '',
  5815. },
  5816. dark_repositoryHeader_avatar_remove: {
  5817. label: 'Avatar remove',
  5818. type: 'checkbox',
  5819. default: false,
  5820. },
  5821. dark_repositoryHeader_avatar_customSvg: {
  5822. label: 'Custom SVG (URL or text)',
  5823. type: 'textarea',
  5824. default: '',
  5825. },
  5826. dark_repositoryHeader_link_color: {
  5827. label: 'Link color',
  5828. type: 'text',
  5829. default: '',
  5830. },
  5831. dark_repositoryHeader_link_hover_backgroundColor: {
  5832. label: 'Link hover background color',
  5833. type: 'text',
  5834. default: '',
  5835. },
  5836. dark_repositoryHeader_link_hover_color: {
  5837. label: 'Link hover color',
  5838. type: 'text',
  5839. default: '',
  5840. },
  5841. dark_repositoryHeader_link_hover_textDecoration: {
  5842. label: 'Link hover text decoration',
  5843. type: 'text',
  5844. default: '',
  5845. },
  5846. on_save: {
  5847. label: 'On save',
  5848. section: ['Settings'],
  5849. type: 'select',
  5850. options: [
  5851. 'do nothing',
  5852. 'refresh tab',
  5853. 'refresh tab and close',
  5854. 'run script',
  5855. 'run script and close',
  5856. ],
  5857. default: 'do nothing',
  5858. },
  5859. on_close: {
  5860. label: 'On close',
  5861. type: 'select',
  5862. options: [
  5863. 'do nothing',
  5864. 'refresh tab',
  5865. 'run script',
  5866. ],
  5867. default: 'do nothing',
  5868. },
  5869. menu_item_title: {
  5870. label: 'Menu item title',
  5871. type: 'text',
  5872. default: 'Custom global navigation',
  5873. },
  5874. menu_item_icon: {
  5875. label: 'Menu item icon',
  5876. type: 'select',
  5877. options: [
  5878. 'logo',
  5879. 'compass',
  5880. 'cog',
  5881. ],
  5882. default: 'logo',
  5883. },
  5884. log_level: {
  5885. label: 'Log level',
  5886. type: 'select',
  5887. options: [
  5888. 'silent',
  5889. 'quiet',
  5890. 'debug',
  5891. 'verbose',
  5892. 'trace',
  5893. ],
  5894. default: 'quiet',
  5895. },
  5896. clear_custom_config: {
  5897. label: 'Clear Custom',
  5898. section: ['Danger Zone'],
  5899. type: 'button',
  5900. click: gmcClearCustom,
  5901. },
  5902. apply_happyMedium_config: {
  5903. label: 'Overwrite Custom with Happy Medium',
  5904. type: 'button',
  5905. click: gmcApplyCustomHappyMediumConfig,
  5906. },
  5907. apply_oldSchool_config: {
  5908. label: 'Overwrite Custom with Old School',
  5909. type: 'button',
  5910. click: gmcApplyCustomOldSchoolConfig,
  5911. },
  5912. },
  5913. });
  5914. })();