projects
/
GM_direct_download_links.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Split out _get_URL() and _add_link() functions
[GM_direct_download_links.git]
/
direct_download_links.user.js
diff --git
a/direct_download_links.user.js
b/direct_download_links.user.js
index
a29f81c
..
8e06997
100644
(file)
--- a/
direct_download_links.user.js
+++ b/
direct_download_links.user.js
@@
-105,6
+105,16
@@
function direct_download_link_add(pageURL, site) {
return null;
}
return null;
}
+ var URL = _get_URL(site, element);
+ if (!URL) {
+ DDL_log('DirectDL (' + site.pageURL + '): cannot get the URL.');
+ return null;
+ }
+
+ return _add_link(site, URL);
+}
+
+function _get_URL(site, element) {
var content = element.innerHTML;
if (!content) {
DDL_log('DirectDL (' + site.pageURL + '): content is null, cannot find URL.');
var content = element.innerHTML;
if (!content) {
DDL_log('DirectDL (' + site.pageURL + '): content is null, cannot find URL.');
@@
-118,6
+128,11
@@
function direct_download_link_add(pageURL, site) {
}
var URL = matches[1];
}
var URL = matches[1];
+ return URL;
+}
+
+function _add_link(site, URL) {
+
var links = document.getElementById(site.linkDest);
if (!links) {
DDL_log('DirectDl (' + site.pageURL + '): Cannot add the direct download link.');
var links = document.getElementById(site.linkDest);
if (!links) {
DDL_log('DirectDl (' + site.pageURL + '): Cannot add the direct download link.');