+ // This is used for sites adding the URL to the DOM after DOMContentLoaded,
+ // for example by some javascript library (like Silverlight.js on rai.tv).
+ if (site.onEvent) {
+ element.addEventListener(site.onEvent.evt, function(e) {
+ if (site.onEvent.targetElement &&
+ e.target.tagName.toLowerCase() != site.onEvent.targetElement) {
+ DDL_log('DirectDL (' + site.pageURL + '): skipping element ' + e.target.tagName);
+ return;
+ }
+ var URL = _get_URL(site, element);
+ return _add_link(site, URL);
+ }, false);
+ return true;
+ }
+
+ 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) {