It uses events to control the signalling between context menu, background workers (ffmpeg and download manager) and content script.
- User clicks on Context Menu
./src/context-menu.js
emitsembed_conversion_requested
event./src/content.js
receivesembed_conversion_requested
and set a loading component within the image./src/content.js
emitsconversion_requested
event./src/handlers/ffmpeg-handler.js
receivesconversion_requested
and process the input./src/handlers/ffmpeg-handler.js
triggers thesendResponse
callback./src/content.js
receives callback and replace image component
- User clicks on Context Menu
./src/context-menu.js
emitsdownload_conversion_requested
event./src/content.js
receivesembed_conversion_requested
and set a loading component within the image./src/content.js
emitsconversion_requested
event./src/handlers/ffmpeg-handler.js
receivesconversion_requested
and process the input./src/handlers/ffmpeg-handler.js
triggers thesendResponse
callback./src/content.js
receives callback and emitsconversion_requested
./src/handlers/download-handler.js
receivesconversion_requested
and triggers a download
From ./src
:
content.js
: scripts required to interact with the DOM elements (loading state, for example) and dispatch messages to the handlerscontext-menu.js
: registerGIFSane
to image's context menu (right-click mouse menu)handlers/
: background scripts (in the future, workers)ffmpeg-handler.js
: handleconversion_requested
events sent by the content script, which triggers FFMpeg conversiondownload-handler.js
: handledownload_requested
events sent by the content script, which triggers a Chrome download based on a blob URL
middlewares/
request-middleware.js
: change CSP headers to allow the injection ofblob:...
URLs through changes onmedia-src
img/
: keep static images used by the script and manifestvendor/
: keep vendor source, as this doesn't rely on build scripts of any sort