diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 96fdb725f..ae991b9db 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -115,7 +115,7 @@ 'use strict'; (function() { - var $, $$, Anonymize, ArchiveLink, Banner, Board, Build, Callbacks, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Labels, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, Report, ReportLink, RevealSpoilers, Rice, Sauce, Settings, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation, + var $, $$, Anonymize, ArchiveLink, Banner, Board, Build, Callbacks, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, Report, ReportLink, RevealSpoilers, Rice, Sauce, Settings, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation, __slice = [].slice, __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, __hasProp = {}.hasOwnProperty, @@ -12426,8 +12426,8 @@ ArchiveLink = { init: function() { - var div, entry, type, _i, _len, _ref; - if (!Conf['Menu'] || !Conf['Archive Link']) { + var div, entry, type, _i, _len, _ref, _ref1; + if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && Conf['Menu'] && Conf['Archive Link'])) { return; } div = $.el('div', { @@ -12447,9 +12447,9 @@ }, subEntries: [] }; - _ref = [['Post', 'post'], ['Name', 'name'], ['Tripcode', 'tripcode'], ['E-mail', 'email'], ['Subject', 'subject'], ['Filename', 'filename'], ['Image MD5', 'MD5']]; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - type = _ref[_i]; + _ref1 = [['Post', 'post'], ['Name', 'name'], ['Tripcode', 'tripcode'], ['Subject', 'subject'], ['Filename', 'filename'], ['Image MD5', 'MD5']]; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + type = _ref1[_i]; entry.subEntries.push(this.createSubEntry(type[0], type[1])); } return Menu.menu.addEntry(entry); @@ -12492,8 +12492,8 @@ DeleteLink = { init: function() { - var div, fileEl, fileEntry, postEl, postEntry; - if (!Conf['Menu'] || !Conf['Delete Link']) { + var div, fileEl, fileEntry, postEl, postEntry, _ref; + if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && Conf['Menu'] && Conf['Delete Link'])) { return; } div = $.el('div', { @@ -12584,6 +12584,7 @@ $.on(link, 'click', DeleteLink["delete"]); } else { if (resDoc.title === 'Updating index...') { + QR.cooldown["delete"](post); (post.origin || post).kill(fileOnly); } s = 'Deleted'; @@ -12629,14 +12630,30 @@ DownloadLink = { init: function() { - var a; - if (!Conf['Menu'] || !Conf['Download Link']) { + var a, _ref; + if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && Conf['Menu'] && Conf['Download Link'])) { return; } a = $.el('a', { className: 'download-link', textContent: 'Download file' }); + $.on(a, 'click', function(e) { + if (this.protocol === 'blob:') { + return true; + } + e.preventDefault(); + return CrossOrigin.file(this.href, (function(_this) { + return function(blob) { + if (blob) { + _this.href = URL.createObjectURL(blob); + return _this.click(); + } else { + return new Notice('error', "Could not download " + _this.href, 30); + } + }; + })(this)); + }); return Menu.menu.addEntry({ el: a, order: 100, @@ -12654,38 +12671,6 @@ } }; - Labels = { - init: function() { - if (!Conf['Menu']) { - return; - } - return Menu.menu.addEntry({ - el: $.el('div', { - textContent: 'Labels' - }), - order: 60, - open: function(post, addSubEntry) { - var label, labels, _i, _len; - labels = (post.origin || post).labels; - if (!labels.length) { - return false; - } - this.subEntries.length = 0; - for (_i = 0, _len = labels.length; _i < _len; _i++) { - label = labels[_i]; - addSubEntry({ - el: $.el('div', { - textContent: label - }) - }); - } - return true; - }, - subEntries: [] - }); - } - }; - Menu = { init: function() { var a; diff --git a/builds/crx/script.js b/builds/crx/script.js index 283cab3ff..03faff257 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -88,7 +88,7 @@ 'use strict'; (function() { - var $, $$, Anonymize, ArchiveLink, Banner, Board, Build, Callbacks, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Labels, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, Report, ReportLink, RevealSpoilers, Rice, Sauce, Settings, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation, + var $, $$, Anonymize, ArchiveLink, Banner, Board, Build, Callbacks, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, Report, ReportLink, RevealSpoilers, Rice, Sauce, Settings, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation, __slice = [].slice, __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, __hasProp = {}.hasOwnProperty, @@ -12448,8 +12448,8 @@ ArchiveLink = { init: function() { - var div, entry, type, _i, _len, _ref; - if (!Conf['Menu'] || !Conf['Archive Link']) { + var div, entry, type, _i, _len, _ref, _ref1; + if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && Conf['Menu'] && Conf['Archive Link'])) { return; } div = $.el('div', { @@ -12469,9 +12469,9 @@ }, subEntries: [] }; - _ref = [['Post', 'post'], ['Name', 'name'], ['Tripcode', 'tripcode'], ['E-mail', 'email'], ['Subject', 'subject'], ['Filename', 'filename'], ['Image MD5', 'MD5']]; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - type = _ref[_i]; + _ref1 = [['Post', 'post'], ['Name', 'name'], ['Tripcode', 'tripcode'], ['Subject', 'subject'], ['Filename', 'filename'], ['Image MD5', 'MD5']]; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + type = _ref1[_i]; entry.subEntries.push(this.createSubEntry(type[0], type[1])); } return Menu.menu.addEntry(entry); @@ -12514,8 +12514,8 @@ DeleteLink = { init: function() { - var div, fileEl, fileEntry, postEl, postEntry; - if (!Conf['Menu'] || !Conf['Delete Link']) { + var div, fileEl, fileEntry, postEl, postEntry, _ref; + if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && Conf['Menu'] && Conf['Delete Link'])) { return; } div = $.el('div', { @@ -12606,6 +12606,7 @@ $.on(link, 'click', DeleteLink["delete"]); } else { if (resDoc.title === 'Updating index...') { + QR.cooldown["delete"](post); (post.origin || post).kill(fileOnly); } s = 'Deleted'; @@ -12651,14 +12652,30 @@ DownloadLink = { init: function() { - var a; - if (!Conf['Menu'] || !Conf['Download Link']) { + var a, _ref; + if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && Conf['Menu'] && Conf['Download Link'])) { return; } a = $.el('a', { className: 'download-link', textContent: 'Download file' }); + $.on(a, 'click', function(e) { + if (this.protocol === 'blob:') { + return true; + } + e.preventDefault(); + return CrossOrigin.file(this.href, (function(_this) { + return function(blob) { + if (blob) { + _this.href = URL.createObjectURL(blob); + return _this.click(); + } else { + return new Notice('error', "Could not download " + _this.href, 30); + } + }; + })(this)); + }); return Menu.menu.addEntry({ el: a, order: 100, @@ -12676,38 +12693,6 @@ } }; - Labels = { - init: function() { - if (!Conf['Menu']) { - return; - } - return Menu.menu.addEntry({ - el: $.el('div', { - textContent: 'Labels' - }), - order: 60, - open: function(post, addSubEntry) { - var label, labels, _i, _len; - labels = (post.origin || post).labels; - if (!labels.length) { - return false; - } - this.subEntries.length = 0; - for (_i = 0, _len = labels.length; _i < _len; _i++) { - label = labels[_i]; - addSubEntry({ - el: $.el('div', { - textContent: label - }) - }); - } - return true; - }, - subEntries: [] - }); - } - }; - Menu = { init: function() { var a; diff --git a/src/Menu/ArchiveLink.coffee b/src/Menu/ArchiveLink.coffee index 0d38f935f..3f8a55eb4 100755 --- a/src/Menu/ArchiveLink.coffee +++ b/src/Menu/ArchiveLink.coffee @@ -1,6 +1,6 @@ ArchiveLink = init: -> - return if !Conf['Menu'] or !Conf['Archive Link'] + return unless g.VIEW in ['index', 'thread'] and Conf['Menu'] and Conf['Archive Link'] div = $.el 'div', textContent: 'Archive' @@ -16,7 +16,6 @@ ArchiveLink = ['Post', 'post'] ['Name', 'name'] ['Tripcode', 'tripcode'] - ['E-mail', 'email'] ['Subject', 'subject'] ['Filename', 'filename'] ['Image MD5', 'MD5'] diff --git a/src/Menu/DeleteLink.coffee b/src/Menu/DeleteLink.coffee index 864c81e33..99a832c6f 100755 --- a/src/Menu/DeleteLink.coffee +++ b/src/Menu/DeleteLink.coffee @@ -1,6 +1,6 @@ DeleteLink = init: -> - return if !Conf['Menu'] or !Conf['Delete Link'] + return unless g.VIEW in ['index', 'thread'] and Conf['Menu'] and Conf['Delete Link'] div = $.el 'div', className: 'delete-link' @@ -69,6 +69,7 @@ DeleteLink = else if resDoc.title is 'Updating index...' # We're 100% sure. + QR.cooldown.delete post (post.origin or post).kill fileOnly s = 'Deleted' link.textContent = s diff --git a/src/Menu/DownloadLink.coffee b/src/Menu/DownloadLink.coffee index 554649efe..3545f9d2e 100755 --- a/src/Menu/DownloadLink.coffee +++ b/src/Menu/DownloadLink.coffee @@ -1,10 +1,22 @@ DownloadLink = init: -> - return if !Conf['Menu'] or !Conf['Download Link'] + return unless g.VIEW in ['index', 'thread'] and Conf['Menu'] and Conf['Download Link'] a = $.el 'a', className: 'download-link' textContent: 'Download file' + + # 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.file @href, (blob) => + if blob + @href = URL.createObjectURL blob + @click() + else + new Notice 'error', "Could not download #{@href}", 30 + Menu.menu.addEntry el: a order: 100 diff --git a/src/Menu/Labels.coffee b/src/Menu/Labels.coffee deleted file mode 100644 index 0f04953c4..000000000 --- a/src/Menu/Labels.coffee +++ /dev/null @@ -1,15 +0,0 @@ -Labels = - init: -> - return if !Conf['Menu'] - - Menu.menu.addEntry - el: $.el 'div', textContent: 'Labels' - order: 60 - open: (post, addSubEntry) -> - {labels} = post.origin or post - return false unless labels.length - @subEntries.length = 0 - for label in labels - addSubEntry el: $.el 'div', textContent: label - true - subEntries: []