From c0822563e49f1dcca21a6c78064f10f4f06943fc Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Sat, 1 Sep 2012 12:50:33 +0200 Subject: [PATCH] Decode HTML entities in the target URL Signed-off-by: Antonio Ospite --- direct_download_links.user.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/direct_download_links.user.js b/direct_download_links.user.js index 37bca00..11932f8 100644 --- a/direct_download_links.user.js +++ b/direct_download_links.user.js @@ -138,6 +138,13 @@ function getElementByXPath(query, root) { return document.evaluate(query, root || document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue; } +/* from http://stackoverflow.com/questions/1912501 */ +function htmlDecode(input){ + var e = document.createElement('div'); + e.innerHTML = input; + return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue; +} + /** * Add a Direct Download link on the page for the specified URL * @@ -198,7 +205,7 @@ function _get_URL(site, element) { var evt = document.createEvent('Event'); evt.initEvent('UrlFetched', true, true); evt.site = site; - evt.URL = URL; + evt.URL = htmlDecode(URL); document.dispatchEvent(evt); } -- 2.1.4