Added download feature for Unix, Linux, and MacOS systems using native messaging.
This commit is contained in:
@@ -16,4 +16,11 @@ const handleUpdated = (tabId, changeInfo, tabInfo) => {
|
||||
}
|
||||
}
|
||||
|
||||
const notify = (data) => {
|
||||
let port = browser.runtime.connectNative("web_video_dl");
|
||||
console.log("Downloding: " + data.url);
|
||||
port.postMessage(data.url);
|
||||
}
|
||||
|
||||
browser.runtime.onMessage.addListener(notify);
|
||||
browser.tabs.onUpdated.addListener(handleUpdated);
|
||||
|
@@ -12,8 +12,14 @@
|
||||
ytdVideoIntervalLoop;
|
||||
let loopingInterval = false;
|
||||
let count = 0;
|
||||
let OSName = "";
|
||||
|
||||
const preSetupProc = () => {
|
||||
if (navigator.appVersion.indexOf("Win")!=-1) OSName = "Windows";
|
||||
if (navigator.appVersion.indexOf("Mac")!=-1) OSName = "MacOS";
|
||||
if (navigator.appVersion.indexOf("X11")!=-1) OSName = "UNIX";
|
||||
if (navigator.appVersion.indexOf("Linux")!=-1) OSName ="Linux";
|
||||
|
||||
video = document.getElementsByTagName("video")[0]; // Video Controler
|
||||
slugInputTag = document.createElement("INPUT");
|
||||
ytRangeEnd = document.createElement("INPUT");
|
||||
@@ -47,12 +53,14 @@
|
||||
ytThumbImgMenu = document.createElement("DIV");
|
||||
ytEnhancerMenu = document.createElement("DIV");
|
||||
ytThumbnailBttn = document.createElement("IMG");
|
||||
ytDownloadBttn = document.createElement("IMG");
|
||||
ytLoopBttn = document.createElement("IMG");
|
||||
ytFloatBttn = document.createElement("IMG");
|
||||
ytMaxDefaultImg = document.createElement("IMG");
|
||||
ytHqDefaultImg = document.createElement("IMG");
|
||||
ytMqDefaultImg = document.createElement("IMG");
|
||||
ytSdDefaultImg = document.createElement("IMG");
|
||||
|
||||
ytAMaxDefaultImg = document.createElement("A");
|
||||
ytAHqDefaultImg = document.createElement("A");
|
||||
ytAMedDefaultImg = document.createElement("A");
|
||||
@@ -81,6 +89,14 @@
|
||||
ytEnhancerMenu.appendChild(ytLoopBttn);
|
||||
ytEnhancerMenu.appendChild(ytRangeSection);
|
||||
ytEnhancerMenu.appendChild(ytFloatBttn);
|
||||
|
||||
if (OSName.includes("MacOS") || OSName.includes("UNIX") ||
|
||||
OSName.includes("Linux")) {
|
||||
console.log("System supports downloader...");
|
||||
console.log("OS is : " + OSName);
|
||||
ytEnhancerMenu.appendChild(ytDownloadBttn);
|
||||
}
|
||||
|
||||
ytRangeSection.append(ytRangeStart);
|
||||
ytRangeSection.append(ytRangeEnd);
|
||||
document.body.appendChild(poppedContainer);
|
||||
@@ -100,6 +116,7 @@
|
||||
ytThumbnailBttn.addEventListener("click", showThumbImageVew);
|
||||
ytLoopBttn.addEventListener("click", setLoop);
|
||||
ytFloatBttn.addEventListener("click", toggleFloat);
|
||||
ytDownloadBttn.addEventListener("click", downloadVideo);
|
||||
video.addEventListener("wheel", manageVolume);
|
||||
|
||||
// Dragable window for floating video
|
||||
@@ -108,6 +125,7 @@
|
||||
ytThumbnailBttn.src = browser.extension.getURL("/icons/thumbnailOff.png");
|
||||
ytLoopBttn.src = browser.extension.getURL("/icons/loopFalse.png");
|
||||
ytFloatBttn.src = browser.extension.getURL("/icons/floatPlayer.png");
|
||||
ytDownloadBttn.src = browser.extension.getURL("/icons/downloadVid.png");
|
||||
|
||||
// Set trget of Thumbnails of video
|
||||
ytAMaxDefaultImg.target = "_blank";
|
||||
@@ -125,6 +143,7 @@
|
||||
ytThumbnailBttn.className = "imageStyle";
|
||||
ytLoopBttn.className = "imageStyle";
|
||||
ytFloatBttn.className = "imageStyle";
|
||||
ytDownloadBttn.className = "imageStyle";
|
||||
ytEnhancerMenu.id = "enhancerMenuIDRef";
|
||||
poppedContainer.id = "draggable";
|
||||
ytRangeStart.id = "rangeStartID";
|
||||
@@ -140,6 +159,10 @@
|
||||
}
|
||||
|
||||
// Functions
|
||||
const downloadVideo = () => {
|
||||
browser.runtime.sendMessage( { "url": video.baseURI } );
|
||||
}
|
||||
|
||||
const showThumbImageVew = (e) => {
|
||||
videoSlug = video.baseURI.slice(32, 32+11); // Used for setting up thumbnails
|
||||
|
||||
|
Reference in New Issue
Block a user