Skip to content

Commit

Permalink
all_Automation_Git_Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
AmolKadam-Tekdi committed Jul 15, 2024
1 parent 2fc4e45 commit d589dbd
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 38 deletions.
31 changes: 19 additions & 12 deletions allAutomation/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified allAutomation/Manifest.zip
Binary file not shown.
11 changes: 10 additions & 1 deletion allAutomation/Manifest/background.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
chrome.runtime.onInstalled.addListener(() => {
console.log("Microphone Simulation Extension Installed");
console.log("My Microphone Simulator Extension Installed");

// Add other background tasks or listeners here if needed
});

chrome.action.onClicked.addListener((tab) => {
chrome.scripting.executeScript({
target: { tabId: tab.id },
files: ['content.js']
});
});
48 changes: 26 additions & 22 deletions allAutomation/Manifest/content.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
function simulateMicrophoneInput(audioFilePath) {
const context = new AudioContext();
fetch(audioFilePath)
.then(response => response.arrayBuffer())
.then(arrayBuffer => context.decodeAudioData(arrayBuffer))
.then(audioBuffer => {
const source = context.createBufferSource();
source.buffer = audioBuffer;
source.connect(context.destination);
source.start();
})
.catch(console.error);
}
console.log("My Microphone Simulator Content Script Loaded");

// Function to check if the microphone button is clicked
function waitForMicButtonClick(selector) {
document.querySelector(selector).addEventListener('click', function() {
console.log("Microphone button clicked");
const audioFilePath = chrome.runtime.getURL("output_audio.wav");
simulateMicrophoneInput(audioFilePath);
});
// Simulate microphone input
function simulateMicrophoneInput(audioFile) {
navigator.mediaDevices.getUserMedia = function(constraints) {
return new Promise((resolve, reject) => {
if (constraints.audio) {
const audioContext = new AudioContext();
fetch(audioFile)
.then(response => response.arrayBuffer())
.then(data => audioContext.decodeAudioData(data))
.then(buffer => {
const source = audioContext.createBufferSource();
source.buffer = buffer;
const destination = audioContext.createMediaStreamDestination();
source.connect(destination);
source.start();
resolve(destination.stream);
})
.catch(err => reject(err));
} else {
reject(new Error("Only audio constraints are supported."));
}
});
};
}

// Start checking for the microphone button click
waitForMicButtonClick('.MuiBox-root.css-1l4w6pd'); // Adjust the selector to match your microphone button
// Use the function to simulate microphone input with your audio file
simulateMicrophoneInput(chrome.runtime.getURL("output_audio.wav"));
13 changes: 10 additions & 3 deletions allAutomation/Manifest/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"manifest_version": 3,
"name": "Microphone Simulation",
"name": "My Microphone Simulator",
"version": "1.0",
"description": "Simulates microphone input for automated testing.",
"permissions": [
"audioCapture"
"tabs",
"activeTab",
"storage",
"scripting"
],
"background": {
"service_worker": "background.js"
Expand All @@ -13,5 +17,8 @@
"matches": ["<all_urls>"],
"js": ["content.js"]
}
]
],
"action": {
"default_popup": "popup.html"
}
}
Binary file modified allAutomation/my_project/tests/Manifest.zip
Binary file not shown.

0 comments on commit d589dbd

Please sign in to comment.