|
1579 | 1579 | ${elementSelector.right.modalDialog} |
1580 | 1580 | { |
1581 | 1581 | pointer-events: all; |
1582 | | - margin-top: 55px; |
1583 | | - margin-right: 20px; |
1584 | 1582 | animation: .2s cubic-bezier(.33,1,.68,1) !important; |
1585 | 1583 | border-top-right-radius: 0.75rem !important; |
1586 | 1584 | border-bottom-right-radius: 0.75rem !important; |
|
2181 | 2179 | }; |
2182 | 2180 | } |
2183 | 2181 |
|
2184 | | - function addMenuItemToActionList() { |
| 2182 | + function addMenuItemToActionList(_event, retryCount = 0) { |
2185 | 2183 | log(VERBOSE, 'addMenuItemToActionList()'); |
| 2184 | + log(VERBOSE, 'retryCount', retryCount); |
2186 | 2185 |
|
2187 | 2186 | const liElementId = 'custom-global-navigation-menu-item'; |
2188 | 2187 |
|
2189 | | - if (document.querySelector(createId(liElementId))) return; |
| 2188 | + if (document.querySelector(createId(liElementId))) { |
| 2189 | + log(DEBUG, 'Menu item already exists, skipping addition'); |
| 2190 | + return; |
| 2191 | + } |
2190 | 2192 |
|
2191 | 2193 | const actionList = document.querySelector(SELECTORS.sidebars.right.actionList); |
2192 | 2194 | if (!actionList) { |
2193 | | - log(DEBUG, 'Action list not found'); |
2194 | | - return setTimeout(addMenuItemToActionList, 100); |
| 2195 | + if (retryCount < 20) { |
| 2196 | + log(DEBUG, 'Action list not found, retrying...'); |
| 2197 | + return setTimeout(() => addMenuItemToActionList(retryCount + 1), 100); |
| 2198 | + } else { |
| 2199 | + logError('Action list not found after 2 seconds, giving up'); |
| 2200 | + return; |
| 2201 | + } |
2195 | 2202 | } |
2196 | 2203 |
|
2197 | 2204 | const signOutLink = actionList.querySelector(SELECTORS.sidebars.right.signOutLink); |
2198 | 2205 | if (!signOutLink) { |
2199 | | - log(DEBUG, 'Logout link not found'); |
2200 | | - return; |
| 2206 | + if (retryCount < 20) { |
| 2207 | + log(DEBUG, 'Logout link not found, retrying...'); |
| 2208 | + return setTimeout(() => addMenuItemToActionList(retryCount + 1), 100); |
| 2209 | + } else { |
| 2210 | + logError('Logout link not found after 2 seconds, giving up'); |
| 2211 | + return; |
| 2212 | + } |
2201 | 2213 | } |
2202 | 2214 |
|
2203 | 2215 | const signOutLi = signOutLink.parentNode; |
|
3666 | 3678 | topDiv: '#__primerPortalRoot__', |
3667 | 3679 | wrapper: '#__primerPortalRoot__ > div', |
3668 | 3680 | backdrop: '#__primerPortalRoot__ > div > [data-position-regular="right"]', |
3669 | | - modalDialog: '#__primerPortalRoot__ > div > [data-position-regular="right"] > div', |
| 3681 | + modalDialog: '#__primerPortalRoot__ div[role="dialog"]', |
3670 | 3682 | closeButton: '#__primerPortalRoot__ button[aria-label="Close"]', |
3671 | 3683 | divider: 'li[data-component="ActionList.Divider"]', |
3672 | 3684 | actionList: '[class^="prc-ActionList-"]', |
|
0 commit comments