Skip to content

Commit cebc837

Browse files
Fix github.com (#108)
1 parent 5850a1c commit cebc837

File tree

3 files changed

+27
-41
lines changed

3 files changed

+27
-41
lines changed

src/button/button-contributions.ts

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -191,31 +191,23 @@ export const buttonContributions: ButtonContributionParams[] = [
191191

192192
// GitHub
193193
{
194-
id: "new-repo",
194+
id: "gh-new-repo",
195195
exampleUrls: [
196196
// disabled testing, because the new layout doesn't show as an anonymous user
197197
// "https://github.com/svenefftinge/browser-extension-test",
198198
// "https://github.com/svenefftinge/browser-extension-test/tree/my-branch",
199199
],
200-
selector: "#repository-details-container > ul",
201-
containerElement: createElement("li", {
202-
}),
200+
selector: `xpath://*[@id="repo-content-pjax-container"]/div/div/div[2]/div[1]/react-partial/div/div/div[1]/div/div/div[2]/div[2]/div/div[3]/div[1]/div[2]`,
201+
containerElement: createElement("div", {}),
202+
additionalClassNames: ["medium"],
203203
application: "github",
204-
manipulations: [
205-
{
206-
// make the code button secondary
207-
element: "#repository-details-container > ul > li > get-repo > details > summary",
208-
remove: "Button--primary",
209-
add: "Button--secondary"
210-
}
211-
],
212204
match: () => {
213205
const regex = /^https?:\/\/([^/]+)\/([^/]+)\/([^/]+)(\/(tree\/.*)?)?$/;
214206
return document.querySelector("div.file-navigation") === null && regex.test(window.location.href);
215207
}
216208
},
217209
{
218-
id: "commit",
210+
id: "gh-commit",
219211
exampleUrls: [
220212
"https://github.com/svenefftinge/browser-extension-test/commit/82d701a9ac26ea25da9b24c5b3722b7a89e43b16"
221213
],
@@ -230,7 +222,7 @@ export const buttonContributions: ButtonContributionParams[] = [
230222
},
231223

232224
{
233-
id: "issues",
225+
id: "gh-issues",
234226
exampleUrls: [
235227
"https://github.com/svenefftinge/browser-extension-test/issues/1"
236228
],
@@ -250,7 +242,7 @@ export const buttonContributions: ButtonContributionParams[] = [
250242
],
251243
},
252244
{
253-
id: "pulls",
245+
id: "gh-pulls",
254246
exampleUrls: [
255247
"https://github.com/svenefftinge/browser-extension-test/pull/2",
256248
],
@@ -261,8 +253,9 @@ export const buttonContributions: ButtonContributionParams[] = [
261253
match: /\/pull\//,
262254
application: "github",
263255
},
256+
// Look into removing since GitHub is shifting to the new repo layout (see gh-new-repo)
264257
{
265-
id: "repo",
258+
id: "gh-repo",
266259
exampleUrls: [
267260
"https://github.com/svenefftinge/browser-extension-test",
268261
"https://github.com/svenefftinge/browser-extension-test/tree/my-branch",
@@ -283,7 +276,7 @@ export const buttonContributions: ButtonContributionParams[] = [
283276
],
284277
},
285278
{
286-
id: "file",
279+
id: "gh-file",
287280
exampleUrls: [
288281
"https://github.com/svenefftinge/browser-extension-test/blob/my-branch/README.md"
289282
],
@@ -295,7 +288,7 @@ export const buttonContributions: ButtonContributionParams[] = [
295288
additionalClassNames: ["medium"],
296289
},
297290
{
298-
id: "empty-repo",
291+
id: "gh-empty-repo",
299292
exampleUrls: [
300293
//TODO fixme "https://github.com/svenefftinge/empty-repo",
301294
],

src/button/button.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189
--border-radius: var(--borderRadius-medium, 0.375rem);
190190
--border-width: var(--borderWidth-thin, max(1px, 0.0625rem));
191191

192-
--primary-height: var(--control-small-size, 2rem);
192+
--primary-height: var(--control-small-size, 1.75rem);
193193
--primary-bg-color: var(--button-primary-bgColor-rest, var(--color-btn-primary-bg));
194194
--primary-hover-bg-color: var(--button-primary-bgColor-hover, var(--color-btn-primary-hover-bg));
195195
--primary-border-color: var(--button-primary-borderColor-rest, var(--color-btn-primary-border));

test/src/button-contributions-copy.ts

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export const buttonContributions: ButtonContributionParams[] = [
173173
"https://gitlab.com/svenefftinge/browser-extension-test/-/issues/1",
174174
],
175175
match: /\/issues\//,
176-
selector: "#content-body > div.issue-details.issuable-details.js-issue-details > div.detail-page-description.content-block.js-detail-page-description.gl-pt-3.gl-pb-0.gl-border-none > div:nth-child(1) > div > div.gl-display-flex.gl-align-items-flex-start.gl-flex-direction-column.gl-sm-flex-direction-row.gl-gap-3.gl-pt-3 > div",
176+
selector: "#content-body > div.issue-details.issuable-details.js-issue-details > div.detail-page-description.content-block.js-detail-page-description.gl-pt-3.gl-pb-0.gl-border-none > div:nth-child(1) > div > div.gl-display-flex > div",
177177
containerElement: createElement("div", {marginLeft: "0", marginRight: "0px"}),
178178
application: "gitlab",
179179
insertBefore: "#new-actions-header-dropdown",
@@ -191,31 +191,23 @@ export const buttonContributions: ButtonContributionParams[] = [
191191

192192
// GitHub
193193
{
194-
id: "new-repo",
194+
id: "gh-new-repo",
195195
exampleUrls: [
196196
// disabled testing, because the new layout doesn't show as an anonymous user
197197
// "https://github.com/svenefftinge/browser-extension-test",
198198
// "https://github.com/svenefftinge/browser-extension-test/tree/my-branch",
199199
],
200-
selector: "#repository-details-container > ul",
201-
containerElement: createElement("li", {
202-
}),
200+
selector: `xpath://*[@id="repo-content-pjax-container"]/div/div/div[2]/div[1]/react-partial/div/div/div[1]/div/div/div[2]/div[2]/div/div[3]/div[1]/div[2]`,
201+
containerElement: createElement("div", {}),
202+
additionalClassNames: ["medium"],
203203
application: "github",
204-
manipulations: [
205-
{
206-
// make the code button secondary
207-
element: "#repository-details-container > ul > li > get-repo > details > summary",
208-
remove: "Button--primary",
209-
add: "Button--secondary"
210-
}
211-
],
212204
match: () => {
213205
const regex = /^https?:\/\/([^/]+)\/([^/]+)\/([^/]+)(\/(tree\/.*)?)?$/;
214206
return document.querySelector("div.file-navigation") === null && regex.test(window.location.href);
215207
}
216208
},
217209
{
218-
id: "commit",
210+
id: "gh-commit",
219211
exampleUrls: [
220212
"https://github.com/svenefftinge/browser-extension-test/commit/82d701a9ac26ea25da9b24c5b3722b7a89e43b16"
221213
],
@@ -230,7 +222,7 @@ export const buttonContributions: ButtonContributionParams[] = [
230222
},
231223

232224
{
233-
id: "issues",
225+
id: "gh-issues",
234226
exampleUrls: [
235227
"https://github.com/svenefftinge/browser-extension-test/issues/1"
236228
],
@@ -250,7 +242,7 @@ export const buttonContributions: ButtonContributionParams[] = [
250242
],
251243
},
252244
{
253-
id: "pulls",
245+
id: "gh-pulls",
254246
exampleUrls: [
255247
"https://github.com/svenefftinge/browser-extension-test/pull/2",
256248
],
@@ -261,8 +253,9 @@ export const buttonContributions: ButtonContributionParams[] = [
261253
match: /\/pull\//,
262254
application: "github",
263255
},
256+
// Look into removing since GitHub is shifting to the new repo layout (see gh-new-repo)
264257
{
265-
id: "repo",
258+
id: "gh-repo",
266259
exampleUrls: [
267260
"https://github.com/svenefftinge/browser-extension-test",
268261
"https://github.com/svenefftinge/browser-extension-test/tree/my-branch",
@@ -283,7 +276,7 @@ export const buttonContributions: ButtonContributionParams[] = [
283276
],
284277
},
285278
{
286-
id: "file",
279+
id: "gh-file",
287280
exampleUrls: [
288281
"https://github.com/svenefftinge/browser-extension-test/blob/my-branch/README.md"
289282
],
@@ -295,7 +288,7 @@ export const buttonContributions: ButtonContributionParams[] = [
295288
additionalClassNames: ["medium"],
296289
},
297290
{
298-
id: "empty-repo",
291+
id: "gh-empty-repo",
299292
exampleUrls: [
300293
//TODO fixme "https://github.com/svenefftinge/empty-repo",
301294
],
@@ -356,7 +349,7 @@ export const buttonContributions: ButtonContributionParams[] = [
356349
exampleUrls: [
357350
// "https://bitbucket.org/svenefftinge/browser-extension-test/src/master/"
358351
],
359-
selector: 'xpath://*[@id="root"]/div[2]/div[3]/div/div/div[1]/div/header/div/div/div/div[2]/div',
352+
selector: 'xpath://*[@id="root"]/div/div[3]/div/div/div[1]/div/header/div/div/div/div[2]/div',
360353
insertBefore: "#root > div.css-kyhvoj > div.css-e48442 > div > div > div.css-8ypwyz.efo6slf1 > div > header > div > div > div > div.sc-kAzzGY.hKOvhL > div > div:nth-child(3)",
361354
containerElement: createElement("div", {
362355
marginLeft: "2px",
@@ -380,7 +373,7 @@ export const buttonContributions: ButtonContributionParams[] = [
380373
exampleUrls: [
381374
// "https://bitbucket.org/efftinge/browser-extension-test/branch/my-branch"
382375
],
383-
selector: 'xpath://*[@id="root"]/div[2]/div[3]/div/div/div[1]/div/div/div[2]/div/div',
376+
selector: 'xpath://*[@id="root"]/div/div[3]/div/div/div[1]/div/div/div[2]/div/div',
384377
containerElement: createElement("div", {
385378
marginLeft: "2px",
386379
}),
@@ -392,7 +385,7 @@ export const buttonContributions: ButtonContributionParams[] = [
392385
exampleUrls: [
393386
"https://bitbucket.org/efftinge/browser-extension-test/commits/"
394387
],
395-
selector: 'xpath://*[@id="root"]/div[2]/div[3]/div/div/div[1]/div/div/div[1]/div[1]/div[2]/div',
388+
selector: 'xpath://*[@id="root"]/div/div[3]/div/div/div[1]/div/div/div[1]/div[1]/div[2]/div',
396389
containerElement: createElement("div", {
397390
marginLeft: "2px",
398391
}),

0 commit comments

Comments
 (0)