1
Fork 0
mirror of https://github.com/Steffo99/bbdl-firefox.git synced 2024-10-16 06:17:28 +00:00
bbdl-firefox/extension/content.js
2020-09-23 15:05:18 +02:00

23 lines
No EOL
682 B
JavaScript

"use strict";
function onMessageReceived(_) {
console.debug("Received message from the background script")
const videoElement = document.querySelector("video")
if(videoElement === null) {
console.error("No video element found on the page.")
return;
}
const videoLink = videoElement.getAttribute("src")
if(videoLink === null) {
console.error("No src found for the video element.")
return;
}
console.debug(`Found video link: ${videoLink}`)
browser.runtime.sendMessage({"download_url": videoLink})
}
browser.runtime.onMessage.addListener(onMessageReceived);
console.debug("bbdl-content was loaded successfully!")