Skip to content

Commit

Permalink
Fix deprioritize-marketplace-link (#3725)
Browse files Browse the repository at this point in the history
Co-authored-by: Federico <me@fregante.com>
  • Loading branch information
yakov116 and fregante committed Nov 17, 2020
1 parent dba3b01 commit 38fb7b0
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions source/features/deprioritize-marketplace-link.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import React from 'dom-chef';
import select from 'select-dom';
import onetime from 'onetime';
import domLoaded from 'dom-loaded';
import elementReady from 'element-ready';
import * as pageDetect from 'github-url-detection';

import features from '.';

async function init(): Promise<void> {
const marketPlaceLink = (await elementReady('.Header-link[href="/marketplace"]'));
if (marketPlaceLink) {
// The Marketplace link seems to have an additional wrapper that other links don't have https://i.imgur.com/KV9rtSq.png
marketPlaceLink.closest('.border-top, .mr-3')!.remove();
}

await domLoaded;

function handleMenuOpening(): void {
select.last('.header-nav-current-user ~ .dropdown-divider')!.before(
<div className="dropdown-divider"/>,
<a className="dropdown-item" href="/marketplace">Marketplace</a>
);
}

async function init(): Promise<void> {
const marketplaceLink = await elementReady('.Header-link[href="/marketplace"]');
if (marketplaceLink) { // On GHE it can be disabled
// The link seems to have an additional wrapper that other links don't have https://i.imgur.com/KV9rtSq.png
marketplaceLink.closest('.border-top, .mr-3')!.remove();

(await elementReady('[aria-label="View profile and more"]'))!
.closest('details')!
.addEventListener('toggle', handleMenuOpening, {once: true});
}
}

void features.add(__filebasename, {
exclude: [
pageDetect.isGist
Expand Down

0 comments on commit 38fb7b0

Please sign in to comment.