diff --git a/4chan_x.user.js b/4chan_x.user.js index 592a2d146..eb4452cca 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -331,14 +331,15 @@ return fd; }, ajax: function(url, callbacks, opts) { - var form, headers, key, r, type, upCallbacks, val; + var form, headers, key, r, responseType, type, upCallbacks, val; if (opts == null) { opts = {}; } - type = opts.type, headers = opts.headers, upCallbacks = opts.upCallbacks, form = opts.form; + type = opts.type, responseType = opts.responseType, headers = opts.headers, upCallbacks = opts.upCallbacks, form = opts.form; r = new XMLHttpRequest(); type || (type = form && 'post' || 'get'); r.open(type, url, true); + r.responseType = $.engine === 'presto' && responseType === 'document' ? '' : responseType || ''; for (key in headers) { val = headers[key]; r.setRequestHeader(key, val); @@ -2617,8 +2618,12 @@ return; } Updater.lastModified = this.getResponseHeader('Last-Modified'); - doc = d.implementation.createHTMLDocument(''); - doc.documentElement.innerHTML = this.response; + if ($.engine === 'presto') { + doc = d.implementation.createHTMLDocument(''); + doc.documentElement.innerHTML = this.response; + } else { + doc = this.response; + } lastPost = Updater.thread.lastElementChild; id = lastPost.id.slice(2); nodes = []; @@ -2670,6 +2675,7 @@ return Updater.request = $.ajax(url, { onload: Updater.cb.update }, { + responseType: 'document', headers: { 'If-Modified-Since': Updater.lastModified } diff --git a/script.coffee b/script.coffee index 6d2374bb6..07b9bd8f9 100644 --- a/script.coffee +++ b/script.coffee @@ -274,10 +274,15 @@ $.extend $, fd.append key, val if val fd ajax: (url, callbacks, opts={}) -> - {type, headers, upCallbacks, form} = opts + {type, responseType, headers, upCallbacks, form} = opts r = new XMLHttpRequest() type or= form and 'post' or 'get' r.open type, url, true + r.responseType = + if $.engine is 'presto' and responseType is 'document' + '' + else + responseType or '' for key, val of headers r.setRequestHeader key, val $.extend r, callbacks @@ -2058,8 +2063,11 @@ Updater = return Updater.lastModified = @getResponseHeader 'Last-Modified' - doc = d.implementation.createHTMLDocument '' - doc.documentElement.innerHTML = @response + if $.engine is 'presto' + doc = d.implementation.createHTMLDocument '' + doc.documentElement.innerHTML = @response + else + doc = @response lastPost = Updater.thread.lastElementChild id = lastPost.id[2..] @@ -2093,15 +2101,16 @@ Updater = retry: -> @count.textContent = 'Retry' - @count.className = null + @count.className = null @update() update: -> Updater.timer.textContent = 0 Updater.request?.abort() - #fool the cache + # Fool the cache. url = location.pathname + '?' + Date.now() Updater.request = $.ajax url, onload: Updater.cb.update, + responseType: 'document' headers: 'If-Modified-Since': Updater.lastModified Watcher =