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

Function checkToken

source/features/rgh-improve-new-issue-form.tsx:54–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52}
53
54async function checkToken(): Promise<void> {
55 const token = await getToken();
56 if (!token) {
57 addTokenNotice('missing');
58 return;
59 }
60
61 try {
62 await baseApiFetch({apiBase: 'https://api.github.com/', path: 'user', token});
63 } catch (error) {
64 if (!navigator.onLine || (error as any)!.message === 'Failed to fetch') {
65 return;
66 }
67
68 addTokenNotice('invalid or expired');
69 return;
70 }
71
72 // Thank you for following the instructions. I'll save you a click.
73 const checkbox = $(isSetTheTokenSelector);
74 if (!checkbox.checked) {
75 checkbox.click();
76 }
77}
78
79async function setVersion(): Promise<void> {
80 // Wait for GitHub's listener to be attached #9293

Callers 1

initFunction · 0.85

Calls 3

getTokenFunction · 0.85
addTokenNoticeFunction · 0.85
baseApiFetchFunction · 0.85

Tested by

no test coverage detected