github-url-detection 9.0.1 → 9.0.3

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.
@@ -118,6 +118,8 @@ export declare const isActionRun: (url?: URL | HTMLAnchorElement | Location) =>
118
118
  export declare const isNewAction: (url?: URL | HTMLAnchorElement | Location) => boolean;
119
119
  export declare const isRepositoryActions: (url?: URL | HTMLAnchorElement | Location) => boolean;
120
120
  export declare const isUserTheOrganizationOwner: () => boolean;
121
+ export declare const canUserAdminRepo: () => boolean;
122
+ /** @deprecated Use `canUserAdminRepo` */
121
123
  export declare const canUserEditRepo: () => boolean;
122
124
  export declare const isNewRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
123
125
  export declare const isNewRepoTemplate: (url?: URL | HTMLAnchorElement | Location) => boolean;
@@ -48,11 +48,33 @@ var isPRConversation = (url = location) => /^pull\/\d+$/.test(getRepo(url)?.path
48
48
  var isPRCommitList = (url = location) => /^pull\/\d+\/commits$/.test(getRepo(url)?.path);
49
49
  var isPRFiles = (url = location) => /^pull\/\d+\/files/.test(getRepo(url)?.path) || isPRCommit(url);
50
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)");
51
+ var stateSelector = [
52
+ ".State",
53
+ '[data-testid="header-state"]'
54
+ ].join(",");
55
+ var isDraftPR = () => $(stateSelector)?.textContent.trim() === "Draft";
56
+ var isOpenPR = () => {
57
+ if (!isPR()) {
58
+ return false;
59
+ }
60
+ const status = $(stateSelector).textContent.trim();
61
+ return status === "Open" || status === "Draft";
62
+ };
63
+ var isMergedPR = () => $(stateSelector)?.textContent.trim() === "Merged";
64
+ var isClosedPR = () => {
65
+ if (!isPR()) {
66
+ return false;
67
+ }
68
+ const status = $(stateSelector).textContent.trim();
69
+ return status === "Closed" || status === "Merged";
70
+ };
71
+ var isClosedIssue = () => {
72
+ if (!isIssue()) {
73
+ return false;
74
+ }
75
+ const status = $(stateSelector).textContent.trim();
76
+ return status === "Closed" || status === "Closed as not planned";
77
+ };
56
78
  var isReleases = (url = location) => getRepo(url)?.path === "releases";
57
79
  var isTags = (url = location) => getRepo(url)?.path === "tags";
58
80
  var isSingleReleaseOrTag = (url = location) => Boolean(getRepo(url)?.path.startsWith("releases/tag"));
@@ -139,7 +161,8 @@ var isActionRun = (url = location) => /^(actions\/)?runs/.test(getRepo(url)?.pat
139
161
  var isNewAction = (url = location) => getRepo(url)?.path === "actions/new";
140
162
  var isRepositoryActions = (url = location) => /^actions(\/workflows\/.+\.ya?ml)?$/.test(getRepo(url)?.path);
141
163
  var isUserTheOrganizationOwner = () => isOrganizationProfile() && exists('[aria-label="Organization"] [data-tab-item="org-header-settings-tab"]');
142
- var canUserEditRepo = () => isRepo() && exists('.reponav-item[href$="/settings"], [data-tab-item$="settings-tab"]');
164
+ var canUserAdminRepo = () => isRepo() && exists('.reponav-item[href$="/settings"], [data-tab-item$="settings-tab"]');
165
+ var canUserEditRepo = canUserAdminRepo;
143
166
  var isNewRepo = (url = location) => url.pathname === "/new" || /^organizations\/[^/]+\/repositories\/new$/.test(getCleanPathname(url));
144
167
  var isNewRepoTemplate = (url = location) => Boolean(url.pathname.split("/")[3] === "generate");
145
168
  var getLoggedInUser = () => $('meta[name="user-login"]')?.getAttribute("content") ?? void 0;
@@ -193,6 +216,7 @@ var utils = {
193
216
  getRepositoryInfo: getRepo
194
217
  };
195
218
  export {
219
+ canUserAdminRepo,
196
220
  canUserEditRepo,
197
221
  hasCode,
198
222
  hasComments,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-url-detection",
3
- "version": "9.0.1",
3
+ "version": "9.0.3",
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",