github-url-detection 6.0.0 → 6.1.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.
@@ -0,0 +1,132 @@
1
+ export declare const is404: () => boolean;
2
+ export declare const is500: () => boolean;
3
+ export declare const isPasswordConfirmation: () => boolean;
4
+ export declare const isBlame: (url?: URL | HTMLAnchorElement | Location) => boolean;
5
+ export declare const isCommit: (url?: URL | HTMLAnchorElement | Location) => boolean;
6
+ export declare const isCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean;
7
+ export declare const isRepoCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean;
8
+ export declare const isCompare: (url?: URL | HTMLAnchorElement | Location) => boolean;
9
+ export declare const isCompareWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
10
+ export declare const isDashboard: (url?: URL | HTMLAnchorElement | Location) => boolean;
11
+ export declare const isEnterprise: (url?: URL | HTMLAnchorElement | Location) => boolean;
12
+ export declare const isGist: (url?: URL | HTMLAnchorElement | Location) => boolean;
13
+ export declare const isGlobalIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
14
+ export declare const isGlobalSearchResults: (url?: URL | HTMLAnchorElement | Location) => boolean;
15
+ export declare const isIssue: (url?: URL | HTMLAnchorElement | Location) => boolean;
16
+ export declare const isIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
17
+ export declare const isConversation: (url?: URL | HTMLAnchorElement | Location) => boolean;
18
+ export declare const isLabelList: (url?: URL | HTMLAnchorElement | Location) => boolean;
19
+ export declare const isMilestone: (url?: URL | HTMLAnchorElement | Location) => boolean;
20
+ export declare const isMilestoneList: (url?: URL | HTMLAnchorElement | Location) => boolean;
21
+ export declare const isNewFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
22
+ export declare const isNewIssue: (url?: URL | HTMLAnchorElement | Location) => boolean;
23
+ export declare const isNewRelease: (url?: URL | HTMLAnchorElement | Location) => boolean;
24
+ export declare const isNewWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
25
+ export declare const isNotifications: (url?: URL | HTMLAnchorElement | Location) => boolean;
26
+ export declare const isOrganizationProfile: () => boolean;
27
+ export declare const isOrganizationRepo: () => boolean;
28
+ export declare const isTeamDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean;
29
+ export declare const isOwnUserProfile: () => boolean;
30
+ export declare const isOwnOrganizationProfile: () => boolean;
31
+ export declare const isProject: (url?: URL | HTMLAnchorElement | Location) => boolean;
32
+ export declare const isProjects: (url?: URL | HTMLAnchorElement | Location) => boolean;
33
+ export declare const isDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean;
34
+ export declare const isDiscussionList: (url?: URL | HTMLAnchorElement | Location) => boolean;
35
+ export declare const isPR: (url?: URL | HTMLAnchorElement | Location) => boolean;
36
+ export declare const isPRConflicts: (url?: URL | HTMLAnchorElement | Location) => boolean;
37
+ /** Any `isIssueOrPRList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown */
38
+ export declare const isPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
39
+ export declare const isPRCommit: (url?: URL | HTMLAnchorElement | Location) => boolean;
40
+ export declare const isPRCommit404: () => boolean;
41
+ export declare const isPRFile404: () => boolean;
42
+ export declare const isPRConversation: (url?: URL | HTMLAnchorElement | Location) => boolean;
43
+ export declare const isPRCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean;
44
+ export declare const isPRFiles: (url?: URL | HTMLAnchorElement | Location) => boolean;
45
+ export declare const isQuickPR: (url?: URL | HTMLAnchorElement | Location) => boolean;
46
+ export declare const isDraftPR: () => boolean;
47
+ export declare const isOpenPR: () => boolean;
48
+ export declare const isMergedPR: () => boolean;
49
+ export declare const isClosedPR: () => boolean;
50
+ export declare const isClosedIssue: () => boolean;
51
+ export declare const isReleases: (url?: URL | HTMLAnchorElement | Location) => boolean;
52
+ export declare const isTags: (url?: URL | HTMLAnchorElement | Location) => boolean;
53
+ export declare const isSingleTag: (url?: URL | HTMLAnchorElement | Location) => boolean;
54
+ export declare const isReleasesOrTags: (url?: URL | HTMLAnchorElement | Location) => boolean;
55
+ export declare const isDeletingFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
56
+ export declare const isEditingFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
57
+ export declare const hasFileEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
58
+ export declare const isEditingRelease: (url?: URL | HTMLAnchorElement | Location) => boolean;
59
+ export declare const hasReleaseEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
60
+ export declare const isEditingWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
61
+ export declare const hasWikiPageEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
62
+ export declare const isRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
63
+ export declare const hasRepoHeader: (url?: URL | HTMLAnchorElement | Location) => boolean;
64
+ export declare const isEmptyRepoRoot: () => boolean;
65
+ export declare const isEmptyRepo: () => boolean;
66
+ export declare const isPublicRepo: () => boolean;
67
+ export declare const isArchivedRepo: () => boolean;
68
+ export declare const isBlank: () => boolean;
69
+ export declare const isRepoTaxonomyIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
70
+ export declare const isRepoIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
71
+ export declare const isRepoPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
72
+ export declare const isRepoIssueList: (url?: URL | HTMLAnchorElement | Location) => boolean;
73
+ export declare const isRepoHome: (url?: URL | HTMLAnchorElement | Location) => boolean;
74
+ export declare const isRepoRoot: (url?: URL | HTMLAnchorElement | Location) => boolean;
75
+ export declare const isRepoSearch: (url?: URL | HTMLAnchorElement | Location) => boolean;
76
+ export declare const isRepoSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
77
+ export declare const isRepoMainSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
78
+ export declare const isRepliesSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
79
+ export declare const isUserSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
80
+ export declare const isRepoTree: (url?: URL | HTMLAnchorElement | Location) => boolean;
81
+ export declare const isRepoWiki: (url?: URL | HTMLAnchorElement | Location) => boolean;
82
+ export declare const isSingleCommit: (url?: URL | HTMLAnchorElement | Location) => boolean;
83
+ export declare const isSingleFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
84
+ export declare const isFileFinder: (url?: URL | HTMLAnchorElement | Location) => boolean;
85
+ export declare const isRepoForksList: (url?: URL | HTMLAnchorElement | Location) => boolean;
86
+ export declare const isRepoNetworkGraph: (url?: URL | HTMLAnchorElement | Location) => boolean;
87
+ export declare const isForkedRepo: () => boolean;
88
+ export declare const isSingleGist: (url?: URL | HTMLAnchorElement | Location) => boolean;
89
+ export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location) => boolean;
90
+ export declare const isTrending: (url?: URL | HTMLAnchorElement | Location) => boolean;
91
+ export declare const isBranches: (url?: URL | HTMLAnchorElement | Location) => boolean;
92
+ export declare const isProfile: (url?: URL | HTMLAnchorElement | Location) => boolean;
93
+ export declare const isGistProfile: (url?: URL | HTMLAnchorElement | Location) => boolean;
94
+ export declare const isUserProfile: () => boolean;
95
+ export declare const isPrivateUserProfile: () => boolean;
96
+ export declare const isUserProfileMainTab: () => boolean;
97
+ export declare const isUserProfileRepoTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
98
+ export declare const isUserProfileStarsTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
99
+ export declare const isUserProfileFollowersTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
100
+ export declare const isUserProfileFollowingTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
101
+ export declare const hasComments: (url?: URL | HTMLAnchorElement | Location) => boolean;
102
+ export declare const hasRichTextEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
103
+ /** Static code, not the code editor */
104
+ export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => boolean;
105
+ /** Has a list of files */
106
+ export declare const hasFiles: (url?: URL | HTMLAnchorElement | Location) => boolean;
107
+ export declare const isMarketplaceAction: (url?: URL | HTMLAnchorElement | Location) => boolean;
108
+ export declare const isActionJobRun: (url?: URL | HTMLAnchorElement | Location) => boolean;
109
+ export declare const isActionRun: (url?: URL | HTMLAnchorElement | Location) => boolean;
110
+ export declare const isNewAction: (url?: URL | HTMLAnchorElement | Location) => boolean;
111
+ export declare const isRepositoryActions: (url?: URL | HTMLAnchorElement | Location) => boolean;
112
+ export declare const isUserTheOrganizationOwner: () => boolean;
113
+ export declare const canUserEditRepo: () => boolean;
114
+ export declare const isNewRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
115
+ export declare const isNewRepoTemplate: (url?: URL | HTMLAnchorElement | Location) => boolean;
116
+ export interface RepositoryInfo {
117
+ owner: string;
118
+ name: string;
119
+ /** The 'user/repo' part from an URL */
120
+ nameWithOwner: string;
121
+ /** A repo's subpage
122
+ @example '/user/repo/issues/' -> 'issues'
123
+ @example '/user/repo/' -> ''
124
+ @example '/settings/token/' -> undefined */
125
+ path: string;
126
+ }
127
+ export declare const utils: {
128
+ getUsername: () => string | undefined;
129
+ getCleanPathname: (url?: URL | HTMLAnchorElement | Location) => string;
130
+ getCleanGistPathname: (url?: URL | HTMLAnchorElement | Location) => string | undefined;
131
+ getRepositoryInfo: (url?: URL | HTMLAnchorElement | Location | string) => RepositoryInfo | undefined;
132
+ };
@@ -342,6 +342,7 @@ const isRepo = (url = location) => /^[^/]+\/[^/]+/.test(getCleanPathname(url)) &
342
342
  const hasRepoHeader = (url = location) => isRepo(url) && !isRepoSearch(url);
