diff --git a/4chan_x.user.js b/4chan_x.user.js index f8abe22d6..dcf971914 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -332,15 +332,14 @@ return fd; }, ajax: function(url, callbacks, opts) { - var form, headers, key, r, responseType, type, upCallbacks, val; + var form, headers, key, r, type, upCallbacks, val; if (opts == null) { opts = {}; } - type = opts.type, responseType = opts.responseType, headers = opts.headers, upCallbacks = opts.upCallbacks, form = opts.form; + type = opts.type, 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); @@ -2132,7 +2131,6 @@ }; opts = { form: $.formData(post), - responseType: 'document', upCallbacks: { onload: function() { return QR.status({ @@ -2148,14 +2146,10 @@ }; return QR.ajax = $.ajax($.id('postForm').parentNode.action, callbacks, opts); }, - response: function(response) { + response: function(html) { var bs, doc, err, msg, persona, postNumber, reply, thread, _, _ref; - if ($.engine === 'presto') { - doc = d.implementation.createHTMLDocument(''); - doc.documentElement.innerHTML = response; - } else { - doc = response; - } + doc = d.implementation.createHTMLDocument(''); + doc.documentElement.innerHTML = html; if (doc.title === '4chan - Banned') { bs = $$('b', doc); err = $.el('span', { @@ -2639,12 +2633,8 @@ return; } Updater.lastModified = this.getResponseHeader('Last-Modified'); - if ($.engine === 'presto') { - doc = d.implementation.createHTMLDocument(''); - doc.documentElement.innerHTML = this.response; - } else { - doc = this.response; - } + doc = d.implementation.createHTMLDocument(''); + doc.documentElement.innerHTML = this.response; lastPost = Updater.thread.lastElementChild; id = lastPost.id.slice(2); nodes = []; @@ -2696,7 +2686,6 @@ return Updater.request = $.ajax(url, { onload: Updater.cb.update }, { - responseType: 'document', headers: { 'If-Modified-Since': Updater.lastModified } @@ -3764,18 +3753,13 @@ return DeleteButton.error(self); } }, { - form: $.formData(form), - responseType: 'document' + form: $.formData(form) }); }, - load: function(self, response) { + load: function(self, html) { var doc, msg, s; - if ($.engine === 'presto') { - doc = d.implementation.createHTMLDocument(''); - doc.documentElement.innerHTML = response; - } else { - doc = response; - } + doc = d.implementation.createHTMLDocument(''); + doc.documentElement.innerHTML = html; if (doc.title === '4chan - Banned') { s = 'Banned!'; } else if (msg = doc.getElementById('errmsg')) { diff --git a/script.coffee b/script.coffee index c54ceec97..cb72e3a67 100644 --- a/script.coffee +++ b/script.coffee @@ -274,15 +274,10 @@ $.extend $, fd.append key, val if val fd ajax: (url, callbacks, opts={}) -> - {type, responseType, headers, upCallbacks, form} = opts + {type, 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 @@ -1618,7 +1613,6 @@ QR = textContent: 'Connection error, or you are banned.' opts = form: $.formData post - responseType: 'document' upCallbacks: onload: -> # Upload done, waiting for response. @@ -1629,12 +1623,9 @@ QR = QR.ajax = $.ajax $.id('postForm').parentNode.action, callbacks, opts - response: (response) -> - if $.engine is 'presto' - doc = d.implementation.createHTMLDocument '' - doc.documentElement.innerHTML = response - else - doc = response + response: (html) -> + doc = d.implementation.createHTMLDocument '' + doc.documentElement.innerHTML = html if doc.title is '4chan - Banned' # Ban/warn check bs = $$ 'b', doc err = $.el 'span', @@ -2080,11 +2071,8 @@ Updater = return Updater.lastModified = @getResponseHeader 'Last-Modified' - if $.engine is 'presto' - doc = d.implementation.createHTMLDocument '' - doc.documentElement.innerHTML = @response - else - doc = @response + doc = d.implementation.createHTMLDocument '' + doc.documentElement.innerHTML = @response lastPost = Updater.thread.lastElementChild id = lastPost.id[2..] @@ -2118,16 +2106,15 @@ 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 = @@ -2954,15 +2941,11 @@ DeleteButton = onerror: -> DeleteButton.error self }, { form: $.formData form - responseType: 'document' } - load: (self, response) -> - if $.engine is 'presto' - doc = d.implementation.createHTMLDocument '' - doc.documentElement.innerHTML = response - else - doc = response + load: (self, html) -> + doc = d.implementation.createHTMLDocument '' + doc.documentElement.innerHTML = html if doc.title is '4chan - Banned' # Ban/warn check s = 'Banned!' else if msg = doc.getElementById 'errmsg' # error!