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