Skip to content

Commit 812e01e

Browse files
committed
Add support for repos link removal
1 parent 4ebc6a3 commit 812e01e

File tree

3 files changed

+102
-17
lines changed

3 files changed

+102
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules/
2+
backup/
23
*.afdesign*
34
/*.css
45
/*.svg

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/github-custom-global-navigation.user.js

Lines changed: 99 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115

116116
updateLink('issues');
117117
updateLink('pullRequests');
118+
updateLink('repos');
118119

119120
if (CONFIG.marketplace.add) updateLink('marketplace');
120121
if (CONFIG.explore.add) updateLink('explore');
@@ -651,7 +652,7 @@
651652
}
652653

653654
function updateLink(configKey) {
654-
log(DEBUG, 'updateLink()');
655+
log(DEBUG, `updateLink() with ${configKey}`);
655656

656657
const elementConfig = CONFIG[configKey];
657658
const elementSelector = SELECTORS[configKey];
@@ -661,16 +662,25 @@
661662

662663
if (tooltipElement) {
663664
link = tooltipElement.previousElementSibling;
665+
log(DEBUG, `Found link for ${configKey} using tooltipElement.previousElementSibling`);
664666
} else {
665667
log(DEBUG, `Tooltip for '${configKey}' not found`);
666668

667669
const linkId = createId(SELECTORS[configKey].id);
670+
log(DEBUG, `Trying HEADER.querySelector(${linkId}) for ${configKey}`);
668671
link = HEADER.querySelector(linkId);
669672

670673
if (!link) {
671-
logError(`Selector '${linkId}' not found`);
672-
673-
return;
674+
log(DEBUG, `HEADER.querySelector(${linkId}) not found, trying SELECTORS[configKey].link: ${elementSelector.link}`);
675+
link = HEADER.querySelector(elementSelector.link);
676+
if (!link) {
677+
logError(`Selector '${linkId}' and '${elementSelector.link}' not found for ${configKey}`);
678+
return;
679+
} else {
680+
log(DEBUG, `Found link for ${configKey} using selector: ${elementSelector.link}`);
681+
}
682+
} else {
683+
log(DEBUG, `Found link for ${configKey} using id selector: ${linkId}`);
674684
}
675685
}
676686

@@ -679,7 +689,6 @@
679689

680690
if (elementConfig.remove) {
681691
HEADER_STYLE.textContent += cssHideElement(createId(configKey));
682-
683692
return;
684693
}
685694

@@ -689,16 +698,10 @@
689698

690699
if (elementConfig.alignLeft) {
691700
const response = cloneAndLeftAlignElement(createId(elementSelector.id), elementSelector.id);
692-
693701
if (response.length === 0) return;
694-
695702
const [cloneId, cloneElement] = response;
696-
697-
elementSelector[CONFIG_NAME] = {
698-
leftAlignedId: cloneId,
699-
};
703+
elementSelector[CONFIG_NAME] = { leftAlignedId: cloneId };
700704
link = cloneElement;
701-
702705
linkSelector = createId(cloneId);
703706
}
704707

@@ -711,15 +714,12 @@
711714
if (elementConfig.icon.remove) {
712715
const svgId = `${configKey}-svg`;
713716
const svg = link.querySelector('svg');
714-
715717
if (!svg) {
716718
logError(`Selector '${configKey} svg' not found`);
717-
719+
log(INFO, `Could not find svg for ${configKey} in link element`);
718720
return;
719721
}
720-
721722
svg.setAttribute('id', svgId);
722-
723723
HEADER_STYLE.textContent += cssHideElement(createId(svgId));
724724
} else {
725725
link.querySelector('svg').style.setProperty('fill', elementConfig.icon.color);
@@ -3578,7 +3578,7 @@
35783578
topDiv: '.AppHeader-globalBar-start .AppHeader-logo',
35793579
svg: '.AppHeader-logo svg',
35803580
},
3581-
hamburgerButton: '.AppHeader-globalBar-start deferred-side-panel',
3581+
hamburgerButton: '.AppHeader-globalBar-start div:first-child react-partial-anchor button',
35823582
pageTitle: {
35833583
id: 'custom-page-title',
35843584
topDiv: '.AppHeader-context',
@@ -3613,13 +3613,19 @@
36133613
},
36143614
issues: {
36153615
id: 'issues',
3616+
link: '.AppHeader-globalBar-end .AppHeader-actions a[href="/issues"]',
36163617
textContent: 'issues-text-content-span',
36173618
},
36183619
pullRequests: {
36193620
id: 'pullRequests',
36203621
link: '.AppHeader-globalBar-end .AppHeader-actions a[href="/pulls"]',
36213622
textContent: 'pullRequests-text-content-span',
36223623
},
3624+
repos: {
3625+
id: 'repos',
3626+
link: '.AppHeader-globalBar-end .AppHeader-actions a[href="/repos"]',
3627+
textContent: 'repos-text-content-span',
3628+
},
36233629
marketplace: {
36243630
id: 'marketplace',
36253631
link: '.AppHeader-globalBar-end .AppHeader-actions a[href="/marketplace"]',
@@ -3807,6 +3813,25 @@
38073813
color: '',
38083814
},
38093815
},
3816+
repos: {
3817+
remove: false,
3818+
border: true,
3819+
tooltip: false,
3820+
alignLeft: false,
3821+
boxShadow: '',
3822+
icon: {
3823+
remove: false,
3824+
color: '',
3825+
},
3826+
text: {
3827+
content: 'Repos',
3828+
color: '',
3829+
},
3830+
hover: {
3831+
backgroundColor: '',
3832+
color: '',
3833+
},
3834+
},
38103835
marketplace: {
38113836
add: false,
38123837
border: false,
@@ -4053,6 +4078,25 @@
40534078
color: '',
40544079
},
40554080
},
4081+
repos: {
4082+
remove: false,
4083+
border: true,
4084+
tooltip: false,
4085+
alignLeft: false,
4086+
boxShadow: '',
4087+
icon: {
4088+
remove: false,
4089+
color: '',
4090+
},
4091+
text: {
4092+
content: 'Repos',
4093+
color: '',
4094+
},
4095+
hover: {
4096+
backgroundColor: '',
4097+
color: '',
4098+
},
4099+
},
40564100
marketplace: {
40574101
add: false,
40584102
border: false,
@@ -4301,6 +4345,25 @@
43014345
color: oldSchoolHoverColor,
43024346
},
43034347
},
4348+
repos: {
4349+
remove: true,
4350+
border: true,
4351+
tooltip: false,
4352+
alignLeft: false,
4353+
boxShadow: '',
4354+
icon: {
4355+
remove: false,
4356+
color: '',
4357+
},
4358+
text: {
4359+
content: 'Repos',
4360+
color: '',
4361+
},
4362+
hover: {
4363+
backgroundColor: '',
4364+
color: '',
4365+
},
4366+
},
43044367
marketplace: {
43054368
add: true,
43064369
border: false,
@@ -4549,6 +4612,25 @@
45494612
color: oldSchoolHoverColor,
45504613
},
45514614
},
4615+
repos: {
4616+
remove: true,
4617+
border: true,
4618+
tooltip: false,
4619+
alignLeft: false,
4620+
boxShadow: '',
4621+
icon: {
4622+
remove: false,
4623+
color: '',
4624+
},
4625+
text: {
4626+
content: 'Repos',
4627+
color: '',
4628+
},
4629+
hover: {
4630+
backgroundColor: '',
4631+
color: '',
4632+
},
4633+
},
45524634
marketplace: {
45534635
add: true,
45544636
border: false,

0 commit comments

Comments
 (0)