-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
f864718
commit d27f0c3
Showing
2 changed files
with
37 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
// Check if running in Chrome extension context | ||
const isExtension = typeof chrome !== 'undefined' && chrome.runtime && chrome.runtime.getURL; | ||
|
||
export const injectMicrophonePermissionIframe = () => { | ||
const iframe = document.createElement("iframe"); | ||
iframe.setAttribute("hidden", "hidden"); | ||
iframe.setAttribute("id", "permissionsIFrame"); | ||
iframe.setAttribute("allow", "microphone"); | ||
iframe.src = chrome.runtime.getURL("/src/pages/permission/index.html"); | ||
document.body.appendChild(iframe); | ||
// Only inject the iframe if we're in a Chrome extension context | ||
if (isExtension) { | ||
const iframe = document.createElement("iframe"); | ||
iframe.setAttribute("hidden", "hidden"); | ||
iframe.setAttribute("id", "permissionsIFrame"); | ||
iframe.setAttribute("allow", "microphone"); | ||
iframe.src = chrome.runtime.getURL("/src/pages/permission/index.html"); | ||
document.body.appendChild(iframe); | ||
} | ||
}; | ||
|
||
// Inject the iframe when the content script runs | ||
injectMicrophonePermissionIframe(); | ||
// Only run extension-specific code if we're in a Chrome extension context | ||
if (isExtension) { | ||
// Inject the iframe when the content script runs | ||
injectMicrophonePermissionIframe(); | ||
|
||
// Listen for messages from the iframe | ||
window.addEventListener('message', (event) => { | ||
if (event.data.type === 'MICROPHONE_PERMISSION_GRANTED') { | ||
console.log('Microphone permission granted'); | ||
// You can add any additional logic here when permission is granted | ||
} | ||
}); | ||
// Listen for messages from the iframe | ||
window.addEventListener('message', (event) => { | ||
if (event.data.type === 'MICROPHONE_PERMISSION_GRANTED') { | ||
console.log('Microphone permission granted'); | ||
// You can add any additional logic here when permission is granted | ||
} | ||
}); | ||
} |