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

Function verify

source/features/rgh-token-user.tsx:13–33  ·  view source on GitHub ↗
(header: HTMLElement)

Source from the content-addressed store, hash-verified

11import {getToken} from '../options-storage.js';
12
13async function verify(header: HTMLElement): Promise<void> {
14 const token = await getToken();
15 if (!token) {
16 return;
17 }
18
19 const currentWebUser = getLoggedInUser();
20 const currentTokenUser = await tokenUser.get(api3, token);
21 if (currentWebUser !== currentTokenUser) {
22 header.after(
23 // Use raw "flash" classes to blend in better with the dropdown menu
24 <div className="flash flash-error px-3 tmp-px-3 mt-3 tmp-mt-3 mb-0 tmp-mb-0 py-2 tmp-py-2 d-flex flex-items-center border-0 rounded-0">
25 <AlertIcon className="mr-2 tmp-mr-2" />
26 <span>
27 Write API calls are blocked because your <OptionsLink className="btn-link">Refined GitHub token</OptionsLink>{' '}
28 belongs to <code>{currentTokenUser}</code>, not <code>{currentWebUser}</code>.
29 </span>
30 </div>,
31 );
32 }
33}
34
35function initOnce(): void {
36 observe('div[aria-labelledby="global-nav-user-menu-header"] > div[role="heading"]', verify);

Callers

nothing calls this directly

Calls 2

getTokenFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected