From c0b18e9381e770e8e1d9a87dd1faada30e176214 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Fri, 9 Dec 2011 16:15:05 +0100 Subject: [PATCH] Split out _get_URL() and _add_link() functions This is in preparation for the introduction of async behaviors. Signed-off-by: Antonio Ospite --- direct_download_links.user.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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.'); -- 2.1.4