X-Git-Url: https://git.ao2.it/GM_direct_download_links.git/blobdiff_plain/15d19652007f2070866f213a27dc3f425366bf10..c7512e18698e3d8c428c939e23ba21e7c7731cbe:/direct_download_links.user.js?ds=sidebyside diff --git a/direct_download_links.user.js b/direct_download_links.user.js index 37bca00..5020163 100644 --- a/direct_download_links.user.js +++ b/direct_download_links.user.js @@ -23,12 +23,15 @@ // @name Direct Download Links // @namespace http://git.ao2.it/GM_direct_download_links.git // @description Add direct download links +// @grant GM_log +// @grant GM_xmlhttpRequest // @include http://video.repubblica.it/* // @include http://tv.repubblica.it/* // @include http://trovacinema.repubblica.it/* // @include http://www.kataweb.it/tvzap/* // @include http://www.rai.tv/* // @include http://soundcloud.com/* +// @include http://www.telecinco.es/* // ==/UserScript== // @@ -96,9 +99,9 @@ var supported_sites = [ }, { locationRegexp: /^http:\/\/www\.kataweb\.it\/tvzap\/.*$/, - urlContainerXPath: '//div[@id="tvzap_video"]', - urlRegexp: /'pcUrl', '((http|mms):\/\/[^']*)'/, - linkDestXPath: '//div[@id="tvzap_video"]', + urlContainerXPath: '//div[@id="contAB"]', + urlRegexp: /[^\/]addParam\('pcUrl', '((http|mms):\/\/[^']*)'/, + linkDestXPath: '//div[@id="contAB"]', }, { locationRegexp: /^http:\/\/www\.rai\.tv\/.*$/, @@ -119,6 +122,12 @@ var supported_sites = [ urlRegexp: /"streamUrl":"([^"]*)"/, linkDestXPath: '//div[@id="main-content-inner"]', }, + { + locationRegexp: /^http:\/\/www\.telecinco.es\/.*$/, + urlContainerXPath: '//video[@class="video-js"]', + urlRegexp: /src="([^"]*)"/, + linkDestXPath: '//div[@class="pg-bd"]', + }, ]; /* Apply different rules to different sites */ @@ -138,6 +147,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 +214,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); }