Chromium now follows Firefox's policy on the download attribute.

This commit is contained in:
ccd0 2014-06-12 09:58:02 -07:00
parent ce6e6b52f5
commit 45d4d2241b

View File

@ -6,19 +6,16 @@ DownloadLink =
className: 'download-link' className: 'download-link'
textContent: 'Download file' textContent: 'Download file'
<% if (type === 'userscript') { %> # Specifying the filename with the download attribute only works for same-origin links.
unless chrome? $.on a, 'click', (e) ->
# Firefox places same-origin restrictions on links with the download attribute. return true if @protocol is 'blob:'
$.on a, 'click', (e) -> e.preventDefault()
return true if @protocol is 'blob:' CrossOrigin.request @href, (blob) =>
e.preventDefault() if blob
CrossOrigin.request @href, (blob) => @href = URL.createObjectURL blob
if blob @click()
@href = URL.createObjectURL blob else
@click() new Notice 'error', "Could not download #{file.URL}", 30
else
new Notice 'error', "Could not download #{file.URL}", 30
<% } %>
$.event 'AddMenuEntry', $.event 'AddMenuEntry',
type: 'post' type: 'post'