-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
155 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
type Details = { | ||
documentId: string; // "7AD74... | ||
documentLifecycle: string; // "activ... | ||
frameId: number; // 0; | ||
frameType: string; // "outer... | ||
fromCache: false; | ||
initiator: string; // "https... | ||
ip: string; // "104.1... | ||
method: string; // "GET";... | ||
parentFrameId: number; //-1; | ||
requestId: string; // "6703"... | ||
statusCode: number; // 200; | ||
statusLine: string; // "HTTP/... | ||
tabId: number; // 1033803684; | ||
timeStamp: number; // 1686881111010.292; | ||
type: string; // "scrip... | ||
url: string; // "https... | ||
requestHeaders?: { name: string; value: string }[]; | ||
}; | ||
|
||
let auth = ""; | ||
// @ts-ignore | ||
chrome.webRequest.onBeforeSendHeaders.addListener( | ||
(details: Details) => { | ||
const foundAuth = details.requestHeaders?.find( | ||
({ name }) => name.toLowerCase() === "authorization" | ||
); | ||
if (foundAuth) { | ||
auth = foundAuth.value; | ||
} | ||
|
||
console.log("REQ headers!", { | ||
url: details.url, | ||
headers: details.requestHeaders, | ||
}); | ||
}, | ||
{ types: ["xmlhttprequest"], urls: ["https://chat.openai.com/*"] }, | ||
|
||
["requestHeaders", "extraHeaders"] | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { ClassNames } from "@emotion/react"; | ||
import { | ||
MantineProvider, | ||
Paper, | ||
Portal | ||
} from "@mantine/core"; | ||
import { useForceUpdate } from "@mantine/hooks"; | ||
import throttle from "lodash/throttle"; | ||
import { useCallback, useEffect, useId, useMemo } from "react"; | ||
|
||
type Props = { | ||
// onExecute: (prompt: string) => Promise<string>; | ||
// onDone: () => void; | ||
}; | ||
|
||
export const TreeSorter = (props: Props) => { | ||
const id = `tree-${(useId() || "").replace(/:/g, "")}`; | ||
const update = useForceUpdate(); | ||
const target = document.getElementById(id); | ||
const installer = useMemo( | ||
() => | ||
throttle( | ||
() => { | ||
const el = document.querySelector("nav .overflow-y-auto > div > div"); | ||
if (!el) return; | ||
|
||
const hasWiped = el.id !== id; | ||
if (hasWiped) { | ||
// install! | ||
el.id = id; | ||
el.classList.add("relative"); | ||
update(); | ||
} | ||
}, | ||
1000, | ||
{ trailing: true } | ||
), | ||
[id] | ||
); | ||
|
||
const mounter = useCallback<MutationCallback>( | ||
(mutation) => { | ||
const added = mutation.filter( | ||
(m) => m.type === "childList" && m.addedNodes | ||
); | ||
console.log(added); | ||
if (!added) return; | ||
|
||
installer(); | ||
}, | ||
[id] | ||
); | ||
|
||
useEffect(() => { | ||
const nav = document.querySelector("nav"); | ||
if (!nav) return; | ||
|
||
const mo = new MutationObserver(mounter); | ||
mo.observe(nav, { childList: true, subtree: true }); | ||
installer(); | ||
return () => { | ||
try { | ||
mo.disconnect(); | ||
} catch { | ||
// ignore | ||
} | ||
}; | ||
}, [mounter, installer]); | ||
|
||
return target ? ( | ||
<Portal target={target}> | ||
<MantineProvider theme={{ colorScheme: "dark" }}> | ||
<ClassNames> | ||
{({ css }) => ( | ||
<Paper | ||
className={css` | ||
position: absolute; | ||
inset: 0; | ||
left: 50%; | ||
z-index: 1000; | ||
`} | ||
> | ||
Hello! | ||
</Paper> | ||
)} | ||
</ClassNames> | ||
</MantineProvider> | ||
</Portal> | ||
) : null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { useEffect } from "react"; | ||
|
||
export const useConversations = () => { | ||
useEffect(() => {}, []); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
/// <reference types="vite/client" /> | ||
/// <reference types="@crxjs/vite-plugin/client.d.ts" /> | ||
/// <reference types="@crxjs/vite-plugin/client.d.ts" /> | ||
declare global { | ||
chrome: any; | ||
} |