GitHub Custom Global Navigation

Customize GitHub's new global navigation

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

  1. // ==UserScript==
  2. // @name GitHub Custom Global Navigation
  3. // @namespace https://github.com/blakegearin/github-custom-global-navigation
  4. // @version 1.6.5
  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() {
  1531. log(DEBUG, 'preloadRightSidebar()');
  1532.  
  1533. if (RIGHT_SIDEBAR_PRELOADED) return;
  1534.  
  1535. const temporaryStyleId = 'temporaryStyle';
  1536.  
  1537. const avatarButton = HEADER.querySelector(SELECTORS.avatar.button);
  1538. if (!avatarButton) {
  1539. setTimeout(preloadRightSidebar, 100);
  1540. } else {
  1541. avatarButton.click();
  1542. const closeButton = document.querySelector(SELECTORS.sidebars.right.closeButton);
  1543.  
  1544. if (!document.querySelector(createId(temporaryStyleId))) {
  1545. // Hide the sidebar
  1546. let temporaryStyle = document.createElement('style');
  1547. temporaryStyle.setAttribute('id', temporaryStyleId);
  1548. temporaryStyle.textContent += `
  1549. #__primerPortalRoot__
  1550. {
  1551. display: none;
  1552. }
  1553. `;
  1554. document.body.appendChild(temporaryStyle);
  1555. }
  1556.  
  1557. if (!closeButton) {
  1558. setTimeout(preloadRightSidebar, 100);
  1559. } else {
  1560. closeButton.click();
  1561.  
  1562. log(INFO, 'Right sidebar preloaded');
  1563. document.querySelector(createId(temporaryStyleId)).remove();
  1564. RIGHT_SIDEBAR_PRELOADED = true;
  1565. }
  1566. }
  1567. }
  1568.  
  1569. function updateSidebars() {
  1570. log(DEBUG, 'updateSidebars()');
  1571.  
  1572. const configKey = 'sidebars';
  1573.  
  1574. const elementConfig = CONFIG[configKey];
  1575. const elementSelector = SELECTORS[configKey];
  1576.  
  1577. if (elementConfig.backdrop.color !== '') {
  1578. HEADER_STYLE.textContent += `
  1579. ${elementSelector.backdrop}
  1580. {
  1581. background: ${CONFIG.sidebars.backdrop.color} !important;
  1582. }
  1583. `;
  1584. }
  1585.  
  1586. if (elementConfig.left.preload) preloadLeftSidebar(elementSelector);
  1587.  
  1588. if (elementConfig.right.floatUnderneath) {
  1589. HEADER_STYLE.textContent += `
  1590. ${elementSelector.right.modalDialog}
  1591. {
  1592. border-top-right-radius: 0.75rem !important;
  1593. border-bottom-right-radius: 0.75rem !important;
  1594. bottom: initial !important;
  1595. margin-top: 55px;
  1596. margin-right: 20px;
  1597. }
  1598. `;
  1599. }
  1600.  
  1601. if (elementConfig.right.preload) preloadRightSidebar();
  1602.  
  1603. if (elementConfig.right.maxHeight) {
  1604. HEADER_STYLE.textContent += `
  1605. ${elementSelector.right.modalDialog}
  1606. {
  1607. max-height: ${elementConfig.right.maxHeight} !important;
  1608. }
  1609. `;
  1610. }
  1611.  
  1612. if (elementConfig.right.width !== '') {
  1613. HEADER_STYLE.textContent += `
  1614. ${elementSelector.right.modalDialog}.Overlay.Overlay--size-small-portrait
  1615. {
  1616. --overlay-width: ${elementConfig.right.width};
  1617. }
  1618. `;
  1619. }
  1620. }
  1621.  
  1622. function importRepositoryHeader() {
  1623. log(DEBUG, 'importRepositoryHeader()');
  1624.  
  1625. const configKey = 'repositoryHeader';
  1626. const repositoryHeader = document.querySelector(SELECTORS[configKey].id);
  1627.  
  1628. if (!repositoryHeader) {
  1629. // This is expected on pages that aren't repositories
  1630. log(DEBUG, `Selector '${SELECTORS[configKey].id}' not found`);
  1631. return;
  1632. }
  1633.  
  1634. const topRepositoryHeaderElement = document.createElement('div');
  1635. topRepositoryHeaderElement.style.setProperty('display', 'flex');
  1636. topRepositoryHeaderElement.style.setProperty('padding', '0px');
  1637. topRepositoryHeaderElement.style.setProperty('box-shadow', 'none');
  1638.  
  1639. const elementConfig = CONFIG[configKey];
  1640.  
  1641. if (elementConfig.backgroundColor !== '') {
  1642. topRepositoryHeaderElement.style.setProperty('background-color', elementConfig.backgroundColor);
  1643. }
  1644.  
  1645. if (repositoryHeader.hidden) {
  1646. log(DEBUG, `Selector '${SELECTORS[configKey].id}' is hidden`);
  1647.  
  1648. if (!HEADER.querySelector(SELECTORS.pageTitle.separator)) {
  1649. log(DEBUG, `Selector '${SELECTORS.pageTitle.separator}' not found, not creating a repository header`);
  1650.  
  1651. return;
  1652. }
  1653.  
  1654. // A repo tab other than Code is being loaded for the first time
  1655. const pageTitle = HEADER.querySelector(SELECTORS.pageTitle.topDiv);
  1656.  
  1657. if (!pageTitle) {
  1658. logError(`Selector '${SELECTORS.pageTitle.topDiv}' not found`);
  1659. return;
  1660. }
  1661.  
  1662. const repositoryHeaderElement = document.createElement('div');
  1663. repositoryHeaderElement.setAttribute('id', TEMP_REPOSITORY_HEADER_FLAG);
  1664. repositoryHeaderElement.classList.add(REPOSITORY_HEADER_CLASS, 'pt-3', 'mb-2', 'px-md-4');
  1665.  
  1666. const clonedPageTitle = pageTitle.cloneNode(true);
  1667. repositoryHeaderElement.appendChild(clonedPageTitle);
  1668.  
  1669. topRepositoryHeaderElement.appendChild(repositoryHeaderElement);
  1670. insertNewGlobalBar(topRepositoryHeaderElement);
  1671. } else if (HEADER.querySelector(createId(TEMP_REPOSITORY_HEADER_FLAG))) {
  1672. log(DEBUG, `Selector '${createId(TEMP_REPOSITORY_HEADER_FLAG)}' found`);
  1673.  
  1674. // The Code tab is being loaded from another tab which has a temporary header
  1675. const tempRepositoryHeader = HEADER.querySelector(createId(TEMP_REPOSITORY_HEADER_FLAG));
  1676.  
  1677. NEW_ELEMENTS = NEW_ELEMENTS.filter(element => element !== tempRepositoryHeader);
  1678. tempRepositoryHeader.remove();
  1679.  
  1680. insertPermanentRepositoryHeader(topRepositoryHeaderElement, repositoryHeader);
  1681. } else {
  1682. log(
  1683. DEBUG,
  1684. `'${SELECTORS[configKey].id}' is hidden and selector '${createId(TEMP_REPOSITORY_HEADER_FLAG)}' not found`,
  1685. );
  1686.  
  1687. // The Code tab being loaded for the first time
  1688. insertPermanentRepositoryHeader(topRepositoryHeaderElement, repositoryHeader);
  1689. }
  1690.  
  1691. updateRepositoryHeaderName();
  1692.  
  1693. if (elementConfig.backgroundColor !== '') {
  1694. HEADER_STYLE.textContent += `
  1695. .${REPOSITORY_HEADER_CLASS},
  1696. .notification-shelf
  1697. {
  1698. background-color: ${elementConfig.backgroundColor} !important;
  1699. }
  1700. `;
  1701. }
  1702.  
  1703. if (elementConfig.alignCenter) {
  1704. HEADER_STYLE.textContent += `
  1705. .${REPOSITORY_HEADER_CLASS}
  1706. {
  1707. max-width: 1280px;
  1708. margin-right: auto;
  1709. margin-left: auto;
  1710. }
  1711.  
  1712. .${REPOSITORY_HEADER_CLASS} div
  1713. {
  1714. padding-left: 0px !important;
  1715. padding-right: 0px !important;
  1716. }
  1717.  
  1718. @media (min-width: 768px) {
  1719. .${REPOSITORY_HEADER_CLASS}
  1720. {
  1721. padding-right: var(--base-size-24, 24px) !important;
  1722. padding-left: var(--base-size-24, 24px) !important;
  1723. }
  1724. }
  1725.  
  1726. @media (min-width: 1012px) {
  1727. .${REPOSITORY_HEADER_CLASS}
  1728. {
  1729. padding-right: var(--base-size-32, 32px) !important;
  1730. padding-left: var(--base-size-32, 32px) !important;
  1731. }
  1732. }
  1733. `;
  1734. }
  1735.  
  1736. if (elementConfig.link.color !== '') {
  1737. HEADER_STYLE.textContent += `
  1738. ${SELECTORS.repositoryHeader.links}
  1739. {
  1740. color: ${elementConfig.link.color} !important;
  1741. }
  1742. `;
  1743. }
  1744.  
  1745. if (elementConfig.link.hover.color !== '') {
  1746. HEADER_STYLE.textContent += `
  1747. ${SELECTORS.repositoryHeader.links}:hover
  1748. {
  1749. color: ${elementConfig.link.hover.color} !important;
  1750. }
  1751. `;
  1752. }
  1753.  
  1754. if (elementConfig.link.hover.backgroundColor !== '') {
  1755. HEADER_STYLE.textContent += `
  1756. ${SELECTORS.repositoryHeader.links}:hover
  1757. {
  1758. background-color: ${elementConfig.link.hover.backgroundColor} !important;
  1759. }
  1760. `;
  1761. }
  1762.  
  1763. if (elementConfig.link.hover.textDecoration !== '') {
  1764. HEADER_STYLE.textContent += `
  1765. ${SELECTORS.repositoryHeader.links}:hover
  1766. {
  1767. text-decoration: ${elementConfig.link.hover.textDecoration} !important;
  1768. }
  1769. `;
  1770. }
  1771.  
  1772. HEADER_STYLE.textContent += `
  1773. .${REPOSITORY_HEADER_CLASS}
  1774. {
  1775. flex: auto !important;
  1776. }
  1777.  
  1778. ${SELECTORS.repositoryHeader.details}
  1779. {
  1780. display: flex;
  1781. align-items: center;
  1782. }
  1783.  
  1784. ${SELECTORS.pageTitle.topDiv}
  1785. {
  1786. flex: 0 1 auto !important;
  1787. height: auto !important;
  1788. min-width: 0 !important;
  1789. }
  1790.  
  1791. .AppHeader-context .AppHeader-context-compact
  1792. {
  1793. display: none !important;
  1794. }
  1795.  
  1796. .AppHeader-context .AppHeader-context-full
  1797. {
  1798. display: inline-flex !important;
  1799. width: 100% !important;
  1800. min-width: 0 !important;
  1801. max-width: 100% !important;
  1802. overflow: hidden !important;
  1803. }
  1804.  
  1805. .AppHeader-context .AppHeader-context-full ul {
  1806. display: flex;
  1807. flex-direction: row;
  1808. }
  1809.  
  1810. .AppHeader-context .AppHeader-context-full li:first-child {
  1811. flex: 0 100 max-content;
  1812. }
  1813.  
  1814. .AppHeader-context .AppHeader-context-full li {
  1815. display: inline-grid;
  1816. grid-auto-flow: column;
  1817. align-items: center;
  1818. flex: 0 99999 auto;
  1819. }
  1820.  
  1821. .AppHeader-context .AppHeader-context-full ul, .AppHeader .AppHeader-globalBar .AppHeader-context .AppHeader-context-full li {
  1822. list-style: none;
  1823. }
  1824.  
  1825. .AppHeader-context .AppHeader-context-item {
  1826. display: flex;
  1827. align-items: center;
  1828. min-width: 3ch;
  1829. line-height: var(--text-body-lineHeight-medium, 1.4285714286);
  1830. text-decoration: none !important;
  1831. border-radius: var(--borderRadius-medium, 6px);
  1832. padding-inline: var(--control-medium-paddingInline-condensed, 8px);
  1833. padding-block: var(--control-medium-paddingBlock, 6px);
  1834. }
  1835.  
  1836. .AppHeader-context .AppHeader-context-full li:last-child .AppHeader-context-item {
  1837. font-weight: var(--base-text-weight-semibold, 600);
  1838. }
  1839.  
  1840. .AppHeader-context .AppHeader-context-item-separator {
  1841. color: var(--fgColor-muted, var(--color-fg-muted));
  1842. white-space: nowrap;
  1843. }
  1844.  
  1845. ${SELECTORS.header.globalBar}
  1846. {
  1847. padding: 16px !important;
  1848. }
  1849. `;
  1850.  
  1851. if (elementConfig.removePageTitle) removePageTitle();
  1852.  
  1853. return true;
  1854. }
  1855.  
  1856. function insertPermanentRepositoryHeader(topRepositoryHeaderElement, repositoryHeader) {
  1857. log(DEBUG, 'insertPermanentRepositoryHeader()');
  1858.  
  1859. const clonedRepositoryHeader = repositoryHeader.cloneNode(true);
  1860.  
  1861. // This is needed to prevent pop-in via Turbo when navigating between tabs on a repo
  1862. repositoryHeader.removeAttribute('data-turbo-replace');
  1863. clonedRepositoryHeader.removeAttribute('data-turbo-replace');
  1864.  
  1865. repositoryHeader.style.setProperty('display', 'none', 'important');
  1866.  
  1867. clonedRepositoryHeader.classList.add(REPOSITORY_HEADER_SUCCESS_FLAG, REPOSITORY_HEADER_CLASS);
  1868.  
  1869. topRepositoryHeaderElement.appendChild(clonedRepositoryHeader);
  1870.  
  1871. insertNewGlobalBar(topRepositoryHeaderElement);
  1872.  
  1873. clonedRepositoryHeader.firstElementChild.classList.remove('container-xl', 'px-lg-5');
  1874.  
  1875. NEW_ELEMENTS.push(clonedRepositoryHeader);
  1876. }
  1877.  
  1878. function updateRepositoryHeaderName() {
  1879. log(DEBUG, 'updateRepositoryHeaderName()');
  1880.  
  1881. const elementConfig = CONFIG.repositoryHeader;
  1882.  
  1883. const name = document.querySelector(SELECTORS.repositoryHeader.name);
  1884.  
  1885. if (!name) {
  1886. // When not in a repo, this is expected
  1887. log(DEBUG, `Selector '${SELECTORS.repositoryHeader.name}' not found`);
  1888. return;
  1889. }
  1890.  
  1891. name.style.setProperty('display', 'none', 'important');
  1892.  
  1893. const pageTitle = HEADER.querySelector(SELECTORS.pageTitle.topDiv);
  1894.  
  1895. if (!pageTitle) {
  1896. logError(`Selector '${SELECTORS.pageTitle.topDiv}' not found`);
  1897. return;
  1898. }
  1899.  
  1900. const ownerImg = document.querySelector(SELECTORS.repositoryHeader.ownerImg);
  1901.  
  1902. if (!ownerImg) {
  1903. log(INFO, `Selector '${SELECTORS.repositoryHeader.ownerImg}' not found`);
  1904. return;
  1905. }
  1906.  
  1907. const clonedPageTitle = pageTitle.cloneNode(true);
  1908. clonedPageTitle.style.display = '';
  1909.  
  1910. const pageTitleId = `${REPOSITORY_HEADER_CLASS}_pageTitle`;
  1911. clonedPageTitle.setAttribute('id', pageTitleId);
  1912. clonedPageTitle.querySelector('img')?.remove();
  1913.  
  1914. HEADER_STYLE.textContent += `
  1915. ${createId(pageTitleId)}
  1916. {
  1917. display: initial !important;
  1918. }
  1919. `;
  1920.  
  1921. clonedPageTitle.querySelectorAll('svg.octicon-lock').forEach(svg => svg.remove());
  1922. clonedPageTitle.querySelectorAll('a[href$="/stargazers"]').forEach(link => link.remove());
  1923.  
  1924. ownerImg.parentNode.insertBefore(clonedPageTitle, ownerImg.nextSibling);
  1925. NEW_ELEMENTS.push(clonedPageTitle);
  1926.  
  1927. if (elementConfig.avatar.remove) {
  1928. ownerImg.remove();
  1929. } else if (elementConfig.avatar.customSvg !== '') {
  1930. if (isValidURL(elementConfig.avatar.customSvg)) {
  1931. ownerImg.src = elementConfig.avatar.customSvg;
  1932. } else {
  1933. const divElement = document.createElement('div');
  1934. divElement.style.setProperty('display', 'flex');
  1935. divElement.style.setProperty('align-items', 'center');
  1936.  
  1937. divElement.innerHTML = elementConfig.avatar.customSvg;
  1938.  
  1939. ownerImg.parentNode.replaceChild(divElement, ownerImg);
  1940. }
  1941. }
  1942.  
  1943. HEADER_STYLE.textContent += cssHideElement(SELECTORS.repositoryHeader.bottomBorder);
  1944. }
  1945.  
  1946. function cloneAndLeftAlignElement(elementSelector, elementId) {
  1947. log(DEBUG, 'cloneAndLeftAlignElement()');
  1948.  
  1949. const leftAlignedDiv = HEADER.querySelector(SELECTORS.header.leftAligned);
  1950.  
  1951. if (!leftAlignedDiv) {
  1952. logError(`Selector '${SELECTORS.header.leftAligned}' not found`);
  1953. return [];
  1954. }
  1955.  
  1956. const element = HEADER.querySelector(elementSelector);
  1957.  
  1958. if (!element) {
  1959. logError(`Selector '${elementSelector}' not found`);
  1960. return [];
  1961. }
  1962.  
  1963. const elementClone = element.cloneNode(true);
  1964. const elementCloneId = `${elementId}-clone`;
  1965.  
  1966. elementClone.setAttribute('id', elementCloneId);
  1967.  
  1968. elementClone.style.setProperty('display', 'none');
  1969.  
  1970. HEADER_STYLE.textContent += cssHideElement(elementSelector);
  1971.  
  1972. HEADER_STYLE.textContent += `
  1973. ${createId(elementCloneId)}
  1974. {
  1975. display: flex !important;
  1976. }
  1977. `;
  1978.  
  1979. leftAlignedDiv.appendChild(elementClone);
  1980.  
  1981. NEW_ELEMENTS.push(elementClone);
  1982.  
  1983. return [elementCloneId, elementClone];
  1984. }
  1985.  
  1986. function insertNewGlobalBar(element) {
  1987. log(DEBUG, 'insertNewGlobalBar()');
  1988.  
  1989. const elementToInsertAfter = HEADER.querySelector(SELECTORS.header.globalBar);
  1990.  
  1991. elementToInsertAfter.parentNode.insertBefore(element, elementToInsertAfter.nextSibling);
  1992. }
  1993.  
  1994. function createId(string) {
  1995. log(TRACE, 'createId()');
  1996.  
  1997. if (string.startsWith('#')) return string;
  1998.  
  1999. if (string.startsWith('.')) {
  2000. logError(`Attempted to create an id from a class: "${string}"`);
  2001. return;
  2002. }
  2003.  
  2004. if (string.startsWith('[')) {
  2005. logError(`Attempted to create an id from an attribute selector: "${string}"`);
  2006. return;
  2007. }
  2008.  
  2009. return `#${string}`;
  2010. }
  2011.  
  2012. function cssHideElement(elementSelector) {
  2013. log(TRACE, 'cssHideElement()');
  2014.  
  2015. return `
  2016. ${elementSelector}
  2017. {
  2018. display: none !important;
  2019. }
  2020. `;
  2021. }
  2022.  
  2023. function isValidURL(string) {
  2024. log(DEBUG, 'isValidURL()');
  2025.  
  2026. const urlPattern = /^(https?:\/\/)?([\w.]+)\.([a-z]{2,6}\.?)(\/[\w.]*)*\/?$/i;
  2027. return urlPattern.test(string);
  2028. }
  2029.  
  2030. function escapeRegExp(string) {
  2031. log(DEBUG, 'escapeRegExp()');
  2032.  
  2033. return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  2034. }
  2035.  
  2036. function compareObjects(firstObject, secondObject, firstName, secondName) {
  2037. log(DEBUG, 'compareObjects()');
  2038.  
  2039. if (typeof firstObject !== 'object' || typeof secondObject !== 'object') {
  2040. return 'Invalid input. Please provide valid objects.';
  2041. }
  2042.  
  2043. const differences = [];
  2044.  
  2045. function findKeyDifferences(obj1, obj2, path = '') {
  2046. const keys1 = Object.keys(obj1);
  2047. const keys2 = Object.keys(obj2);
  2048.  
  2049. keys1.forEach(key => {
  2050. const nestedPath = path ? `${path}.${key}` : key;
  2051. if (!keys2.includes(key)) {
  2052. differences.push(`Found "${nestedPath}" in ${firstName} but not in ${secondName}`);
  2053. } else if (typeof obj1[key] === 'object' && typeof obj2[key] === 'object') {
  2054. findKeyDifferences(obj1[key], obj2[key], nestedPath);
  2055. }
  2056. });
  2057.  
  2058. keys2.forEach(key => {
  2059. const nestedPath = path ? `${path}.${key}` : key;
  2060. if (!keys1.includes(key)) {
  2061. differences.push(`Found "${nestedPath}" in ${secondName} but not in ${firstName}`);
  2062. }
  2063. });
  2064. }
  2065.  
  2066. findKeyDifferences(firstObject, secondObject);
  2067. return differences.length > 0 ? differences : [];
  2068. }
  2069.  
  2070. // eslint-disable-next-line no-unused-vars
  2071. function checkConfigConsistency(configs) {
  2072. log(DEBUG, 'checkConfigConsistency()');
  2073.  
  2074. const lightDarkDifference = compareObjects(
  2075. configs.happyMedium.light,
  2076. configs.happyMedium.dark,
  2077. 'Happy Medium Light',
  2078. 'Happy Medium Dark',
  2079. );
  2080.  
  2081. if (lightDarkDifference.length > 0) {
  2082. logError('lightDarkDifference', lightDarkDifference);
  2083.  
  2084. return false;
  2085. }
  2086.  
  2087. const typeDifference = compareObjects(
  2088. configs.happyMedium,
  2089. configs.oldSchool,
  2090. 'Happy Medium',
  2091. 'Old School',
  2092. );
  2093.  
  2094. if (typeDifference.length > 0) {
  2095. logError('typeDifference', typeDifference);
  2096.  
  2097. return false;
  2098. }
  2099.  
  2100. return true;
  2101. }
  2102.  
  2103. function updateSelectors() {
  2104. log(DEBUG, 'updateSelectors()');
  2105.  
  2106. const toolTips = Array.from(HEADER.querySelectorAll('tool-tip'));
  2107. SELECTORS.toolTips = {
  2108. copilot: toolTips.find(
  2109. tooltip => tooltip.getAttribute('for') === 'copilot-chat-header-button',
  2110. ),
  2111. create: toolTips.find(
  2112. tooltip => tooltip.textContent.includes('Create new'),
  2113. ),
  2114. pullRequests: toolTips.find(
  2115. tooltip => tooltip.textContent.includes('Your pull requests'),
  2116. ),
  2117. issues: toolTips.find(
  2118. tooltip => tooltip.textContent.includes('Your issues'),
  2119. ),
  2120. notifications: toolTips.find(
  2121. tooltip => tooltip.getAttribute('data-target') === 'notification-indicator.tooltip',
  2122. ),
  2123. };
  2124. }
  2125.  
  2126. function waitForFeaturePreviewButton() {
  2127. log(VERBOSE, 'waitForFeaturePreviewButton()');
  2128.  
  2129. if (!HEADER) return;
  2130.  
  2131. const liElementId = 'custom-global-navigation-menu-item';
  2132.  
  2133. if (HEADER.querySelector(createId(liElementId))) return;
  2134.  
  2135. const featurePreviewSearch = Array.from(
  2136. document.querySelectorAll('[data-position-regular="right"] span'),
  2137. )?.find(element => element.textContent === 'Feature preview') || null;
  2138.  
  2139. if (featurePreviewSearch) {
  2140. const featurePreviewSpan = featurePreviewSearch;
  2141. const featurePreviewLabelDiv = featurePreviewSpan.parentNode;
  2142. const featurePreviewLi = featurePreviewLabelDiv.parentNode;
  2143.  
  2144. const newLiElement = featurePreviewLi.cloneNode(true);
  2145. newLiElement.setAttribute('id', liElementId);
  2146.  
  2147. newLiElement.onclick = () => {
  2148. const closeButton = document.querySelector(SELECTORS.sidebars.right.closeButton);
  2149. if (!closeButton) {
  2150. logError(`Selector '${SELECTORS.sidebars.right.closeButton}' not found`);
  2151. } else {
  2152. closeButton.click();
  2153. }
  2154.  
  2155. GMC.open();
  2156. };
  2157.  
  2158. const textElement = newLiElement.querySelector('[data-component="ActionList.Item--DividerContainer"]');
  2159. textElement.textContent = GMC.get('menu_item_title');
  2160.  
  2161. const oldSvg = newLiElement.querySelector('svg');
  2162.  
  2163. const menuItemIcon = GMC.get('menu_item_icon');
  2164. if (menuItemIcon === 'logo') {
  2165. const newSvg = document.createElement('img');
  2166. newSvg.setAttribute('height', '16px');
  2167. newSvg.setAttribute('width', '16px');
  2168. newSvg.src = `https://raw.githubusercontent.com/blakegearin/github-custom-global-navigation/main/img/${THEME}_logo.svg`;
  2169.  
  2170. oldSvg.parentNode.replaceChild(newSvg, oldSvg);
  2171. } else {
  2172. let svgString;
  2173.  
  2174. if (menuItemIcon === 'cog') {
  2175. svgString = `
  2176. <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">
  2177. <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>
  2178. </svg>
  2179. `;
  2180. } else if (menuItemIcon === 'compass') {
  2181. svgString = `
  2182. <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512">
  2183. <!--! Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. -->
  2184. <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"/>
  2185. </svg>
  2186. `;
  2187. }
  2188.  
  2189. const parser = new DOMParser();
  2190. const svgDoc = parser.parseFromString(svgString, 'image/svg+xml');
  2191. const newSvg = svgDoc.documentElement;
  2192.  
  2193. oldSvg.parentNode.replaceChild(newSvg, oldSvg);
  2194. }
  2195.  
  2196. const parentUl = featurePreviewLi.parentNode;
  2197. const settingsLi = document.querySelector('[data-position-regular="right"] a[href="/settings/profile"]').parentNode;
  2198.  
  2199. parentUl.insertBefore(newLiElement, settingsLi.nextSibling);
  2200.  
  2201. const divider = featurePreviewLi.parentNode.querySelector(SELECTORS.sidebars.right.divider);
  2202. if (!divider) {
  2203. logError(`Selector '${SELECTORS.sidebars.right.divider}' not found`);
  2204. return;
  2205. }
  2206. const newDivider = divider.cloneNode(true);
  2207.  
  2208. parentUl.insertBefore(newDivider, settingsLi.nextSibling);
  2209. } else {
  2210. setTimeout(waitForFeaturePreviewButton, 100);
  2211. }
  2212. }
  2213.  
  2214. function generateCustomConfig() {
  2215. log(DEBUG, 'generateCustomConfig()');
  2216.  
  2217. const customConfig = {
  2218. light: {},
  2219. dark: {},
  2220. };
  2221.  
  2222. function recursivelyGenerateCustomConfig(obj, customObj, themePrefix, parentKey = '') {
  2223. for (const key in obj) {
  2224. const currentKey = parentKey ? `${parentKey}.${key}` : key;
  2225. if (typeof obj[key] === 'object') {
  2226. customObj[key] = {};
  2227. recursivelyGenerateCustomConfig(obj[key], customObj[key], themePrefix, currentKey);
  2228. } else {
  2229. const gmcKey = `${themePrefix}_${currentKey.replace(/\./g, '_')}`;
  2230.  
  2231. if (gmcKey in GMC.fields) {
  2232. customObj[key] = GMC.get(gmcKey);
  2233. } else {
  2234. logError(`GMC field not found for key: ${gmcKey}`);
  2235. return;
  2236. }
  2237. }
  2238. }
  2239. }
  2240.  
  2241. recursivelyGenerateCustomConfig(configs.happyMedium.light, customConfig.light, 'light');
  2242. recursivelyGenerateCustomConfig(configs.happyMedium.dark, customConfig.dark, 'dark');
  2243.  
  2244. return customConfig;
  2245. }
  2246.  
  2247. function setTheme() {
  2248. log(DEBUG, 'setTheme()');
  2249.  
  2250. const dataColorMode = document.querySelector('html').getAttribute('data-color-mode');
  2251.  
  2252. if (dataColorMode === 'auto') {
  2253. if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
  2254. THEME = 'dark';
  2255. }
  2256. } else if (dataColorMode === 'dark') {
  2257. THEME = 'dark';
  2258. } else if (dataColorMode !== 'light') {
  2259. logError('Unknown color mode');
  2260. }
  2261.  
  2262. log(VERBOSE, `THEME: ${THEME}`);
  2263. }
  2264.  
  2265. function gmcInitialized() {
  2266. log(DEBUG, 'gmcInitialized()');
  2267.  
  2268. updateLogLevel();
  2269.  
  2270. log(QUIET, 'Running');
  2271.  
  2272. GMC.css.basic = '';
  2273.  
  2274. startObserving();
  2275. }
  2276.  
  2277. function gmcAddSavedSpan(div) {
  2278. log(DEBUG, 'gmcAddSavedSpan()');
  2279.  
  2280. const savedDiv = document.createElement('div');
  2281. savedDiv.setAttribute('id', 'gmc-saved');
  2282.  
  2283. const iconSpan = document.createElement('span');
  2284. iconSpan.style = 'margin-right: 4px;';
  2285.  
  2286. iconSpan.innerHTML = `
  2287. <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;">
  2288. <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>
  2289. </svg>
  2290. `;
  2291.  
  2292. const textSpan = document.createElement('span');
  2293. textSpan.innerText = 'Saved';
  2294.  
  2295. savedDiv.appendChild(iconSpan);
  2296. savedDiv.appendChild(textSpan);
  2297.  
  2298. div.insertBefore(savedDiv, div.firstChild);
  2299. }
  2300.  
  2301. function gmcAddNewIssueButton(div) {
  2302. log(DEBUG, 'gmcAddNewIssueButton()');
  2303.  
  2304. const small = document.createElement('small');
  2305. small.classList.add('left-aligned');
  2306. small.setAttribute('title', 'Submit bug or feature request');
  2307.  
  2308. const link = document.createElement('a');
  2309. link.href = 'https://github.com/blakegearin/github-custom-global-navigation/issues';
  2310. link.innerText = 'submit bug or feature request';
  2311.  
  2312. small.appendChild(link);
  2313.  
  2314. div.insertBefore(small, div.firstChild);
  2315. }
  2316.  
  2317. function gmcOpened() {
  2318. log(DEBUG, 'gmcOpened()');
  2319.  
  2320. function updateCheckboxes() {
  2321. log(DEBUG, 'updateCheckboxes()');
  2322.  
  2323. const checkboxes = document.querySelectorAll('#gmc-frame input[type="checkbox"]');
  2324.  
  2325. if (checkboxes.length > 0) {
  2326. checkboxes.forEach(checkbox => {
  2327. checkbox.classList.add('gmc-checkbox');
  2328. });
  2329. } else {
  2330. setTimeout(updateCheckboxes, 100);
  2331. }
  2332. }
  2333.  
  2334. updateCheckboxes();
  2335.  
  2336. const configVars = document.querySelectorAll('.config_var');
  2337.  
  2338. configVars.forEach(configVar => {
  2339. const label = configVar.querySelector('.field_label');
  2340. const input = configVar.querySelector('input');
  2341.  
  2342. if (label && input && input.type === 'text') label.style.lineHeight = '33px';
  2343.  
  2344. const select = configVar.querySelector('select');
  2345.  
  2346. if (label && select) label.style.lineHeight = '33px';
  2347. });
  2348.  
  2349. modifyThenObserve(() => {
  2350. document.querySelector('#gmc-frame .reset_holder').remove();
  2351.  
  2352. const buttonHolderSelector = '#gmc-frame_buttons_holder';
  2353. const parentDiv = document.querySelector(buttonHolderSelector);
  2354.  
  2355. if (!parentDiv) {
  2356. logError(`Selector ${buttonHolderSelector} not found`);
  2357. return;
  2358. }
  2359.  
  2360. gmcAddSavedSpan(parentDiv);
  2361. gmcAddNewIssueButton(parentDiv);
  2362. });
  2363.  
  2364. document.querySelector('#gmc').classList.remove('hidden');
  2365. }
  2366.  
  2367. function gmcRefreshTab() {
  2368. location.reload();
  2369. }
  2370.  
  2371. function gmcRunScript() {
  2372. applyCustomizations(true);
  2373. }
  2374.  
  2375. function updateLogLevel() {
  2376. CURRENT_LOG_LEVEL = {
  2377. silent: SILENT,
  2378. quiet: QUIET,
  2379. info: INFO,
  2380. debug: DEBUG,
  2381. verbose: VERBOSE,
  2382. trace: TRACE,
  2383. }[GMC.get('log_level')];
  2384. }
  2385.  
  2386. function gmcSaved() {
  2387. log(DEBUG, 'gmcSaved()');
  2388.  
  2389. const gmcSaved = document.getElementById('gmc-saved');
  2390.  
  2391. gmcSaved.style.display = 'block';
  2392.  
  2393. setTimeout(
  2394. () => gmcSaved.style.display = 'none',
  2395. 2750,
  2396. );
  2397.  
  2398. updateLogLevel();
  2399.  
  2400. switch (GMC.get('on_save')) {
  2401. case 'refresh tab':
  2402. gmcRefreshTab();
  2403. break;
  2404. case 'refresh tab and close':
  2405. gmcRefreshTab();
  2406. GMC.close();
  2407. break;
  2408. case 'run script':
  2409. gmcRunScript();
  2410. break;
  2411. case 'run script and close':
  2412. gmcRunScript();
  2413. GMC.close();
  2414. break;
  2415. }
  2416. }
  2417.  
  2418. function gmcClosed() {
  2419. log(DEBUG, 'gmcClosed()');
  2420.  
  2421. switch (GMC.get('on_close')) {
  2422. case 'refresh tab':
  2423. gmcRefreshTab();
  2424. break;
  2425. case 'run script':
  2426. gmcRunScript();
  2427. break;
  2428. }
  2429.  
  2430. document.querySelector('#gmc').classList.add('hidden');
  2431. }
  2432.  
  2433. function gmcClearCustom() {
  2434. log(DEBUG, 'gmcClearCustom()');
  2435.  
  2436. const confirmed = confirm('Are you sure you want to clear your custom configuration? This is irreversible.');
  2437.  
  2438. if (confirmed) {
  2439. const currentType = GMC.get('type');
  2440. GMC.reset();
  2441. GMC.save();
  2442.  
  2443. GMC.set('type', currentType);
  2444. GMC.save();
  2445. }
  2446. }
  2447.  
  2448. function configsToGMC(config, path = []) {
  2449. log(DEBUG, 'configsToGMC()');
  2450.  
  2451. for (const key in config) {
  2452. if (typeof config[key] === 'object' && !Array.isArray(config[key])) {
  2453. configsToGMC(config[key], path.concat(key));
  2454. } else {
  2455. const fieldName = path.concat(key).join('_');
  2456. const fieldValue = config[key];
  2457.  
  2458. log(VERBOSE, 'fieldName', fieldName);
  2459. GMC.set(fieldName, fieldValue);
  2460. }
  2461. }
  2462. }
  2463.  
  2464. function gmcApplyCustomHappyMediumConfig() {
  2465. log(DEBUG, 'gmcApplyCustomHappyMediumConfig()');
  2466.  
  2467. const confirmed = confirm('Are you sure you want to overwrite your custom configuration with Happy Medium? This is irreversible.');
  2468.  
  2469. if (confirmed) {
  2470. configsToGMC(configs.happyMedium);
  2471. GMC.save();
  2472. }
  2473. }
  2474.  
  2475. function gmcApplyCustomOldSchoolConfig() {
  2476. log(DEBUG, 'gmcApplyCustomOldSchoolConfig()');
  2477.  
  2478. const confirmed = confirm('Are you sure you want to overwrite your custom configuration with Old School? This is irreversible.');
  2479.  
  2480. if (confirmed) {
  2481. configsToGMC(configs.oldSchool);
  2482. GMC.save();
  2483. }
  2484. }
  2485.  
  2486. function gmcBuildStyle() {
  2487. log(DEBUG, 'gmcBuildStyle()');
  2488.  
  2489. const headerIdPartials = [
  2490. 'hamburgerButton_remove_var',
  2491. 'logo_remove_var',
  2492. 'pageTitle_remove_var',
  2493. 'search_remove_var',
  2494. 'divider_remove_var',
  2495. 'create_remove_var',
  2496. 'issues_remove_var',
  2497. 'pullRequests_remove_var',
  2498. 'marketplace_add_var',
  2499. 'explore_add_var',
  2500. 'notifications_remove_var',
  2501. 'light_avatar_remove_var',
  2502. 'dark_avatar_remove_var',
  2503. 'globalBar_boxShadowColor_var',
  2504. 'localBar_backgroundColor_var',
  2505. 'sidebars_backdrop_color_var',
  2506. 'repositoryHeader_import_var',
  2507. 'flipCreateInbox_var',
  2508. 'flipIssuesPullRequests_var',
  2509. ];
  2510.  
  2511. const sectionSelectors = headerIdPartials
  2512. .map(varName => `#gmc-frame .config_var[id*='${varName}']`)
  2513. .join(',\n');
  2514.  
  2515. const gmcFrameStyle = document.createElement('style');
  2516. gmcFrameStyle.textContent += `
  2517. /* Modal */
  2518.  
  2519. #gmc
  2520. {
  2521. display: inline-flex !important;
  2522. justify-content: center !important;
  2523. align-items: center !important;
  2524. position: fixed !important;
  2525. top: 0 !important;
  2526. left: 0 !important;
  2527. width: 100vw !important;
  2528. height: 100vh !important;
  2529. z-index: 9999;
  2530. background: none !important;
  2531.  
  2532. pointer-events: none;
  2533. }
  2534.  
  2535. #gmc.hidden
  2536. {
  2537. display: none !important;
  2538. }
  2539.  
  2540. #gmc-frame
  2541. {
  2542. font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
  2543. text-align: left;
  2544.  
  2545. inset: initial !important;
  2546. border: none !important;
  2547. max-height: initial !important;
  2548. max-width: initial !important;
  2549. opacity: 1 !important;
  2550. position: static !important;
  2551. z-index: initial !important;
  2552.  
  2553. width: 85% !important;
  2554. height: 75% !important;
  2555. overflow-y: auto !important;
  2556.  
  2557. border: none !important;
  2558. border-radius: 0.375rem !important;
  2559.  
  2560. pointer-events: auto;
  2561. }
  2562.  
  2563. #gmc-frame_wrapper
  2564. {
  2565. display: flow-root !important;
  2566. padding: 2rem !important;
  2567. }
  2568.  
  2569. /* Sections */
  2570.  
  2571. #gmc-frame #gmc-frame_section_0
  2572. {
  2573. width: 100%;
  2574. border-radius: 6px;
  2575. display: table;
  2576. }
  2577.  
  2578. #gmc-frame #gmc-frame_section_1,
  2579. #gmc-frame #gmc-frame_section_2,
  2580. #gmc-frame #gmc-frame_section_3,
  2581. #gmc-frame #gmc-frame_section_4
  2582. {
  2583. margin-top: 2rem;
  2584. width: 49%;
  2585. box-sizing: border-box;
  2586. }
  2587.  
  2588. #gmc-frame #gmc-frame_section_1
  2589. {
  2590. border-radius: 6px;
  2591. float: left;
  2592. }
  2593.  
  2594. #gmc-frame #gmc-frame_section_2
  2595. {
  2596. border-radius: 6px;
  2597. float: right;
  2598. }
  2599.  
  2600. #gmc-frame #gmc-frame_section_3
  2601. {
  2602. width: 49%;
  2603. margin-top: 2rem;
  2604. box-sizing: border-box;
  2605. border-radius: 6px;
  2606. float: left;
  2607. }
  2608.  
  2609. #gmc-frame #gmc-frame_section_4
  2610. {
  2611. display: inline-grid;
  2612. width: 49%;
  2613. margin-top: 2rem;
  2614. box-sizing: border-box;
  2615. border-radius: 6px;
  2616. float: right
  2617. }
  2618.  
  2619. #gmc-frame #gmc-frame_section_3 .config_var:not(:last-child),
  2620. #gmc-frame #gmc-frame_section_4 .config_var:not(:last-child)
  2621. {
  2622. padding-bottom: 1rem;
  2623. }
  2624.  
  2625. /* Fields */
  2626.  
  2627. #gmc-frame .config_header
  2628. {
  2629. font-size: 2em;
  2630. font-weight: 400;
  2631. line-height: 1.25;
  2632.  
  2633. padding-bottom: 0.3em;
  2634. margin-bottom: 16px;
  2635. }
  2636.  
  2637. #gmc-frame #gmc-frame_type_var
  2638. {
  2639. display: inline-flex;
  2640. }
  2641.  
  2642. #gmc-frame .section_header
  2643. {
  2644. font-size: 1.5em;
  2645. font-weight: 600;
  2646. line-height: 1.25;
  2647.  
  2648. margin-bottom: 16px;
  2649. padding: 1rem 1.5rem;
  2650. }
  2651.  
  2652. #gmc-frame .section_desc,
  2653. #gmc-frame h3
  2654. {
  2655. background: none;
  2656. border: none;
  2657. font-size: 1.25em;
  2658.  
  2659. margin-bottom: 16px;
  2660. font-weight: 600;
  2661. line-height: 1.25;
  2662. text-align: left;
  2663. }
  2664.  
  2665. #gmc-frame .config_var
  2666. {
  2667. padding: 0rem 1.5rem;
  2668. margin-bottom: 1rem;
  2669. display: flex;
  2670. }
  2671.  
  2672. ${sectionSelectors}
  2673. {
  2674. display: flow;
  2675. padding-top: 1rem;
  2676. }
  2677.  
  2678. #gmc-frame .config_var[id*='flipCreateInbox_var'],
  2679. #gmc-frame .config_var[id*='flipIssuesPullRequests_var']
  2680. {
  2681. display: flex;
  2682. }
  2683.  
  2684. #gmc-frame .field_label
  2685. {
  2686. font-weight: 600;
  2687. margin-right: 0.5rem;
  2688. }
  2689.  
  2690. #gmc-frame .field_label,
  2691. #gmc-frame .gmc-label
  2692. {
  2693. width: 15vw;
  2694. }
  2695.  
  2696. #gmc-frame .radio_label:not(:last-child)
  2697. {
  2698. margin-right: 4rem;
  2699. }
  2700.  
  2701. #gmc-frame .radio_label
  2702. {
  2703. line-height: 17px;
  2704. }
  2705.  
  2706. #gmc-frame .gmc-label
  2707. {
  2708. display: table-caption;
  2709. line-height: 17px;
  2710. }
  2711.  
  2712. #gmc-frame input[type="radio"]
  2713. {
  2714. appearance: none;
  2715. border-style: solid;
  2716. cursor: pointer;
  2717. height: 1rem;
  2718. place-content: center;
  2719. position: relative;
  2720. width: 1rem;
  2721. border-radius: 624rem;
  2722. transition: background-color 0s ease 0s, border-color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s;
  2723. margin-right: 0.5rem;
  2724. flex: none;
  2725. }
  2726.  
  2727. #gmc-frame input[type="checkbox"]
  2728. {
  2729. appearance: none;
  2730. border-style: solid;
  2731. border-width: 1px;
  2732. cursor: pointer;
  2733. place-content: center;
  2734. position: relative;
  2735. height: 17px;
  2736. width: 17px;
  2737. border-radius: 3px;
  2738. transition: background-color 0s ease 0s, border-color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s;
  2739. }
  2740.  
  2741. #gmc-frame #gmc-frame_field_type
  2742. {
  2743. display: flex;
  2744. }
  2745.  
  2746. #gmc-frame input[type="radio"]:checked
  2747. {
  2748. border-width: 0.25rem;
  2749. }
  2750.  
  2751. #gmc-frame input[type="radio"]:checked,
  2752. #gmc-frame .gmc-checkbox:checked
  2753. {
  2754. border-color: #2f81f7;
  2755. }
  2756.  
  2757. #gmc-frame .gmc-checkbox:checked
  2758. {
  2759. background-color: #2f81f7;
  2760. }
  2761.  
  2762. #gmc-frame .gmc-checkbox:checked::before
  2763. {
  2764. visibility: visible;
  2765. transition: visibility 0s linear 0s;
  2766. }
  2767.  
  2768. #gmc-frame .gmc-checkbox::before,
  2769. #gmc-frame .gmc-checkbox:indeterminate::before
  2770. {
  2771. animation: 80ms cubic-bezier(0.65, 0, 0.35, 1) 80ms 1 normal forwards running checkmarkIn;
  2772. }
  2773.  
  2774. #gmc-frame .gmc-checkbox::before
  2775. {
  2776. width: 1rem;
  2777. height: 1rem;
  2778. visibility: hidden;
  2779. content: "";
  2780. background-color: #FFFFFF;
  2781. clip-path: inset(1rem 0 0 0);
  2782. -webkit-mask-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iOSIgdmlld0JveD0iMCAwIDEyIDkiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMTEuNzgwMyAwLjIxOTYyNUMxMS45MjEgMC4zNjA0MjcgMTIgMC41NTEzMDUgMTIgMC43NTAzMTNDMTIgMC45NDkzMjEgMTEuOTIxIDEuMTQwMTkgMTEuNzgwMyAxLjI4MUw0LjUxODYgOC41NDA0MkM0LjM3Nzc1IDguNjgxIDQuMTg2ODIgOC43NiAzLjk4Nzc0IDguNzZDMy43ODg2NyA4Ljc2IDMuNTk3NzMgOC42ODEgMy40NTY4OSA4LjU0MDQyTDAuMjAxNjIyIDUuMjg2MkMwLjA2ODkyNzcgNS4xNDM4MyAtMC4wMDMzMDkwNSA0Ljk1NTU1IDAuMDAwMTE2NDkzIDQuNzYwOThDMC4wMDM1NTIwNSA0LjU2NjQzIDAuMDgyMzg5NCA0LjM4MDgxIDAuMjIwMDMyIDQuMjQzMjFDMC4zNTc2NjUgNC4xMDU2MiAwLjU0MzM1NSA0LjAyNjgxIDAuNzM3OTcgNC4wMjMzOEMwLjkzMjU4NCA0LjAxOTk0IDEuMTIwOTMgNC4wOTIxNyAxLjI2MzM0IDQuMjI0ODJMMy45ODc3NCA2Ljk0ODM1TDEwLjcxODYgMC4yMTk2MjVDMTAuODU5NSAwLjA3ODk5MjMgMTEuMDUwNCAwIDExLjI0OTUgMEMxMS40NDg1IDAgMTEuNjM5NSAwLjA3ODk5MjMgMTEuNzgwMyAwLjIxOTYyNVoiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPgo=");
  2783. -webkit-mask-size: 75%;
  2784. -webkit-mask-repeat: no-repeat;
  2785. -webkit-mask-position: center center;
  2786. display: block;
  2787. }
  2788.  
  2789. #gmc-frame .gmc-checkbox
  2790. {
  2791. appearance: none;
  2792. border-style: solid;
  2793. border-width: 1px;
  2794. cursor: pointer;
  2795.  
  2796. height: var(--base-size-16,16px);
  2797. margin: 0.125rem 0px 0px;
  2798. place-content: center;
  2799. position: relative;
  2800. width: var(--base-size-16,16px);
  2801. border-radius: 3px;
  2802. transition: background-color 0s ease 0s, border-color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s;
  2803. }
  2804.  
  2805. #gmc-frame input
  2806. {
  2807. color: fieldtext;
  2808. letter-spacing: normal;
  2809. word-spacing: normal;
  2810. text-transform: none;
  2811. text-indent: 0px;
  2812. text-shadow: none;
  2813. display: inline-block;
  2814. text-align: start;
  2815. appearance: auto;
  2816. -webkit-rtl-ordering: logical;
  2817. }
  2818.  
  2819. #gmc-frame .gmc-checkbox:checked
  2820. {
  2821. transition: background-color 0s ease 0s, border-color 80ms cubic-bezier(0.32, 0, 0.67, 0) 0ms;
  2822. }
  2823.  
  2824. #gmc-frame input[type="text"],
  2825. #gmc-frame textarea,
  2826. #gmc-frame select
  2827. {
  2828. padding: 5px 12px;
  2829. border-radius: 6px;
  2830. }
  2831.  
  2832. #gmc-frame input[type="text"]:focus,
  2833. #gmc-frame textarea:focus,
  2834. #gmc-frame select:focus
  2835. {
  2836. border-color: #2f81f7;
  2837. outline: 1px solid #2f81f7;
  2838. }
  2839.  
  2840. #gmc-frame svg
  2841. {
  2842. height: 17px;
  2843. width: 17px;
  2844. margin-left: 0.5rem;
  2845. }
  2846.  
  2847. #gmc small
  2848. {
  2849. font-size: x-small;
  2850. font-weight: 600;
  2851. margin-left: 3px;
  2852. }
  2853.  
  2854. /* Button bar */
  2855.  
  2856. #gmc-frame #gmc-frame_buttons_holder
  2857. {
  2858. position: fixed;
  2859. width: 85%;
  2860. text-align: right;
  2861.  
  2862. left: 50%;
  2863. bottom: 2%;
  2864. transform: translate(-50%, 0%);
  2865. padding: 1rem;
  2866.  
  2867. border-radius: 0.375rem;
  2868.  
  2869. display: flex;
  2870. align-items: center;
  2871. }
  2872.  
  2873. #gmc-frame #gmc-frame_buttons_holder .left-aligned
  2874. {
  2875. order: 1;
  2876. margin-right: auto;
  2877. }
  2878.  
  2879. #gmc-frame #gmc-frame_buttons_holder > *
  2880. {
  2881. order: 2;
  2882. }
  2883.  
  2884. #gmc-frame .saveclose_buttons
  2885. {
  2886. margin-left: 0.5rem;
  2887. }
  2888.  
  2889. #gmc-frame [type=button],
  2890. #gmc-frame .saveclose_buttons
  2891. {
  2892. position: relative;
  2893. display: inline-block;
  2894. padding: 5px 16px;
  2895. font-size: 14px;
  2896. font-weight: 500;
  2897. line-height: 20px;
  2898. white-space: nowrap;
  2899. vertical-align: middle;
  2900. cursor: pointer;
  2901. -webkit-user-select: none;
  2902. user-select: none;
  2903. border: 1px solid;
  2904. border-radius: 6px;
  2905. -webkit-appearance: none;
  2906. appearance: none;
  2907.  
  2908. font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
  2909. }
  2910.  
  2911. @keyframes fadeOut
  2912. {
  2913. from {
  2914. opacity: 1;
  2915. }
  2916. to {
  2917. opacity: 0;
  2918. }
  2919. }
  2920.  
  2921. #gmc-saved
  2922. {
  2923. display: none;
  2924. margin-right: 10px;
  2925. animation: fadeOut 0.75s ease 2s forwards;
  2926. }
  2927. `;
  2928.  
  2929. if (THEME === 'light') {
  2930. gmcFrameStyle.textContent += `
  2931. #gmc-frame
  2932. {
  2933. background-color: #F6F8FA;
  2934. color: #1F2328;
  2935. box-shadow: 0 0 0 1px #D0D7DE, 0 16px 32px rgba(1,4,9,0.2) !important;
  2936. }
  2937.  
  2938. #gmc-frame .section_header_holder
  2939. {
  2940. background-color: #FFFFFF;
  2941. border: 1px solid #D0D7DE;
  2942. }
  2943.  
  2944. #gmc-frame_buttons_holder
  2945. {
  2946. background-color: #FFFFFF;
  2947. box-shadow: 0 0 0 1px #D0D7DE, 0 16px 32px rgba(1,4,9,0.2) !important;
  2948. }
  2949.  
  2950. #gmc-frame input[type="text"],
  2951. #gmc-frame textarea,
  2952. #gmc-frame select
  2953. {
  2954. border: 1px solid #D0D7DE;
  2955. }
  2956.  
  2957. #gmc-frame select
  2958. {
  2959. background-color: #F6F8FA;
  2960. }
  2961.  
  2962. #gmc-frame select:hover
  2963. {
  2964. background-color: #F3F4F6;
  2965. border-color: #1F232826;
  2966. }
  2967.  
  2968. #gmc-frame input[type="text"],
  2969. #gmc-frame textarea
  2970. {
  2971. background-color: #F6F8FA;
  2972. color: #1F2328;
  2973. }
  2974.  
  2975. #gmc-frame input[type="text"]:focus,
  2976. #gmc-frame textarea:focus
  2977. {
  2978. background-color: #FFFFFF;
  2979. }
  2980.  
  2981. #gmc-frame [type=button],
  2982. #gmc-frame .saveclose_buttons
  2983. {
  2984. background-color: #f6f8fa;
  2985. border-color: #1f232826;
  2986. box-shadow: 0 1px 0 rgba(31,35,40,0.04), inset 0 1px 0 rgba(255,255,255,0.25);
  2987. color: #24292f;
  2988. }
  2989.  
  2990. #gmc-frame [type=button]:hover,
  2991. #gmc-frame .saveclose_buttons:hover
  2992. {
  2993. background-color: #f3f4f6;
  2994. border-color: #1f232826;
  2995. }
  2996.  
  2997. #gmc-frame .gmc-checkbox
  2998. {
  2999. border-color: #6E7781;
  3000. }
  3001.  
  3002. #gmc-frame input[type="radio"]
  3003. {
  3004. color: #6E7781;
  3005. }
  3006.  
  3007. #gmc-frame svg
  3008. {
  3009. fill: #000000;
  3010. }
  3011.  
  3012. #gmc-frame .section_header
  3013. {
  3014. border-bottom: 1px solid #D0D7DE;
  3015. }
  3016.  
  3017. ${sectionSelectors}
  3018. {
  3019. border-top: 1px solid #D0D7DE;
  3020. }
  3021.  
  3022. #gmc-frame #gmc-frame_section_3 .config_var:not(:last-child),
  3023. #gmc-frame #gmc-frame_section_4 .config_var:not(:last-child)
  3024. {
  3025. border-bottom: 1px solid #D0D7DE;
  3026. }
  3027.  
  3028. #gmc-frame #gmc-frame_saveBtn
  3029. {
  3030. background-color: #1F883D;
  3031. border-color: rgba(31, 35, 40, 0.15);
  3032. box-shadow: rgba(31, 35, 40, 0.1) 0px 1px 0px;
  3033. color: #FFFFFF;
  3034. }
  3035.  
  3036. #gmc-frame #gmc-frame_saveBtn:hover
  3037. {
  3038. background-color: rgb(26, 127, 55);
  3039. }
  3040.  
  3041. #gmc-frame #gmc-frame_section_4
  3042. {
  3043. border: 1px solid #FF818266;
  3044. }
  3045.  
  3046. #gmc-frame #gmc-frame_section_4 input
  3047. {
  3048. background-color: #F6F8FA;
  3049. border-color: #1F232826;
  3050. box-shadow: 0 1px 0 rgba(31,35,40,0.04), inset 0 1px 0 rgba(255,255,255,0.25);
  3051. color: #CF222E;
  3052. }
  3053.  
  3054. #gmc-frame #gmc-frame_section_4 input:hover
  3055. {
  3056. background-color: #A40E26;
  3057. border-color: #1F232826;
  3058. box-shadow: 0 1px 0 rgba(31,35,40,0.04);
  3059. color: #ffffff;
  3060. }
  3061.  
  3062. #gmc-saved
  3063. {
  3064. color: #1a7f37;
  3065. }
  3066.  
  3067. #gmc-saved svg path
  3068. {
  3069. fill: #1a7f37;
  3070. }
  3071. `;
  3072. } else if (THEME === 'dark') {
  3073. gmcFrameStyle.textContent += `
  3074. #gmc-frame
  3075. {
  3076. background-color: #161B22;
  3077. color: #E6EDF3;
  3078. box-shadow: 0 0 0 1px #30363D, 0 16px 32px #010409 !important;
  3079. }
  3080.  
  3081. #gmc-frame .section_header_holder
  3082. {
  3083. background-color: #0D1117;
  3084. border: 1px solid #30363D;
  3085. }
  3086.  
  3087. #gmc-frame_buttons_holder
  3088. {
  3089. background-color: #161B22;
  3090. box-shadow: 0 0 0 1px #30363D, 0 16px 32px #010409 !important;
  3091. }
  3092.  
  3093. #gmc-frame input[type="text"],
  3094. #gmc-frame textarea,
  3095. #gmc-frame select
  3096. {
  3097. border: 1px solid #5B626C;
  3098. }
  3099.  
  3100. #gmc-frame input[type="text"],
  3101. #gmc-frame textarea
  3102. {
  3103. background-color: #010409;
  3104. color: #FFFFFF;
  3105. }
  3106.  
  3107. #gmc-frame [type=button]:hover,
  3108. #gmc-frame .saveclose_buttons:hover
  3109. {
  3110. background-color: #30363d;
  3111. border-color: #8b949e;
  3112. }
  3113.  
  3114. #gmc-frame .gmc-checkbox
  3115. {
  3116. border-color: #6E7681;
  3117. }
  3118.  
  3119. #gmc-frame input[type="radio"]
  3120. {
  3121. color: #6D7681;
  3122. }
  3123.  
  3124. #gmc-frame input[type="text"]:focus,
  3125. textarea:focus
  3126. {
  3127. background-color: #0D1117;
  3128. }
  3129.  
  3130. #gmc-frame [type=button],
  3131. #gmc-frame .saveclose_buttons
  3132. {
  3133. color: #c9d1d9;
  3134. background-color: #21262d;
  3135. border-color: #f0f6fc1a;
  3136. }
  3137.  
  3138. #gmc-frame svg
  3139. {
  3140. fill: #E6EDF3;
  3141. }
  3142.  
  3143. #gmc-frame .section_header
  3144. {
  3145. border-bottom: 1px solid #30363D;
  3146. }
  3147.  
  3148. ${sectionSelectors}
  3149. {
  3150. border-top: 1px solid #30363D;
  3151. }
  3152.  
  3153. #gmc-frame #gmc-frame_section_3 .config_var:not(:last-child),
  3154. #gmc-frame #gmc-frame_section_4 .config_var:not(:last-child)
  3155. {
  3156. padding-bottom: 1rem;
  3157. border-bottom: 1px solid #30363D;
  3158. }
  3159.  
  3160. #gmc-frame #gmc-frame_saveBtn
  3161. {
  3162. background-color: #238636;
  3163. border-color: #F0F6FC1A;
  3164. box-shadow: 0 0 transparent;
  3165. color: #FFFFFF;
  3166. }
  3167.  
  3168. #gmc-frame #gmc-frame_saveBtn:hover
  3169. {
  3170. background-color: #2EA043;
  3171. border-color: #F0F6FC1A;
  3172. }
  3173.  
  3174. #gmc-frame #gmc-frame_section_4
  3175. {
  3176. border: 1px solid #f8514966;
  3177. }
  3178.  
  3179. #gmc-frame #gmc-frame_section_4 input
  3180. {
  3181. background-color: #21262D;
  3182. border-color: #F0F6FC1A;
  3183. }
  3184.  
  3185. #gmc-frame #gmc-frame_section_4 input
  3186. {
  3187. color: #F85149;
  3188. }
  3189.  
  3190. #gmc-frame #gmc-frame_section_4 input:hover
  3191. {
  3192. background-color: #DA3633;
  3193. border-color: #F85149;
  3194. color: #FFFFFF;
  3195. }
  3196.  
  3197. #gmc-saved
  3198. {
  3199. color: #3FB950;
  3200. }
  3201.  
  3202. #gmc-saved svg path
  3203. {
  3204. fill: #3FB950;
  3205. }
  3206. `;
  3207. }
  3208.  
  3209. document.head.appendChild(gmcFrameStyle);
  3210. }
  3211.  
  3212. function gmcBuildFrame() {
  3213. log(DEBUG, 'gmcBuildFrame()');
  3214.  
  3215. const body = document.querySelector('body');
  3216. const gmcDiv = document.createElement('div');
  3217.  
  3218. gmcDiv.setAttribute('id', 'gmc');
  3219. gmcDiv.classList.add('hidden');
  3220.  
  3221. body.appendChild(gmcDiv);
  3222.  
  3223. const gmcFrameDiv = document.createElement('div');
  3224. gmcFrameDiv.setAttribute('id', 'gmc-frame');
  3225.  
  3226. gmcDiv.appendChild(gmcFrameDiv);
  3227.  
  3228. gmcBuildStyle();
  3229.  
  3230. return gmcFrameDiv;
  3231. }
  3232.  
  3233. function applyCustomizations(refresh = false) {
  3234. log(DEBUG, 'applyCustomizations()');
  3235.  
  3236. log(DEBUG, 'refresh', refresh);
  3237.  
  3238. HEADER = document.querySelector(SELECTORS.header.self);
  3239.  
  3240. if (!HEADER) return 'continue';
  3241.  
  3242. const featurePreviewButton = document.querySelector(SELECTORS.avatar.button);
  3243.  
  3244. if (!featurePreviewButton) {
  3245. logError(`Selector ${SELECTORS.avatar.button} not found`);
  3246. return 'break';
  3247. }
  3248.  
  3249. featurePreviewButton.addEventListener('click', waitForFeaturePreviewButton);
  3250.  
  3251. CONFIG_NAME = {
  3252. 'Off': 'off',
  3253. 'Happy Medium': 'happyMedium',
  3254. 'Old School': 'oldSchool',
  3255. 'Custom': 'custom',
  3256. }[GMC.get('type')];
  3257.  
  3258. log(DEBUG, 'CONFIG_NAME', CONFIG_NAME);
  3259.  
  3260. if (CONFIG_NAME === 'off') return 'break';
  3261.  
  3262. if (CONFIG_NAME === 'custom') configs.custom = generateCustomConfig();
  3263.  
  3264. CONFIG = configs[CONFIG_NAME][THEME];
  3265.  
  3266. log(VERBOSE, 'CONFIG', CONFIG);
  3267.  
  3268. const headerSuccessFlag = 'customizedHeader';
  3269.  
  3270. const foundHeaderSuccessFlag = document.getElementById(headerSuccessFlag);
  3271. log(DEBUG, 'foundHeaderSuccessFlag', foundHeaderSuccessFlag);
  3272.  
  3273. const configurationApplied = HEADER.classList.contains(CONFIG_NAME);
  3274.  
  3275. if (!configurationApplied && (foundHeaderSuccessFlag === null || refresh)) {
  3276. updateSelectors();
  3277.  
  3278. if (refresh) {
  3279. modifyThenObserve(() => {
  3280. document.querySelector(createId(SELECTORS.header.style))?.remove();
  3281. HEADER_STYLE.textContent = '';
  3282.  
  3283. HEADER.classList.remove(OLD_CONFIG_NAME);
  3284. NEW_ELEMENTS.forEach((element) => element.remove());
  3285. });
  3286. }
  3287.  
  3288. if (CONFIG_NAME === 'oldSchool') {
  3289. HEADER_STYLE.textContent += `
  3290. @media (max-width: 767.98px)
  3291. {
  3292. action-menu
  3293. {
  3294. display: none !important;
  3295. }
  3296. }
  3297. `;
  3298. }
  3299.  
  3300. HEADER_UPDATES_COUNT++;
  3301. updateHeader();
  3302.  
  3303. HEADER.setAttribute('id', headerSuccessFlag);
  3304. HEADER.classList.add(CONFIG_NAME);
  3305.  
  3306. OLD_CONFIG_NAME = CONFIG_NAME;
  3307.  
  3308. log(QUIET, 'Complete');
  3309.  
  3310. return 'break';
  3311. } else {
  3312. if (CONFIG.avatar.dropdownIcon) insertAvatarDropdown();
  3313. if (CONFIG.avatar.canCloseSidebar) updateAvatarButton();
  3314.  
  3315. if (CONFIG.repositoryHeader.import) {
  3316. // When starting in a repository tab like Issues, the proper repository header
  3317. // (including Unwatch, Star, and Fork) is not present per GitHub's design.
  3318. // If page title is removed, the page will be missing any location context in the header.
  3319. // To improve this experience, a temporary repository header is created with the
  3320. // page title or breadcrumbs.
  3321. // The proper repository header replaces the temporary one when navigating to the Code tab.
  3322. if (
  3323. !document.querySelector(SELECTORS.repositoryHeader.id)?.hidden &&
  3324. (
  3325. document.querySelector(createId(TEMP_REPOSITORY_HEADER_FLAG)) ||
  3326. !document.querySelector(`.${REPOSITORY_HEADER_SUCCESS_FLAG}`)
  3327. )
  3328. ) {
  3329. const updated = importRepositoryHeader();
  3330.  
  3331. if (updated) {
  3332. HEADER_UPDATES_COUNT++;
  3333. log(QUIET, 'Repository header updated');
  3334. } else {
  3335. IDLE_MUTATION_COUNT++;
  3336. }
  3337.  
  3338. return 'break';
  3339. }
  3340. }
  3341. }
  3342.  
  3343. if (CONFIG.avatar.dropdownIcon) insertAvatarDropdown();
  3344. }
  3345.  
  3346. function startObserving() {
  3347. log(DEBUG, 'startObserving()');
  3348.  
  3349. OBSERVER.observe(
  3350. document.body,
  3351. {
  3352. childList: true,
  3353. subtree: true,
  3354. },
  3355. );
  3356. }
  3357.  
  3358. function modifyThenObserve(callback) {
  3359. log(DEBUG, 'modifyThenObserve()');
  3360. OBSERVER.disconnect();
  3361.  
  3362. callback();
  3363.  
  3364. startObserving();
  3365. }
  3366.  
  3367. function observeAndModify(mutationsList) {
  3368. log(VERBOSE, 'observeAndModify()');
  3369.  
  3370. if (IDLE_MUTATION_COUNT > MAX_IDLE_MUTATIONS) {
  3371. // This is a failsafe to prevent infinite loops
  3372. logError('MAX_IDLE_MUTATIONS exceeded');
  3373. OBSERVER.disconnect();
  3374.  
  3375. return;
  3376. } else if (HEADER_UPDATES_COUNT >= MAX_HEADER_UPDATES) {
  3377. // This is a failsafe to prevent infinite loops
  3378. logError('MAX_HEADER_UPDATES exceeded');
  3379. OBSERVER.disconnect();
  3380.  
  3381. return;
  3382. }
  3383.  
  3384. for (const mutation of mutationsList) {
  3385. // Use header id to determine if updates have already been applied
  3386. if (mutation.type !== 'childList') return;
  3387.  
  3388. log(TRACE, 'mutation', mutation);
  3389.  
  3390. const outcome = applyCustomizations();
  3391.  
  3392. log(DEBUG, 'outcome', outcome);
  3393.  
  3394. if (outcome === 'continue') continue;
  3395. if (outcome === 'break') break;
  3396. }
  3397. }
  3398.  
  3399. const UNICODE_NON_BREAKING_SPACE = '\u00A0';
  3400. const REPOSITORY_HEADER_SUCCESS_FLAG = 'permCustomizedRepositoryHeader';
  3401. const TEMP_REPOSITORY_HEADER_FLAG = 'tempCustomizedRepositoryHeader';
  3402. const REPOSITORY_HEADER_CLASS = 'customizedRepositoryHeader';
  3403. const MAX_IDLE_MUTATIONS = 1000;
  3404. const MAX_HEADER_UPDATES = 100;
  3405.  
  3406. let CONFIG;
  3407. let CONFIG_NAME;
  3408. let OLD_CONFIG_NAME;
  3409. let HEADER;
  3410.  
  3411. let HEADER_STYLE = document.createElement('style');
  3412. let THEME = 'light';
  3413. let NEW_ELEMENTS = [];
  3414. let LEFT_SIDEBAR_PRELOADED = false;
  3415. let RIGHT_SIDEBAR_PRELOADED = false;
  3416. let IDLE_MUTATION_COUNT = 0;
  3417. let HEADER_UPDATES_COUNT = 0;
  3418. let SELECTORS = {
  3419. header: {
  3420. self: 'header.AppHeader',
  3421. actionsDiv: '.AppHeader-actions',
  3422. globalBar: '.AppHeader-globalBar',
  3423. localBar: {
  3424. topDiv: '.AppHeader-localBar',
  3425. underlineNavActions: '.UnderlineNav-actions',
  3426. },
  3427. leftAligned: '.AppHeader-globalBar-start',
  3428. rightAligned: '.AppHeader-globalBar-end',
  3429. style: 'customHeaderStyle',
  3430. },
  3431. logo: {
  3432. topDiv: '.AppHeader-globalBar-start .AppHeader-logo',
  3433. svg: '.AppHeader-logo svg',
  3434. },
  3435. hamburgerButton: '.AppHeader-globalBar-start deferred-side-panel',
  3436. pageTitle: {
  3437. id: 'custom-page-title',
  3438. topDiv: '.AppHeader-context',
  3439. links: '.AppHeader-context a',
  3440. separator: '.AppHeader-context-item-separator',
  3441. },
  3442. search: {
  3443. id: 'search-div',
  3444. topDiv: '.AppHeader-search',
  3445. input: '.search-input',
  3446. button: '[data-target="qbsearch-input.inputButton"]',
  3447. magnifyingGlassIcon: '.AppHeader-search-control label',
  3448. commandPalette: '#AppHeader-commandPalette-button',
  3449. placeholderSpan: '#qb-input-query',
  3450. placeholderDiv: '.AppHeader-search-control .overflow-hidden',
  3451. modal: '[data-target="qbsearch-input.queryBuilderContainer"]',
  3452. },
  3453. copilot: {
  3454. id: 'copilot-div',
  3455. topDiv: '.AppHeader-CopilotChat',
  3456. button: '#copilot-chat-header-button',
  3457. textContent: 'copilot-text-content-span',
  3458. },
  3459. create: {
  3460. id: 'create-div',
  3461. topDiv: '.AppHeader-actions react-partial-anchor',
  3462. button: '#global-create-menu-anchor',
  3463. overlay: '#global-create-menu-overlay',
  3464. plusIcon: '#global-create-menu-anchor .Button-visual.Button-leadingVisual',
  3465. dropdownIcon: '#global-create-menu-anchor .Button-label',
  3466. textContent: 'create-text-content-span',
  3467. },
  3468. issues: {
  3469. id: 'issues',
  3470. textContent: 'issues-text-content-span',
  3471. },
  3472. pullRequests: {
  3473. id: 'pullRequests',
  3474. link: '.AppHeader-globalBar-end .AppHeader-actions a[href="/pulls"]',
  3475. textContent: 'pullRequests-text-content-span',
  3476. },
  3477. marketplace: {
  3478. id: 'marketplace',
  3479. link: '.AppHeader-globalBar-end .AppHeader-actions a[href="/marketplace"]',
  3480. textContent: 'marketplace-text-content-span',
  3481. },
  3482. explore: {
  3483. id: 'explore',
  3484. link: '.AppHeader-globalBar-end .AppHeader-actions a[href="/explore"]',
  3485. textContent: 'explore-text-content-span',
  3486. },
  3487. notifications: {
  3488. id: 'custom-notifications',
  3489. indicator: 'notification-indicator',
  3490. dot: '.AppHeader-button.AppHeader-button--hasIndicator::before',
  3491. textContent: 'textContent-text-content-spa',
  3492. },
  3493. avatar: {
  3494. topDiv: '.AppHeader-user',
  3495. button: '.AppHeader-user button',
  3496. img: '.AppHeader-user button img.avatar',
  3497. svg: 'avatar-dropdown',
  3498. },
  3499. repositoryHeader: {
  3500. id: '#repository-container-header',
  3501. ownerImg: `.${REPOSITORY_HEADER_CLASS} img`,
  3502. name: `.${REPOSITORY_HEADER_CLASS} strong`,
  3503. links: `.${REPOSITORY_HEADER_CLASS} nav[role="navigation"] a`,
  3504. details: '#repository-details-container',
  3505. bottomBorder: `.${REPOSITORY_HEADER_CLASS} .border-bottom.mx-xl-5`,
  3506. },
  3507. sidebars: {
  3508. backdrop: 'dialog.Overlay.SidePanel::backdrop',
  3509. left: {
  3510. modalDialog: '.Overlay--placement-left',
  3511. },
  3512. right: {
  3513. topDiv: '#__primerPortalRoot__',
  3514. wrapper: '#__primerPortalRoot__ > div',
  3515. backdrop: '#__primerPortalRoot__ > div > [data-position-regular="right"]',
  3516. closeButton: '#__primerPortalRoot__ button[aria-label="Close"]',
  3517. divider: 'li[data-component="ActionList.Divider"]',
  3518. },
  3519. },
  3520. };
  3521.  
  3522. HEADER_STYLE.setAttribute('id', SELECTORS.header.style);
  3523.  
  3524. setTheme();
  3525.  
  3526. const oldSchoolColor = '#F0F6FC';
  3527. const oldSchoolHoverColor = '#FFFFFFB3';
  3528. const oldSchoolHoverBackgroundColor = 'transparent';
  3529. let configs = {
  3530. happyMedium: {
  3531. light: {
  3532. backgroundColor: '',
  3533. hamburgerButton: {
  3534. remove: false,
  3535. },
  3536. logo: {
  3537. remove: false,
  3538. color: '',
  3539. customSvg: '',
  3540. },
  3541. pageTitle: {
  3542. remove: false,
  3543. color: '',
  3544. hover: {
  3545. backgroundColor: '',
  3546. color: '',
  3547. },
  3548. },
  3549. search: {
  3550. remove: false,
  3551. backgroundColor: '',
  3552. borderColor: '',
  3553. boxShadow: '',
  3554. alignLeft: false,
  3555. width: 'max',
  3556. margin: {
  3557. left: '',
  3558. right: '',
  3559. },
  3560. magnifyingGlassIcon: {
  3561. remove: false,
  3562. },
  3563. placeholder: {
  3564. text: '',
  3565. color: '',
  3566. },
  3567. rightButton: 'command palette',
  3568. modal: {
  3569. width: '',
  3570. },
  3571. },
  3572. copilot: {
  3573. remove: false,
  3574. border: true,
  3575. tooltip: false,
  3576. alignLeft: false,
  3577. boxShadow: '',
  3578. icon: {
  3579. remove: false,
  3580. color: '',
  3581. },
  3582. text: {
  3583. content: 'Copilot',
  3584. color: '',
  3585. },
  3586. hover: {
  3587. backgroundColor: '',
  3588. color: '',
  3589. },
  3590. },
  3591. divider: {
  3592. remove: true,
  3593. },
  3594. flipCreateInbox: false,
  3595. create: {
  3596. remove: false,
  3597. border: true,
  3598. tooltip: false,
  3599. boxShadow: '',
  3600. hoverBackgroundColor: '',
  3601. plusIcon: {
  3602. remove: false,
  3603. color: '',
  3604. marginRight: '0.25rem',
  3605. hover: {
  3606. color: '',
  3607. },
  3608. },
  3609. text: {
  3610. content: 'Create',
  3611. color: '',
  3612. },
  3613. dropdownIcon: {
  3614. remove: false,
  3615. color: '',
  3616. hover: {
  3617. color: '',
  3618. },
  3619. },
  3620. },
  3621. flipIssuesPullRequests: true,
  3622. issues: {
  3623. remove: false,
  3624. border: true,
  3625. tooltip: false,
  3626. alignLeft: false,
  3627. boxShadow: '',
  3628. icon: {
  3629. remove: false,
  3630. color: '',
  3631. },
  3632. text: {
  3633. content: 'Issues',
  3634. color: '',
  3635. },
  3636. hover: {
  3637. backgroundColor: '',
  3638. color: '',
  3639. },
  3640. },
  3641. pullRequests: {
  3642. remove: false,
  3643. border: true,
  3644. tooltip: false,
  3645. alignLeft: false,
  3646. boxShadow: '',
  3647. icon: {
  3648. remove: false,
  3649. color: '',
  3650. },
  3651. text: {
  3652. content: 'Pull requests',
  3653. color: '',
  3654. },
  3655. hover: {
  3656. backgroundColor: '',
  3657. color: '',
  3658. },
  3659. },
  3660. marketplace: {
  3661. add: false,
  3662. border: false,
  3663. alignLeft: false,
  3664. boxShadow: '',
  3665. icon: {
  3666. remove: false,
  3667. color: '',
  3668. },
  3669. text: {
  3670. content: 'Marketplace',
  3671. color: '',
  3672. },
  3673. hover: {
  3674. backgroundColor: '',
  3675. color: '',
  3676. },
  3677. },
  3678. explore: {
  3679. add: false,
  3680. border: false,
  3681. alignLeft: false,
  3682. boxShadow: '',
  3683. icon: {
  3684. remove: false,
  3685. color: '',
  3686. },
  3687. text: {
  3688. content: 'Explore',
  3689. color: '',
  3690. },
  3691. hover: {
  3692. backgroundColor: '',
  3693. color: '',
  3694. },
  3695. },
  3696. notifications: {
  3697. remove: false,
  3698. border: true,
  3699. tooltip: false,
  3700. boxShadow: '',
  3701. hoverBackgroundColor: '',
  3702. icon: {
  3703. symbol: 'bell', // Accepts 'inbox', 'bell', or ''
  3704. color: '',
  3705. hover: {
  3706. color: '',
  3707. },
  3708. },
  3709. text: {
  3710. content: 'Inbox',
  3711. color: '',
  3712. },
  3713. dot: {
  3714. remove: false,
  3715. boxShadowColor: '',
  3716. color: '',
  3717. displayOverIcon: true,
  3718. },
  3719. },
  3720. avatar: {
  3721. remove: false,
  3722. size: '',
  3723. dropdownIcon: false,
  3724. canCloseSidebar: true,
  3725. },
  3726. globalBar: {
  3727. boxShadowColor: '',
  3728. leftAligned: {
  3729. gap: '',
  3730. },
  3731. rightAligned: {
  3732. gap: '',
  3733. },
  3734. },
  3735. localBar: {
  3736. backgroundColor: '#F6F8FA',
  3737. alignCenter: false,
  3738. boxShadow: {
  3739. consistentColor: true,
  3740. },
  3741. links: {
  3742. color: '',
  3743. },
  3744. },
  3745. sidebars: {
  3746. backdrop: {
  3747. color: 'transparent',
  3748. },
  3749. left: {
  3750. preload: true,
  3751. },
  3752. right: {
  3753. preload: true,
  3754. floatUnderneath: false,
  3755. width: '',
  3756. maxHeight: '',
  3757. },
  3758. },
  3759. repositoryHeader: {
  3760. import: true,
  3761. alignCenter: false,
  3762. removePageTitle: true,
  3763. backgroundColor: '#F6F8FA',
  3764. avatar: {
  3765. remove: false,
  3766. customSvg: '',
  3767. },
  3768. link: {
  3769. color: '',
  3770. hover: {
  3771. backgroundColor: 'transparent',
  3772. color: 'var(--color-accent-fg)',
  3773. textDecoration: 'underline',
  3774. },
  3775. },
  3776. },
  3777. },
  3778. dark: {
  3779. backgroundColor: '',
  3780. hamburgerButton: {
  3781. remove: false,
  3782. },
  3783. logo: {
  3784. remove: false,
  3785. color: '',
  3786. customSvg: '',
  3787. },
  3788. pageTitle: {
  3789. remove: false,
  3790. color: '',
  3791. hover: {
  3792. backgroundColor: '',
  3793. color: '',
  3794. },
  3795. },
  3796. search: {
  3797. remove: false,
  3798. backgroundColor: '',
  3799. borderColor: '',
  3800. boxShadow: '',
  3801. alignLeft: false,
  3802. width: 'max',
  3803. margin: {
  3804. left: '',
  3805. right: '',
  3806. },
  3807. magnifyingGlassIcon: {
  3808. remove: false,
  3809. },
  3810. placeholder: {
  3811. text: '',
  3812. color: '',
  3813. },
  3814. rightButton: 'command palette',
  3815. modal: {
  3816. width: '',
  3817. },
  3818. },
  3819. copilot: {
  3820. remove: false,
  3821. border: true,
  3822. tooltip: false,
  3823. alignLeft: false,
  3824. boxShadow: '',
  3825. icon: {
  3826. remove: false,
  3827. color: '',
  3828. },
  3829. text: {
  3830. content: 'Copilot',
  3831. color: '',
  3832. },
  3833. hover: {
  3834. backgroundColor: '',
  3835. color: '',
  3836. },
  3837. },
  3838. divider: {
  3839. remove: true,
  3840. },
  3841. flipCreateInbox: false,
  3842. create: {
  3843. remove: false,
  3844. border: true,
  3845. tooltip: false,
  3846. boxShadow: '',
  3847. hoverBackgroundColor: '',
  3848. plusIcon: {
  3849. remove: false,
  3850. color: '',
  3851. marginRight: '0.25rem',
  3852. hover: {
  3853. color: '',
  3854. },
  3855. },
  3856. text: {
  3857. content: 'Create',
  3858. color: '',
  3859. },
  3860. dropdownIcon: {
  3861. remove: false,
  3862. color: '',
  3863. hover: {
  3864. color: '',
  3865. },
  3866. },
  3867. },
  3868. flipIssuesPullRequests: true,
  3869. issues: {
  3870. remove: false,
  3871. border: true,
  3872. tooltip: false,
  3873. alignLeft: false,
  3874. boxShadow: '',
  3875. icon: {
  3876. remove: false,
  3877. color: '',
  3878. },
  3879. text: {
  3880. content: 'Issues',
  3881. color: '',
  3882. },
  3883. hover: {
  3884. backgroundColor: '',
  3885. color: '',
  3886. },
  3887. },
  3888. pullRequests: {
  3889. remove: false,
  3890. border: true,
  3891. tooltip: false,
  3892. alignLeft: false,
  3893. boxShadow: '',
  3894. icon: {
  3895. remove: false,
  3896. color: '',
  3897. },
  3898. text: {
  3899. content: 'Pull requests',
  3900. color: '',
  3901. },
  3902. hover: {
  3903. backgroundColor: '',
  3904. color: '',
  3905. },
  3906. },
  3907. marketplace: {
  3908. add: false,
  3909. border: false,
  3910. alignLeft: false,
  3911. boxShadow: '',
  3912. icon: {
  3913. remove: false,
  3914. color: '',
  3915. },
  3916. text: {
  3917. content: 'Marketplace',
  3918. color: '',
  3919. },
  3920. hover: {
  3921. backgroundColor: '',
  3922. color: '',
  3923. },
  3924. },
  3925. explore: {
  3926. add: false,
  3927. border: false,
  3928. alignLeft: false,
  3929. boxShadow: '',
  3930. icon: {
  3931. remove: false,
  3932. color: '',
  3933. },
  3934. text: {
  3935. content: 'Explore',
  3936. color: '',
  3937. },
  3938. hover: {
  3939. backgroundColor: '',
  3940. color: '',
  3941. },
  3942. },
  3943. notifications: {
  3944. remove: false,
  3945. border: true,
  3946. tooltip: false,
  3947. boxShadow: '',
  3948. hoverBackgroundColor: '',
  3949. icon: {
  3950. symbol: 'bell', // Accepts 'inbox', 'bell', or ''
  3951. color: '',
  3952. hover: {
  3953. color: '',
  3954. },
  3955. },
  3956. text: {
  3957. content: 'Inbox',
  3958. color: '',
  3959. },
  3960. dot: {
  3961. remove: false,
  3962. boxShadowColor: '',
  3963. color: '',
  3964. displayOverIcon: true,
  3965. },
  3966. },
  3967. avatar: {
  3968. remove: false,
  3969. size: '',
  3970. dropdownIcon: false,
  3971. canCloseSidebar: true,
  3972. },
  3973. globalBar: {
  3974. boxShadowColor: '',
  3975. leftAligned: {
  3976. gap: '',
  3977. },
  3978. rightAligned: {
  3979. gap: '',
  3980. },
  3981. },
  3982. localBar: {
  3983. backgroundColor: '#02040A',
  3984. alignCenter: false,
  3985. boxShadow: {
  3986. consistentColor: true,
  3987. },
  3988. links: {
  3989. color: '',
  3990. },
  3991. },
  3992. sidebars: {
  3993. backdrop: {
  3994. color: 'transparent',
  3995. },
  3996. left: {
  3997. preload: true,
  3998. },
  3999. right: {
  4000. preload: true,
  4001. floatUnderneath: false,
  4002. width: '',
  4003. maxHeight: '',
  4004. },
  4005. },
  4006. repositoryHeader: {
  4007. import: true,
  4008. alignCenter: false,
  4009. removePageTitle: true,
  4010. backgroundColor: '#02040A',
  4011. avatar: {
  4012. remove: false,
  4013. customSvg: '',
  4014. },
  4015. link: {
  4016. color: '#6AAFF9',
  4017. hover: {
  4018. backgroundColor: 'transparent',
  4019. color: 'var(--color-accent-fg)',
  4020. textDecoration: 'underline',
  4021. },
  4022. },
  4023. },
  4024. },
  4025. },
  4026. oldSchool: {
  4027. light: {
  4028. backgroundColor: '#161C20',
  4029. hamburgerButton: {
  4030. remove: true,
  4031. },
  4032. logo: {
  4033. remove: false,
  4034. color: '#e6edf3',
  4035. customSvg: '',
  4036. },
  4037. pageTitle: {
  4038. remove: true,
  4039. color: oldSchoolColor,
  4040. hover: {
  4041. backgroundColor: oldSchoolHoverBackgroundColor,
  4042. color: oldSchoolHoverColor,
  4043. },
  4044. },
  4045. search: {
  4046. remove: false,
  4047. backgroundColor: '#494D54',
  4048. borderColor: '#30363d',
  4049. boxShadow: 'none',
  4050. alignLeft: true,
  4051. width: 'calc(var(--feed-sidebar) - 67px)',
  4052. margin: {
  4053. left: '',
  4054. right: '',
  4055. },
  4056. magnifyingGlassIcon: {
  4057. remove: true,
  4058. },
  4059. placeholder: {
  4060. text: 'Search or jump to...',
  4061. color: '#B3B3B5',
  4062. },
  4063. rightButton: 'slash key',
  4064. modal: {
  4065. width: '450px',
  4066. },
  4067. },
  4068. copilot: {
  4069. remove: true,
  4070. border: false,
  4071. tooltip: false,
  4072. alignLeft: true,
  4073. boxShadow: 'none',
  4074. icon: {
  4075. remove: false,
  4076. color: '',
  4077. },
  4078. text: {
  4079. content: 'Copilot',
  4080. color: oldSchoolColor,
  4081. },
  4082. hover: {
  4083. backgroundColor: oldSchoolHoverBackgroundColor,
  4084. color: oldSchoolHoverColor,
  4085. },
  4086. },
  4087. divider: {
  4088. remove: true,
  4089. },
  4090. flipCreateInbox: true,
  4091. create: {
  4092. remove: false,
  4093. border: false,
  4094. tooltip: false,
  4095. boxShadow: 'none',
  4096. hoverBackgroundColor: oldSchoolHoverBackgroundColor,
  4097. plusIcon: {
  4098. remove: false,
  4099. color: oldSchoolColor,
  4100. marginRight: '0px',
  4101. hover: {
  4102. color: oldSchoolHoverColor,
  4103. },
  4104. },
  4105. text: {
  4106. content: '',
  4107. color: '',
  4108. },
  4109. dropdownIcon: {
  4110. remove: false,
  4111. color: oldSchoolColor,
  4112. hover: {
  4113. color: oldSchoolHoverColor,
  4114. },
  4115. },
  4116. },
  4117. flipIssuesPullRequests: true,
  4118. issues: {
  4119. remove: false,
  4120. border: false,
  4121. tooltip: false,
  4122. alignLeft: true,
  4123. boxShadow: 'none',
  4124. icon: {
  4125. remove: true,
  4126. color: '',
  4127. },
  4128. text: {
  4129. content: 'Issues',
  4130. color: oldSchoolColor,
  4131. },
  4132. hover: {
  4133. backgroundColor: oldSchoolHoverBackgroundColor,
  4134. color: oldSchoolHoverColor,
  4135. },
  4136. },
  4137. pullRequests: {
  4138. remove: false,
  4139. border: false,
  4140. tooltip: false,
  4141. alignLeft: true,
  4142. boxShadow: 'none',
  4143. icon: {
  4144. remove: true,
  4145. color: '',
  4146. },
  4147. text: {
  4148. content: 'Pull requests',
  4149. color: oldSchoolColor,
  4150. },
  4151. hover: {
  4152. backgroundColor: oldSchoolHoverBackgroundColor,
  4153. color: oldSchoolHoverColor,
  4154. },
  4155. },
  4156. marketplace: {
  4157. add: true,
  4158. border: false,
  4159. tooltip: false,
  4160. alignLeft: true,
  4161. boxShadow: 'none',
  4162. icon: {
  4163. remove: true,
  4164. color: '',
  4165. },
  4166. text: {
  4167. content: 'Marketplace',
  4168. color: oldSchoolColor,
  4169. },
  4170. hover: {
  4171. backgroundColor: oldSchoolHoverBackgroundColor,
  4172. color: oldSchoolHoverColor,
  4173. },
  4174. },
  4175. explore: {
  4176. add: true,
  4177. border: false,
  4178. tooltip: false,
  4179. alignLeft: true,
  4180. boxShadow: 'none',
  4181. icon: {
  4182. remove: true,
  4183. color: '',
  4184. },
  4185. text: {
  4186. content: 'Explore',
  4187. color: oldSchoolColor,
  4188. },
  4189. hover: {
  4190. backgroundColor: oldSchoolHoverBackgroundColor,
  4191. color: oldSchoolHoverColor,
  4192. },
  4193. },
  4194. notifications: {
  4195. remove: false,
  4196. border: false,
  4197. tooltip: false,
  4198. boxShadow: 'none',
  4199. hoverBackgroundColor: oldSchoolHoverBackgroundColor,
  4200. icon: {
  4201. symbol: 'bell',
  4202. color: oldSchoolColor,
  4203. hover: {
  4204. color: oldSchoolHoverColor,
  4205. },
  4206. },
  4207. text: {
  4208. content: '',
  4209. color: '',
  4210. },
  4211. dot: {
  4212. remove: false,
  4213. boxShadowColor: '#161C20',
  4214. color: '#2f81f7',
  4215. displayOverIcon: true,
  4216. },
  4217. },
  4218. avatar: {
  4219. remove: false,
  4220. size: '24px',
  4221. dropdownIcon: true,
  4222. canCloseSidebar: true,
  4223. },
  4224. globalBar: {
  4225. boxShadowColor: '#21262D',
  4226. leftAligned: {
  4227. gap: '0.75rem',
  4228. },
  4229. rightAligned: {
  4230. gap: '2px',
  4231. },
  4232. },
  4233. localBar: {
  4234. backgroundColor: '#FAFBFD',
  4235. alignCenter: true,
  4236. boxShadow: {
  4237. consistentColor: true,
  4238. },
  4239. links: {
  4240. color: '',
  4241. },
  4242. },
  4243. sidebars: {
  4244. backdrop: {
  4245. color: oldSchoolHoverBackgroundColor,
  4246. },
  4247. left: {
  4248. preload: true,
  4249. },
  4250. right: {
  4251. preload: true,
  4252. floatUnderneath: true,
  4253. width: '',
  4254. maxHeight: '50vh',
  4255. },
  4256. },
  4257. repositoryHeader: {
  4258. import: true,
  4259. alignCenter: true,
  4260. removePageTitle: true,
  4261. backgroundColor: '#FAFBFD',
  4262. avatar: {
  4263. remove: false,
  4264. 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>',
  4265. },
  4266. link: {
  4267. color: '#2F81F7',
  4268. hover: {
  4269. backgroundColor: 'transparent',
  4270. color: '#0969da',
  4271. textDecoration: 'underline',
  4272. },
  4273. },
  4274. },
  4275. },
  4276. dark: {
  4277. backgroundColor: '#161C20',
  4278. hamburgerButton: {
  4279. remove: true,
  4280. },
  4281. logo: {
  4282. remove: false,
  4283. color: '#e6edf3',
  4284. customSvg: '',
  4285. },
  4286. pageTitle: {
  4287. remove: true,
  4288. color: oldSchoolColor,
  4289. hover: {
  4290. backgroundColor: oldSchoolHoverBackgroundColor,
  4291. color: oldSchoolHoverColor,
  4292. },
  4293. },
  4294. search: {
  4295. remove: false,
  4296. backgroundColor: '#0E1217',
  4297. borderColor: '#30363d',
  4298. boxShadow: 'none',
  4299. alignLeft: true,
  4300. width: 'calc(var(--feed-sidebar) - 67px)',
  4301. margin: {
  4302. left: '',
  4303. right: '',
  4304. },
  4305. magnifyingGlassIcon: {
  4306. remove: true,
  4307. },
  4308. placeholder: {
  4309. text: 'Search or jump to...',
  4310. color: '#B3B3B5',
  4311. },
  4312. rightButton: 'slash key',
  4313. modal: {
  4314. width: '450px',
  4315. },
  4316. },
  4317. copilot: {
  4318. remove: true,
  4319. border: false,
  4320. tooltip: false,
  4321. alignLeft: true,
  4322. boxShadow: 'none',
  4323. icon: {
  4324. remove: false,
  4325. color: '',
  4326. },
  4327. text: {
  4328. content: 'Copilot',
  4329. color: oldSchoolColor,
  4330. },
  4331. hover: {
  4332. backgroundColor: oldSchoolHoverBackgroundColor,
  4333. color: oldSchoolHoverColor,
  4334. },
  4335. },
  4336. divider: {
  4337. remove: true,
  4338. },
  4339. flipCreateInbox: true,
  4340. create: {
  4341. remove: false,
  4342. border: false,
  4343. tooltip: false,
  4344. boxShadow: 'none',
  4345. hoverBackgroundColor: oldSchoolHoverBackgroundColor,
  4346. plusIcon: {
  4347. remove: false,
  4348. color: oldSchoolColor,
  4349. marginRight: '0px',
  4350. hover: {
  4351. color: oldSchoolHoverColor,
  4352. },
  4353. },
  4354. text: {
  4355. content: '',
  4356. color: '',
  4357. },
  4358. dropdownIcon: {
  4359. remove: false,
  4360. color: oldSchoolColor,
  4361. hover: {
  4362. color: oldSchoolHoverColor,
  4363. },
  4364. },
  4365. },
  4366. flipIssuesPullRequests: true,
  4367. issues: {
  4368. remove: false,
  4369. border: false,
  4370. tooltip: false,
  4371. alignLeft: true,
  4372. boxShadow: 'none',
  4373. icon: {
  4374. remove: true,
  4375. color: '',
  4376. },
  4377. text: {
  4378. content: 'Issues',
  4379. color: oldSchoolColor,
  4380. },
  4381. hover: {
  4382. backgroundColor: oldSchoolHoverBackgroundColor,
  4383. color: oldSchoolHoverColor,
  4384. },
  4385. },
  4386. pullRequests: {
  4387. remove: false,
  4388. border: false,
  4389. tooltip: false,
  4390. alignLeft: true,
  4391. boxShadow: 'none',
  4392. icon: {
  4393. remove: true,
  4394. color: '',
  4395. },
  4396. text: {
  4397. content: 'Pull requests',
  4398. color: oldSchoolColor,
  4399. },
  4400. hover: {
  4401. backgroundColor: oldSchoolHoverBackgroundColor,
  4402. color: oldSchoolHoverColor,
  4403. },
  4404. },
  4405. marketplace: {
  4406. add: true,
  4407. border: false,
  4408. alignLeft: true,
  4409. boxShadow: 'none',
  4410. icon: {
  4411. remove: true,
  4412. color: '',
  4413. },
  4414. text: {
  4415. content: 'Marketplace',
  4416. color: oldSchoolColor,
  4417. },
  4418. hover: {
  4419. backgroundColor: oldSchoolHoverBackgroundColor,
  4420. color: oldSchoolHoverColor,
  4421. },
  4422. },
  4423. explore: {
  4424. add: true,
  4425. border: false,
  4426. alignLeft: true,
  4427. boxShadow: 'none',
  4428. icon: {
  4429. remove: true,
  4430. color: '',
  4431. },
  4432. text: {
  4433. content: 'Explore',
  4434. color: oldSchoolColor,
  4435. },
  4436. hover: {
  4437. backgroundColor: oldSchoolHoverBackgroundColor,
  4438. color: oldSchoolHoverColor,
  4439. },
  4440. },
  4441. notifications: {
  4442. remove: false,
  4443. border: false,
  4444. tooltip: false,
  4445. boxShadow: 'none',
  4446. hoverBackgroundColor: oldSchoolHoverBackgroundColor,
  4447. icon: {
  4448. symbol: 'bell',
  4449. color: oldSchoolColor,
  4450. hover: {
  4451. color: oldSchoolHoverColor,
  4452. },
  4453. },
  4454. text: {
  4455. content: '',
  4456. color: '',
  4457. },
  4458. dot: {
  4459. remove: false,
  4460. boxShadowColor: '#161C20',
  4461. color: '#2f81f7',
  4462. displayOverIcon: true,
  4463. },
  4464. },
  4465. avatar: {
  4466. remove: false,
  4467. size: '24px',
  4468. dropdownIcon: true,
  4469. canCloseSidebar: true,
  4470. },
  4471. globalBar: {
  4472. boxShadowColor: '#21262D',
  4473. leftAligned: {
  4474. gap: '0.75rem',
  4475. },
  4476. rightAligned: {
  4477. gap: '2px',
  4478. },
  4479. },
  4480. localBar: {
  4481. backgroundColor: '#0D1117',
  4482. alignCenter: true,
  4483. boxShadow: {
  4484. consistentColor: true,
  4485. },
  4486. links: {
  4487. color: '#e6edf3',
  4488. },
  4489. },
  4490. sidebars: {
  4491. backdrop: {
  4492. color: oldSchoolHoverBackgroundColor,
  4493. },
  4494. left: {
  4495. preload: true,
  4496. },
  4497. right: {
  4498. preload: true,
  4499. floatUnderneath: true,
  4500. width: '',
  4501. maxHeight: '50vh',
  4502. },
  4503. },
  4504. repositoryHeader: {
  4505. import: true,
  4506. alignCenter: true,
  4507. removePageTitle: true,
  4508. backgroundColor: '#0D1116',
  4509. avatar: {
  4510. remove: false,
  4511. 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>',
  4512. },
  4513. link: {
  4514. color: '#58A6FF',
  4515. hover: {
  4516. backgroundColor: 'transparent',
  4517. color: '#2F81F7',
  4518. textDecoration: 'underline',
  4519. },
  4520. },
  4521. },
  4522. },
  4523. },
  4524. };
  4525.  
  4526. // For testing purposes
  4527. // if (!checkConfigConsistency(configs)) return;
  4528.  
  4529. let OBSERVER = new MutationObserver(observeAndModify);
  4530.  
  4531. let GMC = new GM_config({
  4532. id: 'gmc-frame',
  4533. title: `
  4534. Custom Global Navigation
  4535. <small>
  4536. <a
  4537. href="https://github.com/blakegearin/github-custom-global-navigation"
  4538. target="_blank"
  4539. >
  4540. source
  4541. </a>
  4542. </small>
  4543. `,
  4544. events: {
  4545. init: gmcInitialized,
  4546. open: gmcOpened,
  4547. save: gmcSaved,
  4548. close: gmcClosed,
  4549. },
  4550. frame: gmcBuildFrame(),
  4551. fields: {
  4552. type: {
  4553. section: [
  4554. `
  4555. Configuration Type
  4556. <small>
  4557. <a
  4558. href="https://github.com/blakegearin/github-custom-global-navigation#configurations"
  4559. target="_blank"
  4560. >
  4561. learn more
  4562. </a>
  4563. </small>
  4564. `,
  4565. ],
  4566. type: 'radio',
  4567. options: [
  4568. 'Off',
  4569. 'Happy Medium',
  4570. 'Old School',
  4571. 'Custom',
  4572. ],
  4573. default: 'Old School',
  4574. },
  4575. light_backgroundColor: {
  4576. label: 'Background color',
  4577. section: [
  4578. 'Custom Light',
  4579. ],
  4580. type: 'text',
  4581. default: '',
  4582. },
  4583. light_hamburgerButton_remove: {
  4584. label: '<h3>Hamburger button</h3><div class="gmc-label">Remove</div>',
  4585. type: 'checkbox',
  4586. default: false,
  4587. },
  4588. light_logo_remove: {
  4589. label: '<h3>Logo</h3><div class="gmc-label">Remove</div>',
  4590. type: 'checkbox',
  4591. default: false,
  4592. },
  4593. light_logo_color: {
  4594. label: 'Color',
  4595. type: 'text',
  4596. default: '',
  4597. },
  4598. light_logo_customSvg: {
  4599. label: 'Custom SVG (URL or text)',
  4600. type: 'textarea',
  4601. default: '',
  4602. },
  4603. light_pageTitle_remove: {
  4604. label: '<h3>Page title</h3><div class="gmc-label">Remove</div>',
  4605. type: 'checkbox',
  4606. default: false,
  4607. },
  4608. light_pageTitle_color: {
  4609. label: 'Color',
  4610. type: 'text',
  4611. default: '',
  4612. },
  4613. light_pageTitle_hover_backgroundColor: {
  4614. label: 'Hover background color',
  4615. type: 'text',
  4616. default: '',
  4617. },
  4618. light_pageTitle_hover_color: {
  4619. label: 'Hover color',
  4620. type: 'text',
  4621. default: '',
  4622. },
  4623. light_search_remove: {
  4624. label: '<h3>Search</h3><div class="gmc-label">Remove</div>',
  4625. type: 'checkbox',
  4626. default: false,
  4627. },
  4628. light_search_backgroundColor: {
  4629. label: 'Background color',
  4630. type: 'text',
  4631. default: '',
  4632. },
  4633. light_search_borderColor: {
  4634. label: 'Border color',
  4635. type: 'text',
  4636. default: '',
  4637. },
  4638. light_search_boxShadow: {
  4639. label: 'Box shadow',
  4640. type: 'text',
  4641. default: '',
  4642. },
  4643. light_search_alignLeft: {
  4644. label: 'Left aligned',
  4645. type: 'checkbox',
  4646. default: false,
  4647. },
  4648. light_search_width: {
  4649. label: 'Width',
  4650. type: 'text',
  4651. default: '',
  4652. },
  4653. light_search_margin_left: {
  4654. label: 'Margin left',
  4655. type: 'text',
  4656. default: '',
  4657. },
  4658. light_search_margin_right: {
  4659. label: 'Margin right',
  4660. type: 'text',
  4661. default: '',
  4662. },
  4663. light_search_magnifyingGlassIcon_remove: {
  4664. label: 'Magnifying glass icon remove',
  4665. type: 'checkbox',
  4666. default: false,
  4667. },
  4668. light_search_placeholder_text: {
  4669. label: 'Placeholder text',
  4670. type: 'text',
  4671. default: '',
  4672. },
  4673. light_search_placeholder_color: {
  4674. label: 'Placeholder color',
  4675. type: 'text',
  4676. default: '',
  4677. },
  4678. light_search_rightButton: {
  4679. label: 'Right button',
  4680. type: 'select',
  4681. options: [
  4682. 'none',
  4683. 'command palette',
  4684. 'slash key',
  4685. ],
  4686. default: 'command palette',
  4687. },
  4688. light_search_modal_width: {
  4689. label: 'Modal width',
  4690. type: 'text',
  4691. default: '',
  4692. },
  4693. light_divider_remove: {
  4694. label: '<h3>Divider</h3><div class="gmc-label">Remove</div>',
  4695. type: 'checkbox',
  4696. default: false,
  4697. },
  4698. light_flipCreateInbox: {
  4699. label: 'Flip the order of Create and Notifications',
  4700. type: 'checkbox',
  4701. default: false,
  4702. },
  4703. light_create_remove: {
  4704. label: '<h3>Create button</h3><div class="gmc-label">Remove</div>',
  4705. type: 'checkbox',
  4706. default: false,
  4707. },
  4708. light_create_border: {
  4709. label: 'Border',
  4710. type: 'checkbox',
  4711. default: true,
  4712. },
  4713. light_create_tooltip: {
  4714. label: 'Tooltip',
  4715. type: 'checkbox',
  4716. default: true,
  4717. },
  4718. light_create_boxShadow: {
  4719. label: 'Box shadow',
  4720. type: 'text',
  4721. default: '',
  4722. },
  4723. light_create_hoverBackgroundColor: {
  4724. label: 'Hover background color',
  4725. type: 'text',
  4726. default: '',
  4727. },
  4728. light_create_plusIcon_remove: {
  4729. label: 'Plus icon remove',
  4730. type: 'checkbox',
  4731. default: false,
  4732. },
  4733. light_create_plusIcon_color: {
  4734. label: 'Plus icon color',
  4735. type: 'text',
  4736. default: '',
  4737. },
  4738. light_create_plusIcon_marginRight: {
  4739. label: 'Plus icon margin right',
  4740. type: 'text',
  4741. default: '',
  4742. },
  4743. light_create_plusIcon_hover_color: {
  4744. label: 'Plus icon hover color',
  4745. type: 'text',
  4746. default: '',
  4747. },
  4748. light_create_text_content: {
  4749. label: 'Text content',
  4750. type: 'text',
  4751. default: '',
  4752. },
  4753. light_create_text_color: {
  4754. label: 'Text color',
  4755. type: 'text',
  4756. default: '',
  4757. },
  4758. light_create_dropdownIcon_remove: {
  4759. label: 'Dropdown icon remove',
  4760. type: 'checkbox',
  4761. default: false,
  4762. },
  4763. light_create_dropdownIcon_color: {
  4764. label: 'Dropdown icon color',
  4765. type: 'text',
  4766. default: '',
  4767. },
  4768. light_create_dropdownIcon_hover_color: {
  4769. label: 'Dropdown icon hover color',
  4770. type: 'text',
  4771. default: '',
  4772. },
  4773. light_flipIssuesPullRequests: {
  4774. label: 'Flip the order of Issues and Pull requests',
  4775. type: 'checkbox',
  4776. default: false,
  4777. },
  4778. light_issues_remove: {
  4779. label: '<h3>Issues button</h3><div class="gmc-label">Remove</div>',
  4780. type: 'checkbox',
  4781. default: false,
  4782. },
  4783. light_issues_border: {
  4784. label: 'Border',
  4785. type: 'checkbox',
  4786. default: true,
  4787. },
  4788. light_issues_tooltip: {
  4789. label: 'Tooltip',
  4790. type: 'checkbox',
  4791. default: true,
  4792. },
  4793. light_issues_alignLeft: {
  4794. label: 'Align left',
  4795. type: 'checkbox',
  4796. default: false,
  4797. },
  4798. light_issues_boxShadow: {
  4799. label: 'Box shadow',
  4800. type: 'text',
  4801. default: '',
  4802. },
  4803. light_issues_icon_remove: {
  4804. label: 'Icon remove',
  4805. type: 'checkbox',
  4806. default: false,
  4807. },
  4808. light_issues_icon_color: {
  4809. label: 'Icon color',
  4810. type: 'text',
  4811. default: '',
  4812. },
  4813. light_issues_text_content: {
  4814. label: 'Text content',
  4815. type: 'text',
  4816. default: '',
  4817. },
  4818. light_issues_text_color: {
  4819. label: 'Text color',
  4820. type: 'text',
  4821. default: '',
  4822. },
  4823. light_issues_hover_backgroundColor: {
  4824. label: 'Hover background color',
  4825. type: 'text',
  4826. default: '',
  4827. },
  4828. light_issues_hover_color: {
  4829. label: 'Hover color',
  4830. type: 'text',
  4831. default: '',
  4832. },
  4833. light_pullRequests_remove: {
  4834. label: '<h3>Pull requests button</h3><div class="gmc-label">Remove</div>',
  4835. type: 'checkbox',
  4836. default: false,
  4837. },
  4838. light_pullRequests_border: {
  4839. label: 'Border',
  4840. type: 'checkbox',
  4841. default: true,
  4842. },
  4843. light_pullRequests_tooltip: {
  4844. label: 'Tooltip',
  4845. type: 'checkbox',
  4846. default: true,
  4847. },
  4848. light_pullRequests_alignLeft: {
  4849. label: 'Align left',
  4850. type: 'checkbox',
  4851. default: false,
  4852. },
  4853. light_pullRequests_boxShadow: {
  4854. label: 'Box shadow',
  4855. type: 'text',
  4856. default: '',
  4857. },
  4858. light_pullRequests_icon_remove: {
  4859. label: 'Icon remove',
  4860. type: 'checkbox',
  4861. default: false,
  4862. },
  4863. light_pullRequests_icon_color: {
  4864. label: 'Icon color',
  4865. type: 'text',
  4866. default: '',
  4867. },
  4868. light_pullRequests_text_content: {
  4869. label: 'Text content',
  4870. type: 'text',
  4871. default: '',
  4872. },
  4873. light_pullRequests_text_color: {
  4874. label: 'Text color',
  4875. type: 'text',
  4876. default: '',
  4877. },
  4878. light_pullRequests_hover_backgroundColor: {
  4879. label: 'Hover background color',
  4880. type: 'text',
  4881. default: '',
  4882. },
  4883. light_pullRequests_hover_color: {
  4884. label: 'Hover color',
  4885. type: 'text',
  4886. default: '',
  4887. },
  4888. light_marketplace_add: {
  4889. label: '<h3>Marketplace</h3><div class="gmc-label">Add</div>',
  4890. type: 'checkbox',
  4891. default: false,
  4892. },
  4893. light_marketplace_border: {
  4894. label: 'Border',
  4895. type: 'checkbox',
  4896. default: true,
  4897. },
  4898. light_marketplace_alignLeft: {
  4899. label: 'Align left',
  4900. type: 'checkbox',
  4901. default: false,
  4902. },
  4903. light_marketplace_boxShadow: {
  4904. label: 'Box shadow',
  4905. type: 'text',
  4906. default: '',
  4907. },
  4908. light_marketplace_icon_remove: {
  4909. label: 'Icon remove',
  4910. type: 'checkbox',
  4911. default: false,
  4912. },
  4913. light_marketplace_icon_color: {
  4914. label: 'Icon color',
  4915. type: 'text',
  4916. default: '',
  4917. },
  4918. light_marketplace_text_content: {
  4919. label: 'Text content',
  4920. type: 'text',
  4921. default: '',
  4922. },
  4923. light_marketplace_text_color: {
  4924. label: 'Text color',
  4925. type: 'text',
  4926. default: '',
  4927. },
  4928. light_marketplace_hover_backgroundColor: {
  4929. label: 'Hover background color',
  4930. type: 'text',
  4931. default: '',
  4932. },
  4933. light_marketplace_hover_color: {
  4934. label: 'Hover color',
  4935. type: 'text',
  4936. default: '',
  4937. },
  4938. light_explore_add: {
  4939. label: '<h3>Explore</h3><div class="gmc-label">Add</div>',
  4940. type: 'checkbox',
  4941. default: false,
  4942. },
  4943. light_explore_border: {
  4944. label: 'Border',
  4945. type: 'checkbox',
  4946. default: true,
  4947. },
  4948. light_explore_alignLeft: {
  4949. label: 'Align left',
  4950. type: 'checkbox',
  4951. default: false,
  4952. },
  4953. light_explore_boxShadow: {
  4954. label: 'Box shadow',
  4955. type: 'text',
  4956. default: '',
  4957. },
  4958. light_explore_icon_remove: {
  4959. label: 'Icon remove',
  4960. type: 'checkbox',
  4961. default: false,
  4962. },
  4963. light_explore_icon_color: {
  4964. label: 'Icon color',
  4965. type: 'text',
  4966. default: '',
  4967. },
  4968. light_explore_text_content: {
  4969. label: 'Text content',
  4970. type: 'text',
  4971. default: '',
  4972. },
  4973. light_explore_text_color: {
  4974. label: 'Text color',
  4975. type: 'text',
  4976. default: '',
  4977. },
  4978. light_explore_hover_backgroundColor: {
  4979. label: 'Hover background color',
  4980. type: 'text',
  4981. default: '',
  4982. },
  4983. light_explore_hover_color: {
  4984. label: 'Hover color',
  4985. type: 'text',
  4986. default: '',
  4987. },
  4988. light_notifications_remove: {
  4989. label: '<h3>Notifications button</h3><div class="gmc-label">Remove</div>',
  4990. type: 'checkbox',
  4991. default: false,
  4992. },
  4993. light_notifications_border: {
  4994. label: 'Border',
  4995. type: 'checkbox',
  4996. default: true,
  4997. },
  4998. light_notifications_tooltip: {
  4999. label: 'Tooltip',
  5000. type: 'checkbox',
  5001. default: true,
  5002. },
  5003. light_notifications_boxShadow: {
  5004. label: 'Box shadow',
  5005. type: 'text',
  5006. default: '',
  5007. },
  5008. light_notifications_hoverBackgroundColor: {
  5009. label: 'Hover background color',
  5010. type: 'text',
  5011. default: '',
  5012. },
  5013. light_notifications_icon_symbol: {
  5014. label: 'Icon symbol',
  5015. type: 'select',
  5016. options: [
  5017. 'none',
  5018. 'inbox',
  5019. 'bell',
  5020. ],
  5021. default: 'inbox',
  5022. },
  5023. light_notifications_icon_color: {
  5024. label: 'Icon color',
  5025. type: 'text',
  5026. default: '',
  5027. },
  5028. light_notifications_icon_hover_color: {
  5029. label: 'Icon hover color',
  5030. type: 'text',
  5031. default: '',
  5032. },
  5033. light_notifications_text_content: {
  5034. label: 'Text content',
  5035. type: 'text',
  5036. default: '',
  5037. },
  5038. light_notifications_text_color: {
  5039. label: 'Text color',
  5040. type: 'text',
  5041. default: '',
  5042. },
  5043. light_notifications_dot_remove: {
  5044. label: 'Dot remove',
  5045. type: 'checkbox',
  5046. default: false,
  5047. },
  5048. light_notifications_dot_boxShadowColor: {
  5049. label: 'Dot hover color',
  5050. type: 'text',
  5051. default: '',
  5052. },
  5053. light_notifications_dot_color: {
  5054. label: 'Dot color',
  5055. type: 'text',
  5056. default: '',
  5057. },
  5058. light_notifications_dot_displayOverIcon: {
  5059. label: 'Dot display over icon',
  5060. type: 'checkbox',
  5061. default: false,
  5062. },
  5063. light_avatar_remove: {
  5064. label: '<h3>Avatar</h3><div class="gmc-label">Remove</div>',
  5065. type: 'checkbox',
  5066. default: false,
  5067. },
  5068. light_avatar_size: {
  5069. label: 'Size',
  5070. type: 'text',
  5071. default: '',
  5072. },
  5073. light_avatar_dropdownIcon: {
  5074. label: 'Dropdown icon',
  5075. type: 'checkbox',
  5076. default: false,
  5077. },
  5078. light_avatar_canCloseSidebar: {
  5079. label: 'Can close sidebar',
  5080. type: 'checkbox',
  5081. default: false,
  5082. },
  5083. light_globalBar_boxShadowColor: {
  5084. label: '<h3>Global bar</h3><div class="gmc-label">Box shadow color</div>',
  5085. type: 'text',
  5086. default: '',
  5087. },
  5088. light_globalBar_leftAligned_gap: {
  5089. label: 'Left aligned gap',
  5090. type: 'text',
  5091. default: '',
  5092. },
  5093. light_globalBar_rightAligned_gap: {
  5094. label: 'Right aligned gap',
  5095. type: 'text',
  5096. default: '',
  5097. },
  5098. light_localBar_backgroundColor: {
  5099. label: '<h3>Local bar</h3><div class="gmc-label">Background color</div>',
  5100. type: 'text',
  5101. default: '',
  5102. },
  5103. light_localBar_alignCenter: {
  5104. label: 'Align center',
  5105. type: 'checkbox',
  5106. default: false,
  5107. },
  5108. light_localBar_boxShadow_consistentColor: {
  5109. label: 'Box shadow consistent color',
  5110. type: 'checkbox',
  5111. default: false,
  5112. },
  5113. light_localBar_links_color: {
  5114. label: 'Links color',
  5115. type: 'text',
  5116. default: '',
  5117. },
  5118. light_sidebars_backdrop_color: {
  5119. label: '<h3>Sidebars</h3><div class="gmc-label">Backdrop color</div>',
  5120. type: 'text',
  5121. default: '',
  5122. },
  5123. light_sidebars_left_preload: {
  5124. label: 'Left preload',
  5125. type: 'checkbox',
  5126. default: false,
  5127. },
  5128. light_sidebars_right_preload: {
  5129. label: 'Right preload',
  5130. type: 'checkbox',
  5131. default: false,
  5132. },
  5133. light_sidebars_right_floatUnderneath: {
  5134. label: 'Right float underneath',
  5135. type: 'checkbox',
  5136. default: false,
  5137. },
  5138. light_sidebars_right_width: {
  5139. label: 'Right width',
  5140. type: 'text',
  5141. default: '',
  5142. },
  5143. light_sidebars_right_maxHeight: {
  5144. label: 'Right max height',
  5145. type: 'text',
  5146. default: '',
  5147. },
  5148. light_repositoryHeader_import: {
  5149. label: '<h3>Repository header</h3><div class="gmc-label">Import</div>',
  5150. type: 'checkbox',
  5151. default: false,
  5152. },
  5153. light_repositoryHeader_alignCenter: {
  5154. label: 'Align center',
  5155. type: 'checkbox',
  5156. default: false,
  5157. },
  5158. light_repositoryHeader_removePageTitle: {
  5159. label: 'Remove page title',
  5160. type: 'checkbox',
  5161. default: false,
  5162. },
  5163. light_repositoryHeader_backgroundColor: {
  5164. label: 'Background color',
  5165. type: 'text',
  5166. default: '',
  5167. },
  5168. light_repositoryHeader_avatar_remove: {
  5169. label: 'Avatar remove',
  5170. type: 'checkbox',
  5171. default: false,
  5172. },
  5173. light_repositoryHeader_avatar_customSvg: {
  5174. label: 'Custom SVG (URL or text)',
  5175. type: 'textarea',
  5176. default: '',
  5177. },
  5178. light_repositoryHeader_link_color: {
  5179. label: 'Link color',
  5180. type: 'text',
  5181. default: '',
  5182. },
  5183. light_repositoryHeader_link_hover_backgroundColor: {
  5184. label: 'Link hover background color',
  5185. type: 'text',
  5186. default: '',
  5187. },
  5188. light_repositoryHeader_link_hover_color: {
  5189. label: 'Link hover color',
  5190. type: 'text',
  5191. default: '',
  5192. },
  5193. light_repositoryHeader_link_hover_textDecoration: {
  5194. label: 'Link hover text decoration',
  5195. type: 'text',
  5196. default: '',
  5197. },
  5198. dark_backgroundColor: {
  5199. label: 'Background color',
  5200. section: [
  5201. 'Custom Dark',
  5202. ],
  5203. type: 'text',
  5204. default: '',
  5205. },
  5206. dark_hamburgerButton_remove: {
  5207. label: '<h3>Hamburger button</h3><div class="gmc-label">Remove</div>',
  5208. type: 'checkbox',
  5209. default: false,
  5210. },
  5211. dark_logo_remove: {
  5212. label: '<h3>Logo</h3><div class="gmc-label">Remove</div>',
  5213. type: 'checkbox',
  5214. default: false,
  5215. },
  5216. dark_logo_color: {
  5217. label: 'Color',
  5218. type: 'text',
  5219. default: '',
  5220. },
  5221. dark_logo_customSvg: {
  5222. label: 'Custom SVG (URL or text)',
  5223. type: 'textarea',
  5224. default: '',
  5225. },
  5226. dark_pageTitle_remove: {
  5227. label: '<h3>Page title</h3><div class="gmc-label">Remove</div>',
  5228. type: 'checkbox',
  5229. default: false,
  5230. },
  5231. dark_pageTitle_color: {
  5232. label: 'Color',
  5233. type: 'text',
  5234. default: '',
  5235. },
  5236. dark_pageTitle_hover_backgroundColor: {
  5237. label: 'Hover background color',
  5238. type: 'text',
  5239. default: '',
  5240. },
  5241. dark_pageTitle_hover_color: {
  5242. label: 'Hover color',
  5243. type: 'text',
  5244. default: '',
  5245. },
  5246. dark_search_remove: {
  5247. label: '<h3>Search</h3><div class="gmc-label">Remove</div>',
  5248. type: 'checkbox',
  5249. default: false,
  5250. },
  5251. dark_search_backgroundColor: {
  5252. label: 'Background color',
  5253. type: 'text',
  5254. default: '',
  5255. },
  5256. dark_search_borderColor: {
  5257. label: 'Border color',
  5258. type: 'text',
  5259. default: '',
  5260. },
  5261. dark_search_boxShadow: {
  5262. label: 'Box shadow',
  5263. type: 'text',
  5264. default: '',
  5265. },
  5266. dark_search_alignLeft: {
  5267. label: 'Left aligned',
  5268. type: 'checkbox',
  5269. default: false,
  5270. },
  5271. dark_search_width: {
  5272. label: 'Width',
  5273. type: 'text',
  5274. default: '',
  5275. },
  5276. dark_search_margin_left: {
  5277. label: 'Margin left',
  5278. type: 'text',
  5279. default: '',
  5280. },
  5281. dark_search_margin_right: {
  5282. label: 'Margin right',
  5283. type: 'text',
  5284. default: '',
  5285. },
  5286. dark_search_magnifyingGlassIcon_remove: {
  5287. label: 'Magnifying glass icon remove',
  5288. type: 'checkbox',
  5289. default: false,
  5290. },
  5291. dark_search_placeholder_text: {
  5292. label: 'Placeholder text',
  5293. type: 'text',
  5294. default: '',
  5295. },
  5296. dark_search_placeholder_color: {
  5297. label: 'Placeholder color',
  5298. type: 'text',
  5299. default: '',
  5300. },
  5301. dark_search_rightButton: {
  5302. label: 'Right button',
  5303. type: 'select',
  5304. options: [
  5305. 'none',
  5306. 'command palette',
  5307. 'slash key',
  5308. ],
  5309. default: 'command palette',
  5310. },
  5311. dark_search_modal_width: {
  5312. label: 'Modal width',
  5313. type: 'text',
  5314. default: '',
  5315. },
  5316. dark_divider_remove: {
  5317. label: '<h3>Divider</h3><div class="gmc-label">Remove</div>',
  5318. type: 'checkbox',
  5319. default: false,
  5320. },
  5321. dark_flipCreateInbox: {
  5322. label: 'Flip the order of Create and Notifications',
  5323. type: 'checkbox',
  5324. default: false,
  5325. },
  5326. dark_create_remove: {
  5327. label: '<h3>Create button</h3><div class="gmc-label">Remove</div>',
  5328. type: 'checkbox',
  5329. default: false,
  5330. },
  5331. dark_create_border: {
  5332. label: 'Border',
  5333. type: 'checkbox',
  5334. default: true,
  5335. },
  5336. dark_create_tooltip: {
  5337. label: 'Tooltip',
  5338. type: 'checkbox',
  5339. default: true,
  5340. },
  5341. dark_create_boxShadow: {
  5342. label: 'Box shadow',
  5343. type: 'text',
  5344. default: '',
  5345. },
  5346. dark_create_hoverBackgroundColor: {
  5347. label: 'Hover background color',
  5348. type: 'text',
  5349. default: '',
  5350. },
  5351. dark_create_plusIcon_remove: {
  5352. label: 'Plus icon remove',
  5353. type: 'checkbox',
  5354. default: false,
  5355. },
  5356. dark_create_plusIcon_color: {
  5357. label: 'Plus icon color',
  5358. type: 'text',
  5359. default: '',
  5360. },
  5361. dark_create_plusIcon_marginRight: {
  5362. label: 'Plus icon margin right',
  5363. type: 'text',
  5364. default: '',
  5365. },
  5366. dark_create_plusIcon_hover_color: {
  5367. label: 'Plus icon hover color',
  5368. type: 'text',
  5369. default: '',
  5370. },
  5371. dark_create_text_content: {
  5372. label: 'Text content',
  5373. type: 'text',
  5374. default: '',
  5375. },
  5376. dark_create_text_color: {
  5377. label: 'Text color',
  5378. type: 'text',
  5379. default: '',
  5380. },
  5381. dark_create_dropdownIcon_remove: {
  5382. label: 'Dropdown icon remove',
  5383. type: 'checkbox',
  5384. default: false,
  5385. },
  5386. dark_create_dropdownIcon_color: {
  5387. label: 'Dropdown icon color',
  5388. type: 'text',
  5389. default: '',
  5390. },
  5391. dark_create_dropdownIcon_hover_color: {
  5392. label: 'Dropdown icon hover color',
  5393. type: 'text',
  5394. default: '',
  5395. },
  5396. dark_flipIssuesPullRequests: {
  5397. label: 'Flip the order of Issues and Pull requests',
  5398. type: 'checkbox',
  5399. default: false,
  5400. },
  5401. dark_issues_remove: {
  5402. label: '<h3>Issues button</h3><div class="gmc-label">Remove</div>',
  5403. type: 'checkbox',
  5404. default: false,
  5405. },
  5406. dark_issues_border: {
  5407. label: 'Border',
  5408. type: 'checkbox',
  5409. default: true,
  5410. },
  5411. dark_issues_tooltip: {
  5412. label: 'Tooltip',
  5413. type: 'checkbox',
  5414. default: true,
  5415. },
  5416. dark_issues_boxShadow: {
  5417. label: 'Box shadow',
  5418. type: 'text',
  5419. default: '',
  5420. },
  5421. dark_issues_alignLeft: {
  5422. label: 'Align left',
  5423. type: 'checkbox',
  5424. default: false,
  5425. },
  5426. dark_issues_icon_remove: {
  5427. label: 'Icon remove',
  5428. type: 'checkbox',
  5429. default: false,
  5430. },
  5431. dark_issues_icon_color: {
  5432. label: 'Icon color',
  5433. type: 'text',
  5434. default: '',
  5435. },
  5436. dark_issues_text_content: {
  5437. label: 'Text content',
  5438. type: 'text',
  5439. default: '',
  5440. },
  5441. dark_issues_text_color: {
  5442. label: 'Text color',
  5443. type: 'text',
  5444. default: '',
  5445. },
  5446. dark_issues_hover_backgroundColor: {
  5447. label: 'Hover background color',
  5448. type: 'text',
  5449. default: '',
  5450. },
  5451. dark_issues_hover_color: {
  5452. label: 'Hover color',
  5453. type: 'text',
  5454. default: '',
  5455. },
  5456. dark_pullRequests_remove: {
  5457. label: '<h3>Pull requests button</h3><div class="gmc-label">Remove</div>',
  5458. type: 'checkbox',
  5459. default: false,
  5460. },
  5461. dark_pullRequests_border: {
  5462. label: 'Border',
  5463. type: 'checkbox',
  5464. default: true,
  5465. },
  5466. dark_pullRequests_tooltip: {
  5467. label: 'Tooltip',
  5468. type: 'checkbox',
  5469. default: true,
  5470. },
  5471. dark_pullRequests_alignLeft: {
  5472. label: 'Align left',
  5473. type: 'checkbox',
  5474. default: false,
  5475. },
  5476. dark_pullRequests_boxShadow: {
  5477. label: 'Box shadow',
  5478. type: 'text',
  5479. default: '',
  5480. },
  5481. dark_pullRequests_icon_remove: {
  5482. label: 'Icon remove',
  5483. type: 'checkbox',
  5484. default: false,
  5485. },
  5486. dark_pullRequests_icon_color: {
  5487. label: 'Icon color',
  5488. type: 'text',
  5489. default: '',
  5490. },
  5491. dark_pullRequests_text_content: {
  5492. label: 'Text content',
  5493. type: 'text',
  5494. default: '',
  5495. },
  5496. dark_pullRequests_text_color: {
  5497. label: 'Text color',
  5498. type: 'text',
  5499. default: '',
  5500. },
  5501. dark_pullRequests_hover_backgroundColor: {
  5502. label: 'Hover background color',
  5503. type: 'text',
  5504. default: '',
  5505. },
  5506. dark_pullRequests_hover_color: {
  5507. label: 'Hover color',
  5508. type: 'text',
  5509. default: '',
  5510. },
  5511. dark_marketplace_add: {
  5512. label: '<h3>Marketplace</h3><div class="gmc-label">Add</div>',
  5513. type: 'checkbox',
  5514. default: false,
  5515. },
  5516. dark_marketplace_border: {
  5517. label: 'Border',
  5518. type: 'checkbox',
  5519. default: true,
  5520. },
  5521. dark_marketplace_alignLeft: {
  5522. label: 'Align left',
  5523. type: 'checkbox',
  5524. default: false,
  5525. },
  5526. dark_marketplace_boxShadow: {
  5527. label: 'Box shadow',
  5528. type: 'text',
  5529. default: '',
  5530. },
  5531. dark_marketplace_icon_remove: {
  5532. label: 'Icon remove',
  5533. type: 'checkbox',
  5534. default: false,
  5535. },
  5536. dark_marketplace_icon_color: {
  5537. label: 'Icon color',
  5538. type: 'text',
  5539. default: '',
  5540. },
  5541. dark_marketplace_text_content: {
  5542. label: 'Text content',
  5543. type: 'text',
  5544. default: '',
  5545. },
  5546. dark_marketplace_text_color: {
  5547. label: 'Text color',
  5548. type: 'text',
  5549. default: '',
  5550. },
  5551. dark_marketplace_hover_backgroundColor: {
  5552. label: 'Hover background color',
  5553. type: 'text',
  5554. default: '',
  5555. },
  5556. dark_marketplace_hover_color: {
  5557. label: 'Hover color',
  5558. type: 'text',
  5559. default: '',
  5560. },
  5561. dark_explore_add: {
  5562. label: '<h3>Explore</h3><div class="gmc-label">Add</div>',
  5563. type: 'checkbox',
  5564. default: false,
  5565. },
  5566. dark_explore_border: {
  5567. label: 'Border',
  5568. type: 'checkbox',
  5569. default: true,
  5570. },
  5571. dark_explore_alignLeft: {
  5572. label: 'Align left',
  5573. type: 'checkbox',
  5574. default: false,
  5575. },
  5576. dark_explore_boxShadow: {
  5577. label: 'Box shadow',
  5578. type: 'text',
  5579. default: '',
  5580. },
  5581. dark_explore_icon_remove: {
  5582. label: 'Icon remove',
  5583. type: 'checkbox',
  5584. default: false,
  5585. },
  5586. dark_explore_icon_color: {
  5587. label: 'Icon color',
  5588. type: 'text',
  5589. default: '',
  5590. },
  5591. dark_explore_text_content: {
  5592. label: 'Text content',
  5593. type: 'text',
  5594. default: '',
  5595. },
  5596. dark_explore_text_color: {
  5597. label: 'Text color',
  5598. type: 'text',
  5599. default: '',
  5600. },
  5601. dark_explore_hover_backgroundColor: {
  5602. label: 'Hover background color',
  5603. type: 'text',
  5604. default: '',
  5605. },
  5606. dark_explore_hover_color: {
  5607. label: 'Hover color',
  5608. type: 'text',
  5609. default: '',
  5610. },
  5611. dark_notifications_remove: {
  5612. label: '<h3>Notifications button</h3><div class="gmc-label">Remove</div>',
  5613. type: 'checkbox',
  5614. default: false,
  5615. },
  5616. dark_notifications_border: {
  5617. label: 'Border',
  5618. type: 'checkbox',
  5619. default: true,
  5620. },
  5621. dark_notifications_tooltip: {
  5622. label: 'Tooltip',
  5623. type: 'checkbox',
  5624. default: true,
  5625. },
  5626. dark_notifications_boxShadow: {
  5627. label: 'Box shadow',
  5628. type: 'text',
  5629. default: '',
  5630. },
  5631. dark_notifications_hoverBackgroundColor: {
  5632. label: 'Hover background color',
  5633. type: 'text',
  5634. default: '',
  5635. },
  5636. dark_notifications_icon_symbol: {
  5637. label: 'Icon symbol',
  5638. type: 'select',
  5639. options: [
  5640. 'none',
  5641. 'inbox',
  5642. 'bell',
  5643. ],
  5644. default: 'inbox',
  5645. },
  5646. dark_notifications_icon_color: {
  5647. label: 'Icon color',
  5648. type: 'text',
  5649. default: '',
  5650. },
  5651. dark_notifications_icon_hover_color: {
  5652. label: 'Icon hover color',
  5653. type: 'text',
  5654. default: '',
  5655. },
  5656. dark_notifications_text_content: {
  5657. label: 'Text content',
  5658. type: 'text',
  5659. default: '',
  5660. },
  5661. dark_notifications_text_color: {
  5662. label: 'Text color',
  5663. type: 'text',
  5664. default: '',
  5665. },
  5666. dark_notifications_dot_remove: {
  5667. label: 'Dot remove',
  5668. type: 'checkbox',
  5669. default: false,
  5670. },
  5671. dark_notifications_dot_boxShadowColor: {
  5672. label: 'Dot hover color',
  5673. type: 'text',
  5674. default: '',
  5675. },
  5676. dark_notifications_dot_color: {
  5677. label: 'Dot color',
  5678. type: 'text',
  5679. default: '',
  5680. },
  5681. dark_notifications_dot_displayOverIcon: {
  5682. label: 'Dot display over icon',
  5683. type: 'checkbox',
  5684. default: false,
  5685. },
  5686. dark_avatar_remove: {
  5687. label: '<h3>Avatar</h3><div class="gmc-label">Remove</div>',
  5688. type: 'checkbox',
  5689. default: false,
  5690. },
  5691. dark_avatar_size: {
  5692. label: 'Size',
  5693. type: 'text',
  5694. default: '',
  5695. },
  5696. dark_avatar_dropdownIcon: {
  5697. label: 'Dropdown icon',
  5698. type: 'checkbox',
  5699. default: false,
  5700. },
  5701. dark_avatar_canCloseSidebar: {
  5702. label: 'Can close sidebar',
  5703. type: 'checkbox',
  5704. default: false,
  5705. },
  5706. dark_globalBar_boxShadowColor: {
  5707. label: '<h3>Global bar</h3><div class="gmc-label">Box shadow color</div>',
  5708. type: 'text',
  5709. default: '',
  5710. },
  5711. dark_globalBar_leftAligned_gap: {
  5712. label: 'Left aligned gap',
  5713. type: 'text',
  5714. default: '',
  5715. },
  5716. dark_globalBar_rightAligned_gap: {
  5717. label: 'Right aligned gap',
  5718. type: 'text',
  5719. default: '',
  5720. },
  5721. dark_localBar_backgroundColor: {
  5722. label: '<h3>Local bar</h3><div class="gmc-label">Background color</div>',
  5723. type: 'text',
  5724. default: '',
  5725. },
  5726. dark_localBar_alignCenter: {
  5727. label: 'Align center',
  5728. type: 'checkbox',
  5729. default: false,
  5730. },
  5731. dark_localBar_boxShadow_consistentColor: {
  5732. label: 'Box shadow consistent color',
  5733. type: 'checkbox',
  5734. default: false,
  5735. },
  5736. dark_localBar_links_color: {
  5737. label: 'Links color',
  5738. type: 'text',
  5739. default: '',
  5740. },
  5741. dark_sidebars_backdrop_color: {
  5742. label: '<h3>Sidebars</h3><div class="gmc-label">Backdrop color</div>',
  5743. type: 'text',
  5744. default: '',
  5745. },
  5746. dark_sidebars_left_preload: {
  5747. label: 'Left preload',
  5748. type: 'checkbox',
  5749. default: false,
  5750. },
  5751. dark_sidebars_right_preload: {
  5752. label: 'Right preload',
  5753. type: 'checkbox',
  5754. default: false,
  5755. },
  5756. dark_sidebars_right_floatUnderneath: {
  5757. label: 'Right float underneath',
  5758. type: 'checkbox',
  5759. default: false,
  5760. },
  5761. dark_sidebars_right_width: {
  5762. label: 'Right width',
  5763. type: 'text',
  5764. default: '',
  5765. },
  5766. dark_sidebars_right_maxHeight: {
  5767. label: 'Right max height',
  5768. type: 'text',
  5769. default: '',
  5770. },
  5771. dark_repositoryHeader_import: {
  5772. label: '<h3>Repository header</h3><div class="gmc-label">Import</div>',
  5773. type: 'checkbox',
  5774. default: false,
  5775. },
  5776. dark_repositoryHeader_alignCenter: {
  5777. label: 'Align enter',
  5778. type: 'checkbox',
  5779. default: false,
  5780. },
  5781. dark_repositoryHeader_removePageTitle: {
  5782. label: 'Remove page title',
  5783. type: 'checkbox',
  5784. default: false,
  5785. },
  5786. dark_repositoryHeader_backgroundColor: {
  5787. label: 'Background color',
  5788. type: 'text',
  5789. default: '',
  5790. },
  5791. dark_repositoryHeader_avatar_remove: {
  5792. label: 'Avatar remove',
  5793. type: 'checkbox',
  5794. default: false,
  5795. },
  5796. dark_repositoryHeader_avatar_customSvg: {
  5797. label: 'Custom SVG (URL or text)',
  5798. type: 'textarea',
  5799. default: '',
  5800. },
  5801. dark_repositoryHeader_link_color: {
  5802. label: 'Link color',
  5803. type: 'text',
  5804. default: '',
  5805. },
  5806. dark_repositoryHeader_link_hover_backgroundColor: {
  5807. label: 'Link hover background color',
  5808. type: 'text',
  5809. default: '',
  5810. },
  5811. dark_repositoryHeader_link_hover_color: {
  5812. label: 'Link hover color',
  5813. type: 'text',
  5814. default: '',
  5815. },
  5816. dark_repositoryHeader_link_hover_textDecoration: {
  5817. label: 'Link hover text decoration',
  5818. type: 'text',
  5819. default: '',
  5820. },
  5821. on_save: {
  5822. label: 'On save',
  5823. section: ['Settings'],
  5824. type: 'select',
  5825. options: [
  5826. 'do nothing',
  5827. 'refresh tab',
  5828. 'refresh tab and close',
  5829. 'run script',
  5830. 'run script and close',
  5831. ],
  5832. default: 'do nothing',
  5833. },
  5834. on_close: {
  5835. label: 'On close',
  5836. type: 'select',
  5837. options: [
  5838. 'do nothing',
  5839. 'refresh tab',
  5840. 'run script',
  5841. ],
  5842. default: 'do nothing',
  5843. },
  5844. menu_item_title: {
  5845. label: 'Menu item title',
  5846. type: 'text',
  5847. default: 'Custom global navigation',
  5848. },
  5849. menu_item_icon: {
  5850. label: 'Menu item icon',
  5851. type: 'select',
  5852. options: [
  5853. 'logo',
  5854. 'compass',
  5855. 'cog',
  5856. ],
  5857. default: 'logo',
  5858. },
  5859. log_level: {
  5860. label: 'Log level',
  5861. type: 'select',
  5862. options: [
  5863. 'silent',
  5864. 'quiet',
  5865. 'debug',
  5866. 'verbose',
  5867. 'trace',
  5868. ],
  5869. default: 'quiet',
  5870. },
  5871. clear_custom_config: {
  5872. label: 'Clear Custom',
  5873. section: ['Danger Zone'],
  5874. type: 'button',
  5875. click: gmcClearCustom,
  5876. },
  5877. apply_happyMedium_config: {
  5878. label: 'Overwrite Custom with Happy Medium',
  5879. type: 'button',
  5880. click: gmcApplyCustomHappyMediumConfig,
  5881. },
  5882. apply_oldSchool_config: {
  5883. label: 'Overwrite Custom with Old School',
  5884. type: 'button',
  5885. click: gmcApplyCustomOldSchoolConfig,
  5886. },
  5887. },
  5888. });
  5889. })();