github-url-detection 8.2.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/distribution/index.js +129 -413
- package/package.json +10 -5
package/distribution/index.js
CHANGED
|
@@ -1,370 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"cla",
|
|
79
|
-
"cloud",
|
|
80
|
-
"codereview",
|
|
81
|
-
"collection",
|
|
82
|
-
"collections",
|
|
83
|
-
"comments",
|
|
84
|
-
"commit",
|
|
85
|
-
"commits",
|
|
86
|
-
"community",
|
|
87
|
-
"companies",
|
|
88
|
-
"compare",
|
|
89
|
-
"contact",
|
|
90
|
-
"contributing",
|
|
91
|
-
"cookbook",
|
|
92
|
-
"coupons",
|
|
93
|
-
"customer-stories",
|
|
94
|
-
"customer",
|
|
95
|
-
"customers",
|
|
96
|
-
"dashboard-feed",
|
|
97
|
-
"dashboard",
|
|
98
|
-
"dashboards",
|
|
99
|
-
"design",
|
|
100
|
-
"develop",
|
|
101
|
-
"developer",
|
|
102
|
-
"diff",
|
|
103
|
-
"discover",
|
|
104
|
-
"discussions",
|
|
105
|
-
"docs",
|
|
106
|
-
"downloads",
|
|
107
|
-
"downtime",
|
|
108
|
-
"editor",
|
|
109
|
-
"editors",
|
|
110
|
-
"edu",
|
|
111
|
-
"enterprise",
|
|
112
|
-
"events",
|
|
113
|
-
"explore",
|
|
114
|
-
"featured",
|
|
115
|
-
"features",
|
|
116
|
-
"files",
|
|
117
|
-
"fixtures",
|
|
118
|
-
"forked",
|
|
119
|
-
"garage",
|
|
120
|
-
"ghost",
|
|
121
|
-
"gist",
|
|
122
|
-
"gists",
|
|
123
|
-
"graphs",
|
|
124
|
-
"guide",
|
|
125
|
-
"guides",
|
|
126
|
-
"help",
|
|
127
|
-
"help-wanted",
|
|
128
|
-
"home",
|
|
129
|
-
"hooks",
|
|
130
|
-
"hosting",
|
|
131
|
-
"hovercards",
|
|
132
|
-
"identity",
|
|
133
|
-
"images",
|
|
134
|
-
"inbox",
|
|
135
|
-
"individual",
|
|
136
|
-
"info",
|
|
137
|
-
"integration",
|
|
138
|
-
"interfaces",
|
|
139
|
-
"introduction",
|
|
140
|
-
"invalid-email-address",
|
|
141
|
-
"investors",
|
|
142
|
-
"issues",
|
|
143
|
-
"jobs",
|
|
144
|
-
"join",
|
|
145
|
-
"journal",
|
|
146
|
-
"journals",
|
|
147
|
-
"lab",
|
|
148
|
-
"labs",
|
|
149
|
-
"languages",
|
|
150
|
-
"launch",
|
|
151
|
-
"layouts",
|
|
152
|
-
"learn",
|
|
153
|
-
"legal",
|
|
154
|
-
"library",
|
|
155
|
-
"linux",
|
|
156
|
-
"listings",
|
|
157
|
-
"lists",
|
|
158
|
-
"login",
|
|
159
|
-
"logos",
|
|
160
|
-
"logout",
|
|
161
|
-
"mac",
|
|
162
|
-
"maintenance",
|
|
163
|
-
"malware",
|
|
164
|
-
"man",
|
|
165
|
-
"marketplace",
|
|
166
|
-
"mention",
|
|
167
|
-
"mentioned",
|
|
168
|
-
"mentioning",
|
|
169
|
-
"mentions",
|
|
170
|
-
"migrating",
|
|
171
|
-
"milestones",
|
|
172
|
-
"mine",
|
|
173
|
-
"mirrors",
|
|
174
|
-
"mobile",
|
|
175
|
-
"navigation",
|
|
176
|
-
"network",
|
|
177
|
-
"new",
|
|
178
|
-
"news",
|
|
179
|
-
"none",
|
|
180
|
-
"nonprofit",
|
|
181
|
-
"nonprofits",
|
|
182
|
-
"notices",
|
|
183
|
-
"notifications",
|
|
184
|
-
"oauth",
|
|
185
|
-
"offer",
|
|
186
|
-
"open-source",
|
|
187
|
-
"organisations",
|
|
188
|
-
"organizations",
|
|
189
|
-
"orgs",
|
|
190
|
-
"pages",
|
|
191
|
-
"partners",
|
|
192
|
-
"payments",
|
|
193
|
-
"personal",
|
|
194
|
-
"plans",
|
|
195
|
-
"plugins",
|
|
196
|
-
"popular",
|
|
197
|
-
"popularity",
|
|
198
|
-
"posts",
|
|
199
|
-
"press",
|
|
200
|
-
"pricing",
|
|
201
|
-
"professional",
|
|
202
|
-
"projects",
|
|
203
|
-
"pulls",
|
|
204
|
-
"raw",
|
|
205
|
-
"readme",
|
|
206
|
-
"recommendations",
|
|
207
|
-
"redeem",
|
|
208
|
-
"releases",
|
|
209
|
-
"render",
|
|
210
|
-
"reply",
|
|
211
|
-
"repositories",
|
|
212
|
-
"resources",
|
|
213
|
-
"restore",
|
|
214
|
-
"revert",
|
|
215
|
-
"save-net-neutrality",
|
|
216
|
-
"saved",
|
|
217
|
-
"scraping",
|
|
218
|
-
"search",
|
|
219
|
-
"security",
|
|
220
|
-
"services",
|
|
221
|
-
"sessions",
|
|
222
|
-
"settings",
|
|
223
|
-
"shareholders",
|
|
224
|
-
"shop",
|
|
225
|
-
"showcases",
|
|
226
|
-
"signin",
|
|
227
|
-
"signup",
|
|
228
|
-
"site",
|
|
229
|
-
"spam",
|
|
230
|
-
"sponsors",
|
|
231
|
-
"ssh",
|
|
232
|
-
"staff",
|
|
233
|
-
"starred",
|
|
234
|
-
"stars",
|
|
235
|
-
"static",
|
|
236
|
-
"status",
|
|
237
|
-
"statuses",
|
|
238
|
-
"storage",
|
|
239
|
-
"store",
|
|
240
|
-
"stories",
|
|
241
|
-
"styleguide",
|
|
242
|
-
"subscriptions",
|
|
243
|
-
"suggest",
|
|
244
|
-
"suggestion",
|
|
245
|
-
"suggestions",
|
|
246
|
-
"support",
|
|
247
|
-
"suspended",
|
|
248
|
-
"talks",
|
|
249
|
-
"teach",
|
|
250
|
-
"teacher",
|
|
251
|
-
"teachers",
|
|
252
|
-
"teaching",
|
|
253
|
-
"team",
|
|
254
|
-
"teams",
|
|
255
|
-
"ten",
|
|
256
|
-
"terms",
|
|
257
|
-
"timeline",
|
|
258
|
-
"topic",
|
|
259
|
-
"topics",
|
|
260
|
-
"tos",
|
|
261
|
-
"tour",
|
|
262
|
-
"train",
|
|
263
|
-
"training",
|
|
264
|
-
"translations",
|
|
265
|
-
"tree",
|
|
266
|
-
"trending",
|
|
267
|
-
"updates",
|
|
268
|
-
"username",
|
|
269
|
-
"users",
|
|
270
|
-
"visualization",
|
|
271
|
-
"w",
|
|
272
|
-
"watching",
|
|
273
|
-
"wiki",
|
|
274
|
-
"windows",
|
|
275
|
-
"works-with",
|
|
276
|
-
"www0",
|
|
277
|
-
"www1",
|
|
278
|
-
"www2",
|
|
279
|
-
"www3",
|
|
280
|
-
"www4",
|
|
281
|
-
"www5",
|
|
282
|
-
"www6",
|
|
283
|
-
"www7",
|
|
284
|
-
"www8",
|
|
285
|
-
"www9"
|
|
286
|
-
];
|
|
287
|
-
const $ = (selector) => document.querySelector(selector);
|
|
288
|
-
const exists = (selector) => Boolean($(selector));
|
|
289
|
-
const is404 = () => /^(Page|File) not found · GitHub/.test(document.title);
|
|
290
|
-
const is500 = () => document.title === "Server Error · GitHub" || document.title === "Unicorn! · GitHub" || document.title === "504 Gateway Time-out";
|
|
291
|
-
const isPasswordConfirmation = () => document.title === "Confirm password" || document.title === "Confirm access";
|
|
292
|
-
const isLoggedIn = () => exists("body.logged-in");
|
|
293
|
-
const isBlame = (url = location) => Boolean(getRepo(url)?.path.startsWith("blame/"));
|
|
294
|
-
const isCommit = (url = location) => isSingleCommit(url) || isPRCommit(url);
|
|
295
|
-
const isCommitList = (url = location) => isRepoCommitList(url) || isPRCommitList(url);
|
|
296
|
-
const isRepoCommitList = (url = location) => Boolean(getRepo(url)?.path.startsWith("commits"));
|
|
297
|
-
const isCompare = (url = location) => Boolean(getRepo(url)?.path.startsWith("compare"));
|
|
298
|
-
const isCompareWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).split("/").slice(3, 5).includes("_compare");
|
|
299
|
-
const isDashboard = (url = location) => !isGist(url) && /^$|^(orgs\/[^/]+\/)?dashboard(-feed)?(\/|$)/.test(getCleanPathname(url));
|
|
300
|
-
const isEnterprise = (url = location) => url.hostname !== "github.com" && url.hostname !== "gist.github.com";
|
|
301
|
-
const isGist = (url = location) => typeof getCleanGistPathname(url) === "string";
|
|
302
|
-
const isGlobalIssueOrPRList = (url = location) => ["issues", "pulls"].includes(url.pathname.split("/", 2)[1]);
|
|
303
|
-
const isGlobalSearchResults = (url = location) => url.pathname === "/search" && new URLSearchParams(url.search).get("q") !== null;
|
|
304
|
-
const isIssue = (url = location) => /^issues\/\d+/.test(getRepo(url)?.path) && document.title !== "GitHub · Where software is built";
|
|
305
|
-
const isIssueOrPRList = (url = location) => isGlobalIssueOrPRList(url) || isRepoIssueOrPRList(url) || isMilestone(url);
|
|
306
|
-
const isConversation = (url = location) => isIssue(url) || isPRConversation(url);
|
|
307
|
-
const isLabelList = (url = location) => getRepo(url)?.path === "labels";
|
|
308
|
-
const isMilestone = (url = location) => /^milestone\/\d+/.test(getRepo(url)?.path);
|
|
309
|
-
const isMilestoneList = (url = location) => getRepo(url)?.path === "milestones";
|
|
310
|
-
const isNewFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("new"));
|
|
311
|
-
const isNewIssue = (url = location) => getRepo(url)?.path === "issues/new";
|
|
312
|
-
const isNewRelease = (url = location) => getRepo(url)?.path === "releases/new";
|
|
313
|
-
const isNewWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).endsWith("/_new");
|
|
314
|
-
const isNotifications = (url = location) => getCleanPathname(url) === "notifications";
|
|
315
|
-
const isOrganizationProfile = () => exists('meta[name="hovercard-subject-tag"][content^="organization"]');
|
|
316
|
-
const isOrganizationRepo = () => exists('.AppHeader-context-full [data-hovercard-type="organization"]');
|
|
317
|
-
const isTeamDiscussion = (url = location) => Boolean(getOrg(url)?.path.startsWith("teams"));
|
|
318
|
-
const isOwnUserProfile = () => getCleanPathname() === getUsername();
|
|
319
|
-
const isOwnOrganizationProfile = () => isOrganizationProfile() && !exists('[href*="contact/report-abuse?report="]');
|
|
320
|
-
const isProject = (url = location) => /^projects\/\d+/.test(getRepo(url)?.path);
|
|
321
|
-
const isProjects = (url = location) => getRepo(url)?.path === "projects";
|
|
322
|
-
const isDiscussion = (url = location) => /^discussions\/\d+/.test(getRepo(url)?.path ?? getOrg(url)?.path);
|
|
323
|
-
const isNewDiscussion = (url = location) => getRepo(url)?.path === "discussions/new" || getOrg(url)?.path === "discussions/new";
|
|
324
|
-
const isDiscussionList = (url = location) => getRepo(url)?.path === "discussions" || getOrg(url)?.path === "discussions";
|
|
325
|
-
const isPR = (url = location) => /^pull\/\d+/.test(getRepo(url)?.path) && !isPRConflicts(url);
|
|
326
|
-
const isPRConflicts = (url = location) => /^pull\/\d+\/conflicts/.test(getRepo(url)?.path);
|
|
327
|
-
const isPRList = (url = location) => url.pathname === "/pulls" || getRepo(url)?.path === "pulls";
|
|
328
|
-
const isPRCommit = (url = location) => /^pull\/\d+\/commits\/[\da-f]{5,40}$/.test(getRepo(url)?.path);
|
|
329
|
-
const isPRCommit404 = () => isPRCommit() && document.title.startsWith("Commit range not found · Pull Request");
|
|
330
|
-
const isPRFile404 = () => isPRFiles() && document.title.startsWith("Commit range not found · Pull Request");
|
|
331
|
-
const isPRConversation = (url = location) => /^pull\/\d+$/.test(getRepo(url)?.path);
|
|
332
|
-
const isPRCommitList = (url = location) => /^pull\/\d+\/commits$/.test(getRepo(url)?.path);
|
|
333
|
-
const isPRFiles = (url = location) => /^pull\/\d+\/files/.test(getRepo(url)?.path) || isPRCommit(url);
|
|
334
|
-
const isQuickPR = (url = location) => isCompare(url) && /[?&]quick_pull=1(&|$)/.test(url.search);
|
|
335
|
-
const isDraftPR = () => exists("#partial-discussion-header .octicon-git-pull-request-draft");
|
|
336
|
-
const isOpenPR = () => exists("#partial-discussion-header :is(.octicon-git-pull-request, .octicon-git-pull-request-draft)");
|
|
337
|
-
const isMergedPR = () => exists("#partial-discussion-header .octicon-git-merge");
|
|
338
|
-
const isClosedPR = () => exists("#partial-discussion-header :is(.octicon-git-pull-request-closed, .octicon-git-merge)");
|
|
339
|
-
const isClosedIssue = () => exists("#partial-discussion-header :is(.octicon-issue-closed, .octicon-skip)");
|
|
340
|
-
const isReleases = (url = location) => getRepo(url)?.path === "releases";
|
|
341
|
-
const isTags = (url = location) => getRepo(url)?.path === "tags";
|
|
342
|
-
const isSingleReleaseOrTag = (url = location) => Boolean(getRepo(url)?.path.startsWith("releases/tag"));
|
|
343
|
-
const isReleasesOrTags = (url = location) => isReleases(url) || isTags(url);
|
|
344
|
-
const isDeletingFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("delete"));
|
|
345
|
-
const isEditingFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("edit"));
|
|
346
|
-
const hasFileEditor = (url = location) => isEditingFile(url) || isNewFile(url) || isDeletingFile(url);
|
|
347
|
-
const isEditingRelease = (url = location) => Boolean(getRepo(url)?.path.startsWith("releases/edit"));
|
|
348
|
-
const hasReleaseEditor = (url = location) => isEditingRelease(url) || isNewRelease(url);
|
|
349
|
-
const isEditingWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).endsWith("/_edit");
|
|
350
|
-
const hasWikiPageEditor = (url = location) => isEditingWikiPage(url) || isNewWikiPage(url);
|
|
351
|
-
const isRepo = (url = location) => /^[^/]+\/[^/]+/.test(getCleanPathname(url)) && !reservedNames.includes(url.pathname.split("/", 2)[1]) && !isDashboard(url) && !isGist(url) && !isNewRepoTemplate(url);
|
|
352
|
-
const hasRepoHeader = (url = location) => isRepo(url) && !isRepoSearch(url);
|
|
353
|
-
const isEmptyRepoRoot = () => isRepoHome() && !exists('link[rel="canonical"]');
|
|
354
|
-
const isEmptyRepo = () => exists('[aria-label="Cannot fork because repository is empty."]');
|
|
355
|
-
const isPublicRepo = () => exists('meta[name="octolytics-dimension-repository_public"][content="true"]');
|
|
356
|
-
const isArchivedRepo = () => Boolean(isRepo() && $("main > .flash-warn")?.textContent.includes("archived"));
|
|
357
|
-
const isBlank = () => exists("main .blankslate:not([hidden] .blankslate)");
|
|
358
|
-
const isRepoTaxonomyIssueOrPRList = (url = location) => /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(getRepo(url)?.path);
|
|
359
|
-
const isRepoIssueOrPRList = (url = location) => isRepoPRList(url) || isRepoIssueList(url) || isRepoTaxonomyIssueOrPRList(url);
|
|
360
|
-
const isRepoPRList = (url = location) => Boolean(getRepo(url)?.path.startsWith("pulls"));
|
|
361
|
-
const isRepoIssueList = (url = location) => (
|
|
1
|
+
// index.ts
|
|
2
|
+
import reservedNames from "github-reserved-names/reserved-names.json" with { type: "json" };
|
|
3
|
+
var $ = (selector) => document.querySelector(selector);
|
|
4
|
+
var exists = (selector) => Boolean($(selector));
|
|
5
|
+
var is404 = () => /^(Page|File) not found · GitHub/.test(document.title);
|
|
6
|
+
var is500 = () => document.title === "Server Error \xB7 GitHub" || document.title === "Unicorn! \xB7 GitHub" || document.title === "504 Gateway Time-out";
|
|
7
|
+
var isPasswordConfirmation = () => document.title === "Confirm password" || document.title === "Confirm access";
|
|
8
|
+
var isLoggedIn = () => exists("body.logged-in");
|
|
9
|
+
var isBlame = (url = location) => Boolean(getRepo(url)?.path.startsWith("blame/"));
|
|
10
|
+
var isCommit = (url = location) => isSingleCommit(url) || isPRCommit(url);
|
|
11
|
+
var isCommitList = (url = location) => isRepoCommitList(url) || isPRCommitList(url);
|
|
12
|
+
var isRepoCommitList = (url = location) => Boolean(getRepo(url)?.path.startsWith("commits"));
|
|
13
|
+
var isCompare = (url = location) => Boolean(getRepo(url)?.path.startsWith("compare"));
|
|
14
|
+
var isCompareWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).split("/").slice(3, 5).includes("_compare");
|
|
15
|
+
var isDashboard = (url = location) => !isGist(url) && /^$|^(orgs\/[^/]+\/)?dashboard(-feed)?(\/|$)/.test(getCleanPathname(url));
|
|
16
|
+
var isEnterprise = (url = location) => url.hostname !== "github.com" && url.hostname !== "gist.github.com";
|
|
17
|
+
var isGist = (url = location) => typeof getCleanGistPathname(url) === "string";
|
|
18
|
+
var isGlobalIssueOrPRList = (url = location) => ["issues", "pulls"].includes(url.pathname.split("/", 2)[1]);
|
|
19
|
+
var isGlobalSearchResults = (url = location) => url.pathname === "/search" && new URLSearchParams(url.search).get("q") !== null;
|
|
20
|
+
var isIssue = (url = location) => /^issues\/\d+/.test(getRepo(url)?.path) && document.title !== "GitHub \xB7 Where software is built";
|
|
21
|
+
var isIssueOrPRList = (url = location) => isGlobalIssueOrPRList(url) || isRepoIssueOrPRList(url) || isMilestone(url);
|
|
22
|
+
var isConversation = (url = location) => isIssue(url) || isPRConversation(url);
|
|
23
|
+
var isLabelList = (url = location) => getRepo(url)?.path === "labels";
|
|
24
|
+
var isMilestone = (url = location) => /^milestone\/\d+/.test(getRepo(url)?.path);
|
|
25
|
+
var isMilestoneList = (url = location) => getRepo(url)?.path === "milestones";
|
|
26
|
+
var isNewFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("new"));
|
|
27
|
+
var isNewIssue = (url = location) => getRepo(url)?.path === "issues/new";
|
|
28
|
+
var isNewRelease = (url = location) => getRepo(url)?.path === "releases/new";
|
|
29
|
+
var isNewWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).endsWith("/_new");
|
|
30
|
+
var isNotifications = (url = location) => getCleanPathname(url) === "notifications";
|
|
31
|
+
var isOrganizationProfile = () => exists('meta[name="hovercard-subject-tag"][content^="organization"]');
|
|
32
|
+
var isOrganizationRepo = () => exists('.AppHeader-context-full [data-hovercard-type="organization"]');
|
|
33
|
+
var isTeamDiscussion = (url = location) => Boolean(getOrg(url)?.path.startsWith("teams"));
|
|
34
|
+
var isOwnUserProfile = () => getCleanPathname() === getUsername();
|
|
35
|
+
var isOwnOrganizationProfile = () => isOrganizationProfile() && !exists('[href*="contact/report-abuse?report="]');
|
|
36
|
+
var isProject = (url = location) => /^projects\/\d+/.test(getRepo(url)?.path);
|
|
37
|
+
var isProjects = (url = location) => getRepo(url)?.path === "projects";
|
|
38
|
+
var isDiscussion = (url = location) => /^discussions\/\d+/.test(getRepo(url)?.path ?? getOrg(url)?.path);
|
|
39
|
+
var isNewDiscussion = (url = location) => getRepo(url)?.path === "discussions/new" || getOrg(url)?.path === "discussions/new";
|
|
40
|
+
var isDiscussionList = (url = location) => getRepo(url)?.path === "discussions" || getOrg(url)?.path === "discussions";
|
|
41
|
+
var isPR = (url = location) => /^pull\/\d+/.test(getRepo(url)?.path) && !isPRConflicts(url);
|
|
42
|
+
var isPRConflicts = (url = location) => /^pull\/\d+\/conflicts/.test(getRepo(url)?.path);
|
|
43
|
+
var isPRList = (url = location) => url.pathname === "/pulls" || getRepo(url)?.path === "pulls";
|
|
44
|
+
var isPRCommit = (url = location) => /^pull\/\d+\/commits\/[\da-f]{5,40}$/.test(getRepo(url)?.path);
|
|
45
|
+
var isPRCommit404 = () => isPRCommit() && document.title.startsWith("Commit range not found \xB7 Pull Request");
|
|
46
|
+
var isPRFile404 = () => isPRFiles() && document.title.startsWith("Commit range not found \xB7 Pull Request");
|
|
47
|
+
var isPRConversation = (url = location) => /^pull\/\d+$/.test(getRepo(url)?.path);
|
|
48
|
+
var isPRCommitList = (url = location) => /^pull\/\d+\/commits$/.test(getRepo(url)?.path);
|
|
49
|
+
var isPRFiles = (url = location) => /^pull\/\d+\/files/.test(getRepo(url)?.path) || isPRCommit(url);
|
|
50
|
+
var isQuickPR = (url = location) => isCompare(url) && /[?&]quick_pull=1(&|$)/.test(url.search);
|
|
51
|
+
var isDraftPR = () => exists("#partial-discussion-header .octicon-git-pull-request-draft");
|
|
52
|
+
var isOpenPR = () => exists("#partial-discussion-header :is(.octicon-git-pull-request, .octicon-git-pull-request-draft)");
|
|
53
|
+
var isMergedPR = () => exists("#partial-discussion-header .octicon-git-merge");
|
|
54
|
+
var isClosedPR = () => exists("#partial-discussion-header :is(.octicon-git-pull-request-closed, .octicon-git-merge)");
|
|
55
|
+
var isClosedIssue = () => exists("#partial-discussion-header :is(.octicon-issue-closed, .octicon-skip)");
|
|
56
|
+
var isReleases = (url = location) => getRepo(url)?.path === "releases";
|
|
57
|
+
var isTags = (url = location) => getRepo(url)?.path === "tags";
|
|
58
|
+
var isSingleReleaseOrTag = (url = location) => Boolean(getRepo(url)?.path.startsWith("releases/tag"));
|
|
59
|
+
var isReleasesOrTags = (url = location) => isReleases(url) || isTags(url);
|
|
60
|
+
var isDeletingFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("delete"));
|
|
61
|
+
var isEditingFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("edit"));
|
|
62
|
+
var hasFileEditor = (url = location) => isEditingFile(url) || isNewFile(url) || isDeletingFile(url);
|
|
63
|
+
var isEditingRelease = (url = location) => Boolean(getRepo(url)?.path.startsWith("releases/edit"));
|
|
64
|
+
var hasReleaseEditor = (url = location) => isEditingRelease(url) || isNewRelease(url);
|
|
65
|
+
var isEditingWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).endsWith("/_edit");
|
|
66
|
+
var hasWikiPageEditor = (url = location) => isEditingWikiPage(url) || isNewWikiPage(url);
|
|
67
|
+
var isRepo = (url = location) => /^[^/]+\/[^/]+/.test(getCleanPathname(url)) && !reservedNames.includes(url.pathname.split("/", 2)[1]) && !isDashboard(url) && !isGist(url) && !isNewRepoTemplate(url);
|
|
68
|
+
var hasRepoHeader = (url = location) => isRepo(url) && !isRepoSearch(url);
|
|
69
|
+
var isEmptyRepoRoot = () => isRepoHome() && !exists('link[rel="canonical"]');
|
|
70
|
+
var isEmptyRepo = () => exists('[aria-label="Cannot fork because repository is empty."]');
|
|
71
|
+
var isPublicRepo = () => exists('meta[name="octolytics-dimension-repository_public"][content="true"]');
|
|
72
|
+
var isArchivedRepo = () => Boolean(isRepo() && $("main > .flash-warn")?.textContent.includes("archived"));
|
|
73
|
+
var isBlank = () => exists("main .blankslate:not([hidden] .blankslate)");
|
|
74
|
+
var isRepoTaxonomyIssueOrPRList = (url = location) => /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(getRepo(url)?.path);
|
|
75
|
+
var isRepoIssueOrPRList = (url = location) => isRepoPRList(url) || isRepoIssueList(url) || isRepoTaxonomyIssueOrPRList(url);
|
|
76
|
+
var isRepoPRList = (url = location) => Boolean(getRepo(url)?.path.startsWith("pulls"));
|
|
77
|
+
var isRepoIssueList = (url = location) => (
|
|
362
78
|
// `issues/fregante` is a list but `issues/1`, `issues/new`, `issues/new/choose`, `issues/templates/edit` aren’t
|
|
363
79
|
/^labels\/|^issues(?!\/(\d+|new|templates)($|\/))/.test(getRepo(url)?.path)
|
|
364
80
|
);
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
81
|
+
var hasSearchParameter = (url) => new URLSearchParams(url.search).get("search") === "1";
|
|
82
|
+
var isRepoHome = (url = location) => getRepo(url)?.path === "" && !hasSearchParameter(url);
|
|
83
|
+
var _isRepoRoot = (url) => {
|
|
368
84
|
const repository = getRepo(url ?? location);
|
|
369
85
|
if (!repository) {
|
|
370
86
|
return false;
|
|
@@ -377,52 +93,52 @@ const _isRepoRoot = (url) => {
|
|
|
377
93
|
}
|
|
378
94
|
return repository.path.startsWith("tree/") && document.title.startsWith(repository.nameWithOwner) && !document.title.endsWith(repository.nameWithOwner);
|
|
379
95
|
};
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
96
|
+
var isRepoRoot = (url) => !hasSearchParameter(url ?? location) && _isRepoRoot(url);
|
|
97
|
+
var isRepoSearch = (url = location) => getRepo(url)?.path === "search";
|
|
98
|
+
var isRepoSettings = (url = location) => Boolean(getRepo(url)?.path.startsWith("settings"));
|
|
99
|
+
var isRepoMainSettings = (url = location) => getRepo(url)?.path === "settings";
|
|
100
|
+
var isRepliesSettings = (url = location) => url.pathname.startsWith("/settings/replies");
|
|
101
|
+
var isUserSettings = (url = location) => url.pathname.startsWith("/settings/");
|
|
102
|
+
var isRepoTree = (url = location) => _isRepoRoot(url) || Boolean(getRepo(url)?.path.startsWith("tree/"));
|
|
103
|
+
var isRepoWiki = (url = location) => Boolean(getRepo(url)?.path.startsWith("wiki"));
|
|
104
|
+
var isSingleCommit = (url = location) => /^commit\/[\da-f]{5,40}$/.test(getRepo(url)?.path);
|
|
105
|
+
var isSingleFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("blob/"));
|
|
106
|
+
var isFileFinder = (url = location) => Boolean(getRepo(url)?.path.startsWith("find/"));
|
|
107
|
+
var isRepoFile404 = (url = location) => (isSingleFile(url) || isRepoTree(url)) && document.title.startsWith("File not found");
|
|
108
|
+
var isRepoForksList = (url = location) => getRepo(url)?.path === "network/members";
|
|
109
|
+
var isRepoNetworkGraph = (url = location) => getRepo(url)?.path === "network";
|
|
110
|
+
var isForkedRepo = () => exists('meta[name="octolytics-dimension-repository_is_fork"][content="true"]');
|
|
111
|
+
var isSingleGist = (url = location) => /^[^/]+\/[\da-f]{20,32}(\/[\da-f]{40})?$/.test(getCleanGistPathname(url));
|
|
112
|
+
var isGistRevision = (url = location) => /^[^/]+\/[\da-f]{20,32}\/revisions$/.test(getCleanGistPathname(url));
|
|
113
|
+
var isTrending = (url = location) => url.pathname === "/trending" || url.pathname.startsWith("/trending/");
|
|
114
|
+
var isBranches = (url = location) => Boolean(getRepo(url)?.path.startsWith("branches"));
|
|
115
|
+
var doesLookLikeAProfile = (string) => typeof string === "string" && string.length > 0 && !string.includes("/") && !string.includes(".") && !reservedNames.includes(string);
|
|
116
|
+
var isProfile = (url = location) => !isGist(url) && doesLookLikeAProfile(getCleanPathname(url));
|
|
117
|
+
var isGistProfile = (url = location) => doesLookLikeAProfile(getCleanGistPathname(url));
|
|
118
|
+
var isUserProfile = () => isProfile() && !isOrganizationProfile();
|
|
119
|
+
var isPrivateUserProfile = () => isUserProfile() && !exists('.UnderlineNav-item[href$="tab=stars"]');
|
|
120
|
+
var isUserProfileMainTab = () => isUserProfile() && !new URLSearchParams(location.search).has("tab");
|
|
121
|
+
var isUserProfileRepoTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "repositories";
|
|
122
|
+
var isUserProfileStarsTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "stars";
|
|
123
|
+
var isUserProfileFollowersTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "followers";
|
|
124
|
+
var isUserProfileFollowingTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "following";
|
|
125
|
+
var isProfileRepoList = (url = location) => isUserProfileRepoTab(url) || getOrg(url)?.path === "repositories";
|
|
126
|
+
var hasComments = (url = location) => isPR(url) || isIssue(url) || isCommit(url) || isTeamDiscussion(url) || isSingleGist(url);
|
|
127
|
+
var hasRichTextEditor = (url = location) => hasComments(url) || isNewIssue(url) || isCompare(url) || isRepliesSettings(url) || hasReleaseEditor(url) || isDiscussion(url) || isNewDiscussion(url);
|
|
128
|
+
var hasCode = (url = location) => hasComments(url) || isRepoTree(url) || isRepoSearch(url) || isGlobalSearchResults(url) || isSingleFile(url) || isGist(url) || isCompare(url) || isCompareWikiPage(url) || isBlame(url);
|
|
129
|
+
var hasFiles = (url = location) => isCommit(url) || isCompare(url) || isPRFiles(url);
|
|
130
|
+
var isMarketplaceAction = (url = location) => url.pathname.startsWith("/marketplace/actions/");
|
|
131
|
+
var isActionJobRun = (url = location) => Boolean(getRepo(url)?.path.startsWith("runs/"));
|
|
132
|
+
var isActionRun = (url = location) => /^(actions\/)?runs/.test(getRepo(url)?.path);
|
|
133
|
+
var isNewAction = (url = location) => getRepo(url)?.path === "actions/new";
|
|
134
|
+
var isRepositoryActions = (url = location) => /^actions(\/workflows\/.+\.ya?ml)?$/.test(getRepo(url)?.path);
|
|
135
|
+
var isUserTheOrganizationOwner = () => isOrganizationProfile() && exists('[aria-label="Organization"] [data-tab-item="org-header-settings-tab"]');
|
|
136
|
+
var canUserEditRepo = () => isRepo() && exists('.reponav-item[href$="/settings"], [data-tab-item$="settings-tab"]');
|
|
137
|
+
var isNewRepo = (url = location) => url.pathname === "/new" || /^organizations\/[^/]+\/repositories\/new$/.test(getCleanPathname(url));
|
|
138
|
+
var isNewRepoTemplate = (url = location) => Boolean(url.pathname.split("/")[3] === "generate");
|
|
139
|
+
var getUsername = () => $('meta[name="user-login"]')?.getAttribute("content") ?? void 0;
|
|
140
|
+
var getCleanPathname = (url = location) => url.pathname.replaceAll(/\/+/g, "/").slice(1, url.pathname.endsWith("/") ? -1 : void 0);
|
|
141
|
+
var getCleanGistPathname = (url = location) => {
|
|
426
142
|
const pathname = getCleanPathname(url);
|
|
427
143
|
if (url.hostname.startsWith("gist.")) {
|
|
428
144
|
return pathname;
|
|
@@ -430,14 +146,14 @@ const getCleanGistPathname = (url = location) => {
|
|
|
430
146
|
const [gist, ...parts] = pathname.split("/");
|
|
431
147
|
return gist === "gist" ? parts.join("/") : void 0;
|
|
432
148
|
};
|
|
433
|
-
|
|
149
|
+
var getOrg = (url = location) => {
|
|
434
150
|
const [, orgs, name, ...path] = url.pathname.split("/");
|
|
435
151
|
if (orgs === "orgs" && name) {
|
|
436
152
|
return { name, path: path.join("/") };
|
|
437
153
|
}
|
|
438
154
|
return void 0;
|
|
439
155
|
};
|
|
440
|
-
|
|
156
|
+
var getRepo = (url) => {
|
|
441
157
|
if (!url) {
|
|
442
158
|
const canonical = $('[property="og:url"]');
|
|
443
159
|
if (canonical) {
|
|
@@ -461,7 +177,7 @@ const getRepo = (url) => {
|
|
|
461
177
|
path: path.join("/")
|
|
462
178
|
};
|
|
463
179
|
};
|
|
464
|
-
|
|
180
|
+
var utils = {
|
|
465
181
|
getOrg,
|
|
466
182
|
getUsername,
|
|
467
183
|
getCleanPathname,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-url-detection",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Which GitHub page are you on? Is it an issue? Is it a list? Perfect for your WebExtension or userscript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "run-p build:*",
|
|
28
|
-
"build:
|
|
28
|
+
"build:esbuild": "esbuild index.ts --bundle --external:github-reserved-names --outdir=distribution --format=esm --drop-labels=TEST",
|
|
29
29
|
"build:typescript": "tsc --declaration --emitDeclarationOnly",
|
|
30
30
|
"build:demo": "vite build demo",
|
|
31
31
|
"prepack": "npm run build",
|
|
@@ -49,15 +49,20 @@
|
|
|
49
49
|
],
|
|
50
50
|
"rules": {
|
|
51
51
|
"@typescript-eslint/triple-slash-reference": "off",
|
|
52
|
-
"@typescript-eslint/naming-convention": "off"
|
|
52
|
+
"@typescript-eslint/naming-convention": "off",
|
|
53
|
+
"no-unused-labels": "off",
|
|
54
|
+
"no-labels": "off"
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
]
|
|
56
58
|
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"github-reserved-names": "^2.0.5"
|
|
61
|
+
},
|
|
57
62
|
"devDependencies": {
|
|
58
63
|
"@sindresorhus/tsconfig": "^5.0.0",
|
|
59
64
|
"@sveltejs/vite-plugin-svelte": "^3.1.1",
|
|
60
|
-
"
|
|
65
|
+
"esbuild": "^0.21.5",
|
|
61
66
|
"npm-run-all": "^4.1.5",
|
|
62
67
|
"strip-indent": "^4.0.0",
|
|
63
68
|
"svelte": "^4.2.17",
|
|
@@ -68,6 +73,6 @@
|
|
|
68
73
|
"xo": "^0.58.0"
|
|
69
74
|
},
|
|
70
75
|
"engines": {
|
|
71
|
-
"node": ">=
|
|
76
|
+
"node": ">=20.10"
|
|
72
77
|
}
|
|
73
78
|
}
|