X-Git-Url: https://git.ao2.it/GM_direct_download_links.git/blobdiff_plain/c98d0a8f5339b850c447cf2933a740a14fb22426..c0b18e9381e770e8e1d9a87dd1faada30e176214:/direct_download_links.user.js?ds=sidebyside diff --git a/direct_download_links.user.js b/direct_download_links.user.js index a29f81c..8e06997 100644 --- 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; } + 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.'); @@ -118,6 +128,11 @@ function direct_download_link_add(pageURL, site) { } 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.');