MCPcopy Index your code
hub / github.com/refined-github/refined-github / init

Function init

source/features/sidebar-focus-file.tsx:8–26  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6import delay from '../helpers/delay.js';
7
8async 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
28void features.add(import.meta.url, {
29 include: [

Callers

nothing calls this directly

Calls 2

scrollIntoViewIfNeededFunction · 0.85
delayFunction · 0.85

Tested by

no test coverage detected