- use innerHTML instead of textContent, this is how it should have
been from the start, textContent just worked for Repubblica, as the
URL was in a script, but what if it is in some html code (<a/>,
<object/>)?
- check the regexp actually matches something
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
return null;
}
- var content = element.textContent;
+ var content = element.innerHTML;
if (!content) {
- alert('DirectDL (' + pageURL + '): textContent is null, cannot find file URL.');
+ alert('DirectDL (' + pageURL + '): content is null, cannot find file URL.');
+ return null;
}
- var fileURL = content.match(fileRegexp)[1];
- if (!fileURL) {
+ var matches = content.match(fileRegexp);
+ if (!matches || matches.length < 2 || !matches[1]) {
alert('DirectDL (' + pageURL + '): file URL not found, check the fileRegexp');
return null;
}
+ var fileURL = matches[1];
var links = document.getElementById(linkDest);
if (!links) {