Skip to content

Commit

Permalink
v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielsim committed Apr 19, 2017
0 parents commit f88c28f
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 0 deletions.
53 changes: 53 additions & 0 deletions content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
var firstHref = $("a[href^='http']").eq(0).attr("href");
var source = document.documentElement.innerHTML;
var startIndex = 0, endIndex;
var allLinks = [];

while (true) {
startIndex = source.indexOf('<a id="aiPodcast', startIndex);
if (startIndex == -1) {
break;
}
endIndex = source.indexOf("</b>", startIndex);
if (endIndex < startIndex) {
break;
}
endIndex += 4;
var content = source.substring(startIndex, endIndex);

//parse link
var linkStartIndex = content.indexOf("http");
if (linkStartIndex == -1) {
break;
}
var linkEndIndex = content.indexOf(".mp4");
if (linkEndIndex == -1) {
linkEndIndex = content.indexOf(".mp3");
}
if (linkEndIndex == -1 || linkEndIndex < linkStartIndex) {
break;
}
linkEndIndex += 4;
var parsedLink = content.substring(linkStartIndex, linkEndIndex);
parsedLink = parsedLink.replace("/StreamInBrowser/", "/Stream/");
parsedLink = parsedLink.replace(".mp3", ".mp4");

//parse title
var titleStartIndex = content.indexOf("<b>");
titleStartIndex += 3;
var titleEndIndex = content.indexOf("</b>");

var parsedTitle = content.substring(titleStartIndex, titleEndIndex);

var media = {
title: parsedTitle,
link: parsedLink
}

allLinks.push(media);

startIndex = endIndex;
}

chrome.storage.local.set({'videoLinks': allLinks}, function() {
});
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions jquery-3.2.1.min.js

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"manifest_version": 2,

"name": "IVLE Downloader",
"description": "This extension will download videos",
"version": "1.0",

"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},

"permissions": [
"activeTab", "storage"
],

"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": ["jquery-3.2.1.min.js", "content.js"]
}
]

}
27 changes: 27 additions & 0 deletions popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!doctype html>

<html lang="en">
<head>
<meta charset="utf-8">

<title>IVLE downloader</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">


<script src="popup.js"></script>
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
</head>

<body>
<h2>Usage:</h2>
<p style = "width: 300px">
1. Load a webcast normally to authenticate yourself. Then close the window.<br>
2. Go back to webcast video list and refresh.<br>
3. Open this and links should appear here.<br>
<br>
</p>
</body>
</html>
9 changes: 9 additions & 0 deletions popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var links = [];
chrome.storage.local.get('videoLinks', function(res) {
for (var i = 0, len = res.videoLinks.length; i < len; i++) {
var title = res.videoLinks[i].title;
var link = res.videoLinks[i].link;
links.push(res.videoLinks[i]);
document.body.innerHTML += "<a href ='" + link + "' download='" + title + "'>" + title + "</a><br /><br />";
}
});

0 comments on commit f88c28f

Please sign in to comment.