Adding `Image Download List` to the Popular `VideoDownloadHelper` Chrome Extension


The Chrome Extension: Simple Video Download Helper is available on Chrome Webstore. The number of current users exceeds 10000 (Hurrray!)
It is fully open source on Github.

New Features

As suggested by my friend, I have added a function allowing users to extract a list of images in the current page. For example, when users presses the image button, a list of image sources are listed.

chrome-extension-video-downloader-image-list Adding `Image Download List` to the Popular `VideoDownloadHelper` Chrome Extension chrome extension javascript video download tutorial

chrome-extension-video-downloader-image-list

Javascript Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
$("#pic").click(function() {
  let domain = pageurl.replace('http://','').replace('https://','').replace('www.','').split(/[/?#]/)[0];
  if (pageurl.startsWith("http://")) {
    domain = "http://" + domain;
  } else if (pageurl.startsWith("https://")) {
    domain = "https://" + domain;
  }
  $.ajax({
     type: "GET",
     url: pageurl,
     success: function(data) {
        var tmp = [];
        var re = /<img\s[^>]*?src\s*=\s*['\"]([^'\"]*?)['\"][^>]*?>/ig;
        var found = re.exec(data);
        while (found != null) {
            var tmp_url = found[1];
            if ((tmp_url != null) && (tmp_url.length > 0)) {
              if (tmp_url.startsWith("http://") || tmp_url.startsWith("https://")) {
                tmp.push(tmp_url);
              } else {
                if (tmp_url[0] == '/') {
                  tmp.push(domain + tmp_url);
                } else {
                  tmp.push(domain + '/' + tmp_url);
                }
              }
            }
            found = re.exec(data);
        }
        if (tmp.length > 0) {
          let s = '<h3>Images List</h3>';
          s += "<ol>";
          for (let i = 0; i < tmp.length; ++ i) {
            s += "<li><a target=_blank href='" + tmp[i] + "'>" + tmp[i] + "</a>";
          }
          s += "</ol>";
          $('div#down').html(s);
        }    
     }           
  });     
});   
$("#pic").click(function() {
  let domain = pageurl.replace('http://','').replace('https://','').replace('www.','').split(/[/?#]/)[0];
  if (pageurl.startsWith("http://")) {
    domain = "http://" + domain;
  } else if (pageurl.startsWith("https://")) {
    domain = "https://" + domain;
  }
  $.ajax({
     type: "GET",
     url: pageurl,
     success: function(data) {
        var tmp = [];
        var re = /<img\s[^>]*?src\s*=\s*['\"]([^'\"]*?)['\"][^>]*?>/ig;
        var found = re.exec(data);
        while (found != null) {
            var tmp_url = found[1];
            if ((tmp_url != null) && (tmp_url.length > 0)) {
              if (tmp_url.startsWith("http://") || tmp_url.startsWith("https://")) {
                tmp.push(tmp_url);
              } else {
                if (tmp_url[0] == '/') {
                  tmp.push(domain + tmp_url);
                } else {
                  tmp.push(domain + '/' + tmp_url);
                }
              }
            }
            found = re.exec(data);
        }
        if (tmp.length > 0) {
          let s = '<h3>Images List</h3>';
          s += "<ol>";
          for (let i = 0; i < tmp.length; ++ i) {
            s += "<li><a target=_blank href='" + tmp[i] + "'>" + tmp[i] + "</a>";
          }
          s += "</ol>";
          $('div#down').html(s);
        }    
     }           
  });     
});   

Relevant Video Download Posts

Here are some posts that relate to download videos (parser):

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
356 words
Last Post: How to Write Chrome Bookmark Scripts? - Step by Step Tutorial with a SteemIt Example
Next Post: Adding Clipboard Support to Chrome Extension: Show My IP Addresses (External and Local)

The Permanent URL is: Adding `Image Download List` to the Popular `VideoDownloadHelper` Chrome Extension

Leave a Reply