343
343
  const isEmptyRepoRoot = () => isRepoHome() && !exists('link[rel="canonical"]');
344
344
  const isEmptyRepo = () => exists('[aria-label="Cannot fork because repository is empty."]');
345
+ const isPublicRepo = () => Boolean(isRepo() && $("#repository-container-header .Label").textContent.startsWith("Public"));
345
346
  const isArchivedRepo = () => Boolean(isRepo() && $("#repository-container-header .Label").textContent.endsWith("archive"));
346
347
  const isBlank = () => exists("main .blankslate");
347
348
  const isRepoTaxonomyIssueOrPRList = (url = location) => /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(getRepo(url)?.path);
@@ -383,7 +384,7 @@ const doesLookLikeAProfile = (string) => typeof string === "string" && string.le
383
384
  const isProfile = (url = location) => !isGist(url) && doesLookLikeAProfile(getCleanPathname(url));
384
385
  const isGistProfile = (url = location) => doesLookLikeAProfile(getCleanGistPathname(url));
385
386
  const isUserProfile = () => isProfile() && !isOrganizationProfile();
386
- const isPrivateUserProfile = () => isUserProfile() && !exists(".user-following-container");
387
+ const isPrivateUserProfile = () => isUserProfile() && !exists('.UnderlineNav-item[href$="tab=stars"]');
387
388
  const isUserProfileMainTab = () => isUserProfile() && !new URLSearchParams(location.search).has("tab");
388
389
  const isUserProfileRepoTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "repositories";
389
390
  const isUserProfileStarsTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "stars";
@@ -519,6 +520,7 @@ export {
519
520
  isProfile,
520
521
  isProject,
521
522
  isProjects,
523
+ isPublicRepo,
522
524
  isQuickPR,
523
525
  isReleases,
524
526
  isReleasesOrTags,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-url-detection",
3
- "version": "6.0.0",
3
+ "version": "6.1.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",
@@ -30,7 +30,7 @@
30
30
  "demo:build": "vite build demo --config demo/vite.config.js",
31
31
  "demo:test": "svelte-check",
32
32
  "demo:watch": "vite serve demo --config demo/vite.config.js",
33
- "prepack": "vite build",
33
+ "prepack": "npm run build",
34
34
  "test": "run-p build ava xo",
35
35
  "watch": "run-p watch:typescript demo:watch # vite watch doesn’t generate the lib, so just use the demo",
36
36
  "watch:typescript": "tsc --watch --noEmit",