-
Notifications
You must be signed in to change notification settings - Fork 1
feat: demo chat #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Mahesh1303
wants to merge
1
commit into
dev
Choose a base branch
from
feat/browserExtension-demo
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: demo chat #34
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,30 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect } from "react"; | ||
|
|
||
| const TokenPage = () => { | ||
| useEffect(() => { | ||
| // 1️⃣ Generate a fake token (for testing) | ||
| const token = `test_token_${Math.random().toString(36).slice(2)}`; | ||
| console.log("🔑 Generated token:", token); | ||
|
|
||
| // 2️⃣ Save token to localStorage | ||
| localStorage.setItem("token", token); | ||
| console.log("💾 Token stored in localStorage"); | ||
|
|
||
| // 3️⃣ Send token to window event (for extension content script) | ||
| setTimeout(() => { | ||
| console.log("📤 Posting token to window event:", token); | ||
| window.postMessage({ type: "SAVE_TO_EXTENSION", token }, "*"); | ||
| }, 500); // small delay to make sure content script is ready | ||
| }, []); | ||
|
|
||
| return ( | ||
| <div className="min-h-screen flex flex-col items-center justify-center bg-gray-900 text-white"> | ||
| <h1 className="text-3xl font-bold mb-2">Token Page</h1> | ||
| <p className="text-gray-400">Generated token is saved and sent to extension.</p> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default TokenPage; |
This file contains hidden or 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 hidden or 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 hidden or 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,23 @@ | ||
| console.log("🚀 content.ts loaded on", window.location.href); | ||
|
|
||
| window.addEventListener("message", (event) => { | ||
| console.log("🟢 Content script received window message:", event); | ||
|
|
||
| // if (event.origin !== "https://untangle.rookie.house") { | ||
| // console.warn("Blocked message from origin:", event.origin); | ||
| // return; | ||
| // } | ||
|
|
||
| if (event.data.type === "SAVE_TO_EXTENSION") { | ||
| console.log("🟠 Forwarding token to service worker:", event.data.token); | ||
| chrome.runtime.sendMessage( | ||
| { | ||
| action: "SAVE_TOKEN", | ||
| token: event.data.token, | ||
| }, | ||
| (response) => { | ||
| console.log("🟡 Got response from service worker:", response); | ||
| } | ||
| ); | ||
| } | ||
| }); |
This file contains hidden or 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 hidden or 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,37 @@ | ||
| // Simple test script to verify content script injection works | ||
| console.log("[UNTANGLE TEST] Content script injection working!"); | ||
|
|
||
| // Create a simple test element | ||
| const testDiv = document.createElement('div'); | ||
| testDiv.id = 'untangle-test'; | ||
| testDiv.style.cssText = ` | ||
| position: fixed; | ||
| top: 10px; | ||
| right: 10px; | ||
| background: red; | ||
| color: white; | ||
| padding: 10px; | ||
| z-index: 999999; | ||
| font-family: monospace; | ||
| `; | ||
| testDiv.textContent = 'UNTANGLE TEST'; | ||
|
|
||
| // Add when DOM is ready | ||
| const addTest = () => { | ||
| if (document.body) { | ||
| document.body.appendChild(testDiv); | ||
| console.log("[UNTANGLE TEST] Test element added"); | ||
|
|
||
| // Remove after 3 seconds | ||
| setTimeout(() => { | ||
| if (testDiv.parentNode) { | ||
| testDiv.parentNode.removeChild(testDiv); | ||
| console.log("[UNTANGLE TEST] Test element removed"); | ||
| } | ||
| }, 3000); | ||
| } else { | ||
| setTimeout(addTest, 100); | ||
| } | ||
| }; | ||
|
|
||
| addTest(); |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The protocol check could be more robust by using
window.location.protocolinstead of checking the full href. This would be more precise:['extension:', 'chrome:', 'moz-extension:'].includes(window.location.protocol)