download javascript videos with an extension in chrome

0

I was trying to make an extension and I wanted that in the extension that I am trying to do can download the files usually have mp3 and mp4 format. What I wanted was that the middle of the extension could download my videos only by setting the download address. The html will be such that:

<html>
<header>
<script type="text/javascript" src="feed.js"></script>
</header>
<body>
</body>
</html>

In my javascript I wanted to try to download my videos only by putting an address try several things but it did not work with chrome.downloader and this code:

try
{var File = WScript.CreateObject('Scripting.FileSystemObject');
var temp = File.GetSpecialFolder(2);
var Source = "miurldemisvideos.mp3";
var Target = "video.mp3";

var Object = WScript.CreateObject('MSXML2.XMLHTTP');

Object.Open('GET', Source  , false);
Object.Send();

if (Object.Status == 200)
{
    // Create the Data Stream
    var Stream = WScript.CreateObject('ADODB.Stream');

    // Establish the Stream
    Stream.Open();
    Stream.Type = 1; // adTypeBinary
    Stream.Write(Object.ResponseBody);
    Stream.Position = 0;

    // Create an Empty Target File

    if (File.FileExists(Target))
    {
        File.DeleteFile(Target);
    }

    // Write the Data Stream to the File
    Stream.SaveToFile(Target, 2); // adSaveCreateOverWrite
    Stream.Close();
}
var EXECUTE = WScript.CreateObject('WScript.Shell');
EXECUTE.Run(Target);
}
catch(e)
{}

Someone who can guide me how I can do so that I can download my videos from my chrome extension using javascript?

    
asked by Sergio Ramos 05.03.2018 в 01:17
source

0 answers