Add a download link to the menu for compatible browsers. Close #102.
This commit is contained in:
parent
8dd9300541
commit
08e104f0fa
@ -77,7 +77,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var $, $$, Anonymize, ArchiveLink, AutoGif, Conf, Config, DeleteLink, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, Get, ImageExpand, ImageHover, Keybinds, Main, Menu, Nav, Options, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, ReplyHiding, ReportLink, RevealSpoilers, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Time, TitlePost, UI, Unread, Updater, Watcher, d, g, _base;
|
var $, $$, Anonymize, ArchiveLink, AutoGif, Conf, Config, DeleteLink, DownloadLink, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, Get, ImageExpand, ImageHover, Keybinds, Main, Menu, Nav, Options, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, ReplyHiding, ReportLink, RevealSpoilers, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Time, TitlePost, UI, Unread, Updater, Watcher, d, g, _base;
|
||||||
|
|
||||||
Config = {
|
Config = {
|
||||||
main: {
|
main: {
|
||||||
@ -112,7 +112,8 @@
|
|||||||
'Menu': [true, 'Add a drop-down menu in posts.'],
|
'Menu': [true, 'Add a drop-down menu in posts.'],
|
||||||
'Report Link': [true, 'Add a report link to the menu.'],
|
'Report Link': [true, 'Add a report link to the menu.'],
|
||||||
'Delete Link': [true, 'Add a delete link to the menu.'],
|
'Delete Link': [true, 'Add a delete link to the menu.'],
|
||||||
'Archive Link': [true, 'Add a archive link to the menu.']
|
'Download Link': [true, 'Add a download with original filename link to the menu. Chrome-only currently.'],
|
||||||
|
'Archive Link': [true, 'Add an archive link to the menu.']
|
||||||
},
|
},
|
||||||
Monitoring: {
|
Monitoring: {
|
||||||
'Thread Updater': [true, 'Update threads. Has more options in its own dialog.'],
|
'Thread Updater': [true, 'Update threads. Has more options in its own dialog.'],
|
||||||
@ -3203,6 +3204,7 @@
|
|||||||
fullname: span.title,
|
fullname: span.title,
|
||||||
shortname: span.textContent
|
shortname: span.textContent
|
||||||
};
|
};
|
||||||
|
node.setAttribute('data-filename', span.title);
|
||||||
return node.innerHTML = FileInfo.funk(FileInfo);
|
return node.innerHTML = FileInfo.funk(FileInfo);
|
||||||
},
|
},
|
||||||
setFormats: function() {
|
setFormats: function() {
|
||||||
@ -3996,6 +3998,31 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DownloadLink = {
|
||||||
|
init: function() {
|
||||||
|
var a;
|
||||||
|
if ($.el('a').download === void 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
a = $.el('a', {
|
||||||
|
className: 'download_link',
|
||||||
|
textContent: 'Download file'
|
||||||
|
});
|
||||||
|
return Menu.addEntry({
|
||||||
|
el: a,
|
||||||
|
open: function(post) {
|
||||||
|
var fileText;
|
||||||
|
a.href = post.img.parentNode.href;
|
||||||
|
fileText = post.fileInfo.firstElementChild;
|
||||||
|
return a.download = Conf['File Info Formatting'] ? fileText.dataset.filename : $('span', fileText).title;
|
||||||
|
},
|
||||||
|
requirement: function(post) {
|
||||||
|
return post.img;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
ArchiveLink = {
|
ArchiveLink = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var a;
|
var a;
|
||||||
@ -4675,6 +4702,9 @@
|
|||||||
if (Conf['Delete Link']) {
|
if (Conf['Delete Link']) {
|
||||||
DeleteLink.init();
|
DeleteLink.init();
|
||||||
}
|
}
|
||||||
|
if (Conf['Download Link']) {
|
||||||
|
DownloadLink.init();
|
||||||
|
}
|
||||||
if (Conf['Archive Link']) {
|
if (Conf['Archive Link']) {
|
||||||
ArchiveLink.init();
|
ArchiveLink.init();
|
||||||
}
|
}
|
||||||
@ -4949,7 +4979,8 @@ a[href="javascript:;"] {\
|
|||||||
border-bottom: 1px solid rgba(0, 0, 0, .25);\
|
border-bottom: 1px solid rgba(0, 0, 0, .25);\
|
||||||
display: block;\
|
display: block;\
|
||||||
outline: none;\
|
outline: none;\
|
||||||
padding: 3px 4px;\
|
padding: 3px 7px;\
|
||||||
|
text-decoration: none;\
|
||||||
}\
|
}\
|
||||||
.entry:last-child {\
|
.entry:last-child {\
|
||||||
border: none;\
|
border: none;\
|
||||||
|
|||||||
@ -28,7 +28,8 @@ Config =
|
|||||||
'Menu': [true, 'Add a drop-down menu in posts.']
|
'Menu': [true, 'Add a drop-down menu in posts.']
|
||||||
'Report Link': [true, 'Add a report link to the menu.']
|
'Report Link': [true, 'Add a report link to the menu.']
|
||||||
'Delete Link': [true, 'Add a delete link to the menu.']
|
'Delete Link': [true, 'Add a delete link to the menu.']
|
||||||
'Archive Link': [true, 'Add a archive link to the menu.']
|
'Download Link': [true, 'Add a download with original filename link to the menu. Chrome-only currently.']
|
||||||
|
'Archive Link': [true, 'Add an archive link to the menu.']
|
||||||
Monitoring:
|
Monitoring:
|
||||||
'Thread Updater': [true, 'Update threads. Has more options in its own dialog.']
|
'Thread Updater': [true, 'Update threads. Has more options in its own dialog.']
|
||||||
'Unread Count': [true, 'Show unread post count in tab title']
|
'Unread Count': [true, 'Show unread post count in tab title']
|
||||||
@ -2497,6 +2498,8 @@ FileInfo =
|
|||||||
resolution: span.previousSibling.textContent.match(/\d+x\d+|PDF/)[0]
|
resolution: span.previousSibling.textContent.match(/\d+x\d+|PDF/)[0]
|
||||||
fullname: span.title
|
fullname: span.title
|
||||||
shortname: span.textContent
|
shortname: span.textContent
|
||||||
|
# XXX GM/Scriptish
|
||||||
|
node.setAttribute 'data-filename', span.title
|
||||||
node.innerHTML = FileInfo.funk FileInfo
|
node.innerHTML = FileInfo.funk FileInfo
|
||||||
setFormats: ->
|
setFormats: ->
|
||||||
code = Conf['fileInfo'].replace /%([BKlLMnNprs])/g, (s, c) ->
|
code = Conf['fileInfo'].replace /%([BKlLMnNprs])/g, (s, c) ->
|
||||||
@ -3137,6 +3140,26 @@ ReportLink =
|
|||||||
set = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=685,height=200"
|
set = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=685,height=200"
|
||||||
window.open url, id, set
|
window.open url, id, set
|
||||||
|
|
||||||
|
DownloadLink =
|
||||||
|
init: ->
|
||||||
|
# Test for download feature support.
|
||||||
|
return if $.el('a').download is undefined
|
||||||
|
a = $.el 'a',
|
||||||
|
className: 'download_link'
|
||||||
|
textContent: 'Download file'
|
||||||
|
Menu.addEntry
|
||||||
|
el: a
|
||||||
|
open: (post) ->
|
||||||
|
a.href = post.img.parentNode.href
|
||||||
|
fileText = post.fileInfo.firstElementChild
|
||||||
|
a.download =
|
||||||
|
if Conf['File Info Formatting']
|
||||||
|
fileText.dataset.filename
|
||||||
|
else
|
||||||
|
$('span', fileText).title
|
||||||
|
requirement: (post) ->
|
||||||
|
post.img
|
||||||
|
|
||||||
ArchiveLink =
|
ArchiveLink =
|
||||||
init: ->
|
init: ->
|
||||||
a = $.el 'a',
|
a = $.el 'a',
|
||||||
@ -3633,6 +3656,9 @@ Main =
|
|||||||
if Conf['Delete Link']
|
if Conf['Delete Link']
|
||||||
DeleteLink.init()
|
DeleteLink.init()
|
||||||
|
|
||||||
|
if Conf['Download Link']
|
||||||
|
DownloadLink.init()
|
||||||
|
|
||||||
if Conf['Archive Link']
|
if Conf['Archive Link']
|
||||||
ArchiveLink.init()
|
ArchiveLink.init()
|
||||||
|
|
||||||
@ -3848,7 +3874,8 @@ a[href="javascript:;"] {
|
|||||||
border-bottom: 1px solid rgba(0, 0, 0, .25);
|
border-bottom: 1px solid rgba(0, 0, 0, .25);
|
||||||
display: block;
|
display: block;
|
||||||
outline: none;
|
outline: none;
|
||||||
padding: 3px 4px;
|
padding: 3px 7px;
|
||||||
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
.entry:last-child {
|
.entry:last-child {
|
||||||
border: none;
|
border: none;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user