diff --git a/4chan_x.user.js b/4chan_x.user.js index fd9708603..955f028f8 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1971,7 +1971,9 @@ QR.mimeTypes.push(''); fileInput = $('input[type=file]', QR.el); fileInput.max = $('input[name=MAX_FILE_SIZE]').value; - fileInput.accept = mimeTypes; + if ($.engine !== 'presto') { + fileInput.accept = mimeTypes; + } QR.spoiler = !!$('input[name=spoiler]'); spoiler = $('#spoilerLabel', QR.el); spoiler.hidden = !QR.spoiler; @@ -3670,7 +3672,7 @@ a.className = 'quotelink'; a.setAttribute('onclick', "replyhl('" + id + "');"); } else { - a.href = Redirect.thread(board, id, 'post'); + a.href = Redirect.thread(board, 0, id); a.className = 'deadlink'; a.target = '_blank'; if (Redirect.post(board, id)) { @@ -3944,26 +3946,15 @@ }; Redirect = { - init: function() { - var path, url; - url = location.hostname === 'images.4chan.org' ? (path = location.pathname.split('/'), this.image(path[1], path[3])) : /^\d+$/.test(g.THREAD_ID) ? this.thread() : void 0; - if (url) { - return location.href = url; - } - }, image: function(board, filename) { - if (!Conf['404 Redirect']) { - return; - } switch (board) { case 'a': - case 'co': case 'jp': case 'm': case 'tg': case 'u': case 'vg': - return "http://archive.foolz.us/" + board + "/full_image/" + filename; + return "//archive.foolz.us/" + board + "/full_image/" + filename; } }, post: function(board, postID) { @@ -3977,22 +3968,18 @@ case 'u': case 'v': case 'vg': + case 'dev': + case 'foolz': + case 'kuku': return "//archive.foolz.us/api/chan/post/board/" + board + "/num/" + postID + "/format/json"; } }, - thread: function(board, id, mode) { - if (board == null) { - board = g.BOARD; - } - if (id == null) { - id = g.THREAD_ID; - } - if (mode == null) { - mode = 'thread'; - } - if (!(Conf['404 Redirect'] || mode === 'post')) { - return; + thread: function(board, threadID, postID) { + var path, url; + if (postID) { + postID = postID.match(/\d+/)[0]; } + path = threadID ? "" + board + "/thread/" + threadID : "" + board + "/post/" + postID; switch (board) { case 'a': case 'co': @@ -4003,31 +3990,57 @@ case 'u': case 'v': case 'vg': - return "http://archive.foolz.us/" + board + "/" + mode + "/" + id + "/"; + case 'dev': + case 'foolz': + case 'kuku': + url = "//archive.foolz.us/" + path + "/"; + if (threadID && postID) { + url += "#" + postID; + } + break; case 'lit': - return "http://fuuka.warosu.org/" + board + "/" + mode + "/" + id; + url = "//fuuka.warosu.org/" + path; + if (threadID && postID) { + url += "#p" + postID; + } + break; case 'diy': case 'g': case 'k': case 'sci': - return "https://archive.installgentoo.net/" + board + "/" + mode + "/" + id; + url = "//archive.installgentoo.net/" + path; + if (threadID && postID) { + url += "#p" + postID; + } + break; case 'cgl': case 'mu': case 'w': - return "http://archive.rebeccablacktech.com/" + board + "/" + mode + "/" + id; + url = "//archive.rebeccablacktech.com/" + path; + if (threadID && postID) { + url += "#p" + postID; + } + break; case 'an': case 'toy': case 'x': - return "http://archive.xfiles.to/" + board + "/" + mode + "/" + id; + url = "http://archive.xfiles.to/" + path; + if (threadID && postID) { + url += "#p" + postID; + } + break; case 'e': - return "https://md401.homelinux.net/4chan/cgi-board.pl/" + board + "/" + mode + "/" + id; + url = "https://md401.homelinux.net/4chan/cgi-board.pl/" + path; + if (threadID && postID) { + url += "#p" + postID; + } + break; default: - if (mode === 'thread') { - return "//boards.4chan.org/" + board + "/"; - } else { - return null; + if (threadID) { + url = "//boards.4chan.org/" + board + "/"; } } + return url || null; } }; @@ -4331,8 +4344,13 @@ return; case 'images.4chan.org': $.ready(function() { - if (d.title === '4chan - 404') { - return Redirect.init(); + var url; + if (d.title === '4chan - 404' && Conf['404 Redirect']) { + path = location.pathname.split('/'); + url = Redirect.image(path[1], path[3]); + if (url) { + return location.href = url; + } } }); return; @@ -4432,7 +4450,9 @@ ready: function() { var MutationObserver, a, board, nav, node, nodes, observer, _i, _j, _len, _len1, _ref, _ref1; if (d.title === '4chan - 404') { - Redirect.init(); + if (Conf['404 Redirect'] && /^\d+$/.test(g.THREAD_ID)) { + location.href = Redirect.thread(g.BOARD, g.THREAD_ID, location.hash); + } return; } if (!$.id('navtopr')) { @@ -4838,7 +4858,7 @@ textarea.field {\ min-height: 120px;\ }\ #qr .field:only-child {\ - display: block;\ + display: -webkit-box;\ min-width: 100%;\ }\ .captcha {\ diff --git a/script.coffee b/script.coffee index 4ae7b8ec2..ded82224a 100644 --- a/script.coffee +++ b/script.coffee @@ -1474,7 +1474,7 @@ QR = QR.mimeTypes.push '' fileInput = $ 'input[type=file]', QR.el fileInput.max = $('input[name=MAX_FILE_SIZE]').value - fileInput.accept = mimeTypes + fileInput.accept = mimeTypes if $.engine isnt 'presto' # Opera's accept attribute is fucked up QR.spoiler = !!$ 'input[name=spoiler]' spoiler = $ '#spoilerLabel', QR.el @@ -2864,7 +2864,7 @@ Quotify = a.className = 'quotelink' a.setAttribute 'onclick', "replyhl('#{id}');" else - a.href = Redirect.thread board, id, 'post' + a.href = Redirect.thread board, 0, id a.className = 'deadlink' a.target = '_blank' if Redirect.post board, id @@ -3089,51 +3089,59 @@ Favicon = dead: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAAP8AAP///////yH5BAEKAAIALAAAAAAQABAAAAIvlI+pq+D9DAgUoFkPDlbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw==' Redirect = - init: -> - url = - if location.hostname is 'images.4chan.org' - path = location.pathname.split '/' - @image path[1], path[3] - else if /^\d+$/.test g.THREAD_ID - @thread() - location.href = url if url image: (board, filename) -> # Do not use g.BOARD, the image url can originate from a cross-quote. - return unless Conf['404 Redirect'] switch board - when 'a', 'co', 'jp', 'm', 'tg', 'u', 'vg' - "http://archive.foolz.us/#{board}/full_image/#{filename}" + when 'a', 'jp', 'm', 'tg', 'u', 'vg' + "//archive.foolz.us/#{board}/full_image/#{filename}" # these will work whenever https://github.com/eksopl/fuuka/issues/23 is done # when 'cgl', 'g', 'w' - # "http://archive.rebeccablacktech.com/#{board}/full_image/#{filename}" + # "//archive.rebeccablacktech.com/#{board}/full_image/#{filename}" # when 'an', 'toy', 'x' # "http://archive.xfiles.to/#{board}/full_image/#{filename}" # when 'e' # "https://md401.homelinux.net/4chan/cgi-board.pl/#{board}/full_image/#{filename}" post: (board, postID) -> switch board - when 'a', 'co', 'jp', 'm', 'tg', 'tv', 'u', 'v', 'vg' + when 'a', 'co', 'jp', 'm', 'tg', 'tv', 'u', 'v', 'vg', 'dev', 'foolz', 'kuku' "//archive.foolz.us/api/chan/post/board/#{board}/num/#{postID}/format/json" - thread: (board=g.BOARD, id=g.THREAD_ID, mode='thread') -> - return unless Conf['404 Redirect'] or mode is 'post' - switch board - when 'a', 'co', 'jp', 'm', 'tg', 'tv', 'u', 'v', 'vg' - "http://archive.foolz.us/#{board}/#{mode}/#{id}/" - when 'lit' - "http://fuuka.warosu.org/#{board}/#{mode}/#{id}" - when 'diy', 'g', 'k', 'sci' - "https://archive.installgentoo.net/#{board}/#{mode}/#{id}" - when 'cgl', 'mu', 'w' - "http://archive.rebeccablacktech.com/#{board}/#{mode}/#{id}" - when 'an', 'toy', 'x' - "http://archive.xfiles.to/#{board}/#{mode}/#{id}" - when 'e' - "https://md401.homelinux.net/4chan/cgi-board.pl/#{board}/#{mode}/#{id}" + thread: (board, threadID, postID) -> + # keep the number only if the location.hash was sent f.e. + postID = postID.match(/\d+/)[0] if postID + path = + if threadID + "#{board}/thread/#{threadID}" else - if mode is 'thread' - "//boards.4chan.org/#{board}/" - else - null + "#{board}/post/#{postID}" + switch board + when 'a', 'co', 'jp', 'm', 'tg', 'tv', 'u', 'v', 'vg', 'dev', 'foolz', 'kuku' + url = "//archive.foolz.us/#{path}/" + if threadID and postID + url += "##{postID}" + when 'lit' + url = "//fuuka.warosu.org/#{path}" + if threadID and postID + url += "#p#{postID}" + when 'diy', 'g', 'k', 'sci' + url = "//archive.installgentoo.net/#{path}" + if threadID and postID + url += "#p#{postID}" + when 'cgl', 'mu', 'w' + url = "//archive.rebeccablacktech.com/#{path}" + if threadID and postID + url += "#p#{postID}" + when 'an', 'toy', 'x' + url = "http://archive.xfiles.to/#{path}" + if threadID and postID + url += "#p#{postID}" + when 'e' + url = "https://md401.homelinux.net/4chan/cgi-board.pl/#{path}" + if threadID and postID + url += "#p#{postID}" + else + if threadID + url = "//boards.4chan.org/#{board}/" + url or null ImageHover = init: -> @@ -3344,7 +3352,11 @@ Main = window.location = 'javascript:Recaptcha.reload()' if e.keyCode is 8 and not e.target.value return when 'images.4chan.org' - $.ready -> Redirect.init() if d.title is '4chan - 404' + $.ready -> + if d.title is '4chan - 404' and Conf['404 Redirect'] + path = location.pathname.split '/' + url = Redirect.image path[1], path[3] + location.href = url if url return $.ready Options.init @@ -3438,7 +3450,8 @@ Main = ready: -> if d.title is '4chan - 404' - Redirect.init() + if Conf['404 Redirect'] and /^\d+$/.test g.THREAD_ID + location.href = Redirect.thread g.BOARD, g.THREAD_ID, location.hash return unless $.id 'navtopr' return @@ -3788,7 +3801,7 @@ textarea.field { min-height: 120px; } #qr .field:only-child { - display: block; + display: -webkit-box; min-width: 100%; } .captcha {