X-Git-Url: https://git.ao2.it/GM_direct_download_links.git/blobdiff_plain/b44c3136e2f6c694ba0cad07e08a40db0c894f29..ca6cfbc09afa37b5f618e481aadf9ed2aafc2fd4:/direct_download_links.user.js diff --git a/direct_download_links.user.js b/direct_download_links.user.js index 7da37b1..e1f17f3 100644 --- a/direct_download_links.user.js +++ b/direct_download_links.user.js @@ -1,6 +1,6 @@ // direct_download_links - Add direct download links -// version 0.2 -// 2011-11-14 +// version 0.3 +// 2011-12-23 // Copyright (C) 2011 Antonio Ospite // Released under the GPL license // http://www.gnu.org/copyleft/gpl.html @@ -28,6 +28,7 @@ // @include http://trovacinema.repubblica.it/* // @include http://www.kataweb.it/tvzap/* // @include http://www.rai.tv/* +// @include http://soundcloud.com/* // ==/UserScript== // @@ -38,6 +39,8 @@ * the regexp starting from a glob line. * - use xpath instead of regexp like in http://a32.me/2009/11/greasemonkey/ * - use jquery, like shown in http://a32.me/2009/11/greasemonkey/ + * - Support the "download" attribute for anchors: + * http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#downloading-resources */ /* Fields supported by the "site" object. @@ -110,6 +113,12 @@ var supported_sites = [ processURL: _rai_get_actual_url, linkDest: 'Player', }, + { + locationRegexp: /^http:\/\/soundcloud.com\/.*$/, + urlContainer: 'main-content-inner', + urlRegexp: /"streamUrl":"([^"]*)"/, + linkDest: 'main-content-inner', + }, ]; /* Apply different rules to different sites */ @@ -181,8 +190,8 @@ function _get_URL(site, element) { return; } - var evt = document.createEvent('Event'); - evt.initEvent('UrlFetched', true, true); + var evt = document.createEvent('Event'); + evt.initEvent('UrlFetched', true, true); evt.site = site; evt.URL = URL; document.dispatchEvent(evt); @@ -212,6 +221,7 @@ function _add_link(e) { style += ' border: 2px solid red;' style += ' float: right; font-size: large;'; style += ' padding: .5em; margin: 1em;' + style += ' position: relative; z-index: 1000;' download_link.setAttribute('style', style); destination.insertBefore(download_link, destination.firstChild); @@ -228,6 +238,17 @@ function DDL_log(message) { } function _rai_get_actual_url(site, URL) { + + // SmoothStreaming manifest files get added without processing, for now: + if (URL.match(/.*\.csm$/)) { + var evt = document.createEvent('Event'); + evt.initEvent('UrlFetched', true, true); + evt.site = site; + evt.URL = URL; + document.dispatchEvent(evt); + return; + } + // http://www.neaveru.com/wordpress/index.php/2008/05/09/greasemonkey-bug-domnodeinserted-event-doesnt-allow-gm_xmlhttprequest/ setTimeout( function() { GM_xmlhttpRequest({ @@ -246,8 +267,8 @@ function _rai_get_actual_url(site, URL) { if (ref.length > 0) { href = ref[0].getAttribute('HREF');; - var evt = document.createEvent('Event'); - evt.initEvent('UrlFetched', true, true); + var evt = document.createEvent('Event'); + evt.initEvent('UrlFetched', true, true); evt.site = site; evt.URL = href; document.dispatchEvent(evt);