Skip to content

Latest commit

 

History

History
136 lines (80 loc) · 3.18 KB

document.md

File metadata and controls

136 lines (80 loc) · 3.18 KB

Gruntled Documentation - Back-End

This is a brief overview of the methods and variables contained in the Javascript files used to run the extension.


Table of Contents

  1. Webcam.js
  2. Yt_controls.js
  3. Popup.js

Webcam.js

Contains functions to Setup the webcam as well as to handle the resulting MediaStream and MediaRecorder Object.

Injected into Youtube page upon clicking on extension icon.

createNewVideoElement()

Creates new html video element w/ custom styles applied.

setupWebcam()

Creates new video element w/ webcam as srcObject and appends it to youtube video container element.


Yt_controls.js

The purpose of this script is to setup the webcam and handle the resulting MediaStream and MediaRecorder Object.

play()

Handle Youtube video Play

  1. Grabs play/pause button from dom
  2. If title matches play condition sends(fires?) click event

pause()

Handle Youtube video Pause

  1. Grabs play/pause button from dom
  2. If title matches pause condition sends(fires?) click event

restart()

Handle Youtube video Restart


Popup.js

Responsible for handling control over extension and it currently controls:

  • Setting up and Recording Webcam video
  • Backend for popup.html

addCustomEventListener(html_element, custom_event_func)

Add custom function as click event to an html element

let addCustomEventListener = (html_element, custom_event_func) => {
    html_element.addEventListener("click", (e) => {
        custom_event_func && custom_event_func(); // if no custom function is provided doesnt run it
    });
};

setupTabs()

Setup Popup Tab Functionality

function setupTabs() {
    // Do Stuff ...
}

setupWebcam() [ BROKEN ]

Setup Webcam Preview in popup window

getSupportedMimeTypes()

Filters for supported mimtypes

getCurrentTab() [ async ]

Grabs current active tab from window

startRecording() [ WEBCAM ]

Handle clicking of start recording button

  1. Set MimeType Option
  2. Try to create new media recorder using media stream
  3. [debug] show result
  4. Update record button text
  5. Update other buttons/inputs
  6. Set on stop event
  7. When data is available start recording

handleDataAvailable(event) [ WEBCAM ]

if the data exist and it has a size > than 0 append it to the recoeded blobs array

stopRecording() [ WEBCAM ]

Stops the MediaRecorder, then updates record, play and download buttons, updates codecPreferences

recordToggle() [ WEBCAM ]

Toggle between running startRecording() and stopRecording() based off of recordButton text content (textContent)

startCamera() [ WEBCAM ]

MAYBE injects start up webcam function/script into youtube page
MAYBE runs a setup webcam function that allows for it to play in the popup Also sends a message or function to play/pause/restart the youtube video

playbackVideo()

Convert recorded Blobs array into a new Blob object and then add it as a src to recordedVideo and start playing.

downloadVideo()

Downloads recordedBlobs


End of Document