GitHub Custom Global Navigation

Customize GitHub's new global navigation

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

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