chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if (request.hello === "injectRecordButton") {
// Create the record button
var recordButton = document.createElement("button");
recordButton.innerHTML = "Record";
// Add an event listener to the record button to start recording
recordButton.addEventListener("click", function() {
// Use the chrome.tabCapture API to capture the current tab and record the screen
chrome.tabCapture.capture({ video: true, audio: true }, function(stream) {
// Record the stream and save the resulting video file
const video = document.createElement("video");
video.srcObject = stream;
video.style.position = "fixed";
video.style.bottom = "0";
video.style.right = "0";
video.style.zIndex = "9999";
document.body.appendChild(video);
// ...
});
});
// Inject the record button into the page
document.body.appendChild(recordButton);
}
});