()
| 6 | import delay from '../helpers/delay.js'; |
| 7 | |
| 8 | async function init(): Promise<void | false> { |
| 9 | const {filePath} = new GitHubFileUrl(location.href); |
| 10 | |
| 11 | // eslint-disable-next-line unicorn/prefer-query-selector -- `querySelector` requires escaping |
| 12 | const item = document.getElementById(`${filePath}-item`); |
| 13 | if (item) { |
| 14 | // This feature is only needed for the very first load of the view. |
| 15 | // GitHub does it natively after that. |
| 16 | scrollIntoViewIfNeeded(item); |
| 17 | |
| 18 | // Try again after a delay because GitHub might have reset the scroll |
| 19 | // https://github.com/refined-github/refined-github/pull/7848#discussion_r1784041198 |
| 20 | await delay(500); |
| 21 | scrollIntoViewIfNeeded(item); |
| 22 | } else { |
| 23 | // The sidebar might be closed |
| 24 | return false; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | void features.add(import.meta.url, { |
| 29 | include: [ |
nothing calls this directly
no test coverage detected