From ae7e7cdf8850d8a36789b6c78179c5b51b53d666 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 1 May 2011 17:21:21 +0200 Subject: [PATCH 1/4] Update to Coffee-script master --- 4chan_x.js | 76 +++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index da7041d1e..b4153ecb2 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -60,7 +60,7 @@ (function() { var $, $$, Favicon, NAMESPACE, Recaptcha, anonymize, config, d, expandComment, expandThread, g, imageHover, imgExpand, imgGif, imgPreloading, keybinds, localize, log, main, nav, nodeInserted, options, qr, quickReport, redirect, replyHiding, sauce, threadHiding, threading, titlePost, ui, unread, updater, watcher, _config, _ref; var __slice = Array.prototype.slice; - if (typeof console !== "undefined" && console !== null) { + if (typeof console != "undefined" && console !== null) { log = function(arg) { return console.log(arg); }; @@ -381,7 +381,7 @@ } } }); - if (typeof GM_deleteValue !== "undefined" && GM_deleteValue !== null) { + if (typeof GM_deleteValue != "undefined" && GM_deleteValue !== null) { $.extend($, { deleteValue: function(name) { return GM_deleteValue(name); @@ -1188,8 +1188,8 @@ in the global context. */ return $.globalEval(function() { - var data, _ref3; - data = ((_ref3 = document.querySelector('table font b')) != null ? _ref3.firstChild.textContent : void 0) || ''; + var data, _ref; + data = ((_ref = document.querySelector('table font b')) != null ? _ref.firstChild.textContent : void 0) || ''; return parent.postMessage(data, '*'); }); } @@ -1594,17 +1594,17 @@ span = _ref[_i]; suffix = $('a', span).href; _results.push((function() { - var _len2, _results2; - _results2 = []; - for (i = 0, _len2 = prefixes.length; i < _len2; i++) { + var _len, _results; + _results = []; + for (i = 0, _len = prefixes.length; i < _len; i++) { prefix = prefixes[i]; link = $.el('a', { textContent: names[i], href: prefix + suffix }); - _results2.push($.append(span, $.tn(' '), link)); + _results.push($.append(span, $.tn(' '), link)); } - return _results2; + return _results; })()); } return _results; @@ -1792,10 +1792,10 @@ }; Recaptcha = { init: function() { - var el, recaptcha, _i, _len, _ref2; - _ref2 = $$('#recaptcha_table a'); - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - el = _ref2[_i]; + var el, recaptcha, _i, _len, _ref; + _ref = $$('#recaptcha_table a'); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + el = _ref[_i]; el.tabIndex = 1; } recaptcha = $('#recaptcha_response_field'); @@ -1811,13 +1811,13 @@ } }; nodeInserted = function(e) { - var callback, dialog, target, _i, _len, _ref2, _results; + var callback, dialog, target, _i, _len, _ref, _results; target = e.target; if (target.nodeName === 'TABLE') { - _ref2 = g.callbacks; + _ref = g.callbacks; _results = []; - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - callback = _ref2[_i]; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + callback = _ref[_i]; _results.push(callback(target)); } return _results; @@ -1922,11 +1922,11 @@ }, cb: { node: function(root) { - var thumb, _i, _len, _ref2, _results; - _ref2 = $$('img[md5]', root); + var thumb, _i, _len, _ref, _results; + _ref = $$('img[md5]', root); _results = []; - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - thumb = _ref2[_i]; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + thumb = _ref[_i]; $.bind(thumb.parentNode, 'click', imgExpand.cb.toggle); _results.push(imgExpand.on ? imgExpand.toggle(thumb) : void 0); } @@ -1961,12 +1961,12 @@ } }, typeChange: function(e) { - var img, _i, _len, _ref2, _results; + var img, _i, _len, _ref, _results; imgExpand.foo(); - _ref2 = $$('img[md5] + img'); + _ref = $$('img[md5] + img'); _results = []; - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - img = _ref2[_i]; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + img = _ref[_i]; _results.push(imgExpand.resize(img)); } return _results; @@ -2009,9 +2009,9 @@ return imgExpand.type = $('#imageType').value; }, resize: function(img) { - var imgHeight, imgWidth, maxHeight, maxWidth, maxWidthOP, maxWidthReply, ratio, type, _, _ref2; + var imgHeight, imgWidth, maxHeight, maxWidth, maxWidthOP, maxWidthReply, ratio, type, _, _ref; maxWidthOP = imgExpand.maxWidthOP, maxWidthReply = imgExpand.maxWidthReply, maxHeight = imgExpand.maxHeight, type = imgExpand.type; - _ref2 = $.x("preceding::span[@class][1]/text()[2]", img).textContent.match(/(\d+)x(\d+)/), _ = _ref2[0], imgWidth = _ref2[1], imgHeight = _ref2[2]; + _ref = $.x("preceding::span[@class][1]/text()[2]", img).textContent.match(/(\d+)x(\d+)/), _ = _ref[0], imgWidth = _ref[1], imgHeight = _ref[2]; imgWidth = Number(imgWidth); imgHeight = Number(imgHeight); if (img.parentNode.parentNode.nodeName === 'TD') { @@ -2035,15 +2035,15 @@ } }, dialog: function() { - var controls, delform, imageType, option, _i, _len, _ref2; + var controls, delform, imageType, option, _i, _len, _ref; controls = $.el('div', { id: 'imgControls', innerHTML: " " }); imageType = $.getValue('imageType', 'full'); - _ref2 = $$('option', controls); - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - option = _ref2[_i]; + _ref = $$('option', controls); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + option = _ref[_i]; if (option.textContent === imageType) { option.selected = true; break; @@ -2064,7 +2064,7 @@ }; main = { init: function() { - var DAY, callback, cutoff, hiddenThreads, id, lastChecked, now, pathname, temp, timestamp, tzOffset, _i, _len, _ref2, _ref3; + var DAY, callback, cutoff, hiddenThreads, id, lastChecked, now, pathname, temp, timestamp, tzOffset, _i, _len, _ref, _ref2; pathname = location.pathname.substring(1).split('/'); g.BOARD = pathname[0], temp = pathname[1]; if (temp === 'res') { @@ -2103,9 +2103,9 @@ delete hiddenThreads[id]; } } - _ref2 = g.hiddenReplies; - for (id in _ref2) { - timestamp = _ref2[id]; + _ref = g.hiddenReplies; + for (id in _ref) { + timestamp = _ref[id]; if (timestamp < cutoff) { delete g.hiddenReplies[id]; } @@ -2185,9 +2185,9 @@ expandComment.init(); } } - _ref3 = g.callbacks; - for (_i = 0, _len = _ref3.length; _i < _len; _i++) { - callback = _ref3[_i]; + _ref2 = g.callbacks; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + callback = _ref2[_i]; callback(); } $.bind(d.body, 'DOMNodeInserted', nodeInserted); From 4949d707c46aad8bd4711d85b10c1e0b1934318e Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 1 May 2011 17:22:34 +0200 Subject: [PATCH 2/4] Fix OP comment expansion, fix #54 --- 4chan_x.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index b4153ecb2..8e42b2b83 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -468,7 +468,7 @@ innerHTML: xhr.responseText }); if (threadID === replyID) { - bq = $('blockqoute', body); + bq = $('blockquote', body); } else { _ref = $$('td[id]', body); for (_i = 0, _len = _ref.length; _i < _len; _i++) { diff --git a/script.coffee b/script.coffee index b495c1536..7edab72ad 100644 --- a/script.coffee +++ b/script.coffee @@ -309,7 +309,7 @@ expandComment = innerHTML: xhr.responseText if threadID is replyID - bq = $ 'blockqoute', body + bq = $ 'blockquote', body else #css selectors don't like ids starting with numbers, # getElementById only works for root document. From a683331a9e5317a38a2483b02e1dec996412b00d Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 1 May 2011 17:34:40 +0200 Subject: [PATCH 3/4] Fix OP image expanding if there is not reply, fix #53 --- 4chan_x.js | 9 +++++---- script.coffee | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 8e42b2b83..85c837c30 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1999,10 +1999,11 @@ foo: function() { var crap, formWidth, left, table, td; formWidth = $('form[name=delform]').getBoundingClientRect().width; - td = $('td.reply'); - table = td.parentNode.parentNode.parentNode; - left = td.getBoundingClientRect().left - table.getBoundingClientRect().left; - crap = td.getBoundingClientRect().width - parseInt(getComputedStyle(td).width); + if (td = $('td.reply')) { + table = td.parentNode.parentNode.parentNode; + left = td.getBoundingClientRect().left - table.getBoundingClientRect().left; + crap = td.getBoundingClientRect().width - parseInt(getComputedStyle(td).width); + } imgExpand.maxWidthOP = formWidth; imgExpand.maxWidthReply = formWidth - left - crap; imgExpand.maxHeight = d.body.clientHeight; diff --git a/script.coffee b/script.coffee index 7edab72ad..1a2366686 100644 --- a/script.coffee +++ b/script.coffee @@ -1518,10 +1518,10 @@ imgExpand = foo: -> formWidth = $('form[name=delform]').getBoundingClientRect().width - td = $('td.reply') - table = td.parentNode.parentNode.parentNode - left = td.getBoundingClientRect().left - table.getBoundingClientRect().left - crap = td.getBoundingClientRect().width - parseInt(getComputedStyle(td).width) + if td = $('td.reply') + table = td.parentNode.parentNode.parentNode + left = td.getBoundingClientRect().left - table.getBoundingClientRect().left + crap = td.getBoundingClientRect().width - parseInt(getComputedStyle(td).width) imgExpand.maxWidthOP = formWidth imgExpand.maxWidthReply = formWidth - left - crap From 145fd26a3f293bb25cd5590d937472b0e3798640 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 1 May 2011 21:08:28 +0200 Subject: [PATCH 4/4] Revert coffee-script to 7efea4b --- 4chan_x.js | 76 +++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 85c837c30..5bb9b0ef8 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -60,7 +60,7 @@ (function() { var $, $$, Favicon, NAMESPACE, Recaptcha, anonymize, config, d, expandComment, expandThread, g, imageHover, imgExpand, imgGif, imgPreloading, keybinds, localize, log, main, nav, nodeInserted, options, qr, quickReport, redirect, replyHiding, sauce, threadHiding, threading, titlePost, ui, unread, updater, watcher, _config, _ref; var __slice = Array.prototype.slice; - if (typeof console != "undefined" && console !== null) { + if (typeof console !== "undefined" && console !== null) { log = function(arg) { return console.log(arg); }; @@ -381,7 +381,7 @@ } } }); - if (typeof GM_deleteValue != "undefined" && GM_deleteValue !== null) { + if (typeof GM_deleteValue !== "undefined" && GM_deleteValue !== null) { $.extend($, { deleteValue: function(name) { return GM_deleteValue(name); @@ -1188,8 +1188,8 @@ in the global context. */ return $.globalEval(function() { - var data, _ref; - data = ((_ref = document.querySelector('table font b')) != null ? _ref.firstChild.textContent : void 0) || ''; + var data, _ref3; + data = ((_ref3 = document.querySelector('table font b')) != null ? _ref3.firstChild.textContent : void 0) || ''; return parent.postMessage(data, '*'); }); } @@ -1594,17 +1594,17 @@ span = _ref[_i]; suffix = $('a', span).href; _results.push((function() { - var _len, _results; - _results = []; - for (i = 0, _len = prefixes.length; i < _len; i++) { + var _len2, _results2; + _results2 = []; + for (i = 0, _len2 = prefixes.length; i < _len2; i++) { prefix = prefixes[i]; link = $.el('a', { textContent: names[i], href: prefix + suffix }); - _results.push($.append(span, $.tn(' '), link)); + _results2.push($.append(span, $.tn(' '), link)); } - return _results; + return _results2; })()); } return _results; @@ -1792,10 +1792,10 @@ }; Recaptcha = { init: function() { - var el, recaptcha, _i, _len, _ref; - _ref = $$('#recaptcha_table a'); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - el = _ref[_i]; + var el, recaptcha, _i, _len, _ref2; + _ref2 = $$('#recaptcha_table a'); + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + el = _ref2[_i]; el.tabIndex = 1; } recaptcha = $('#recaptcha_response_field'); @@ -1811,13 +1811,13 @@ } }; nodeInserted = function(e) { - var callback, dialog, target, _i, _len, _ref, _results; + var callback, dialog, target, _i, _len, _ref2, _results; target = e.target; if (target.nodeName === 'TABLE') { - _ref = g.callbacks; + _ref2 = g.callbacks; _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - callback = _ref[_i]; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + callback = _ref2[_i]; _results.push(callback(target)); } return _results; @@ -1922,11 +1922,11 @@ }, cb: { node: function(root) { - var thumb, _i, _len, _ref, _results; - _ref = $$('img[md5]', root); + var thumb, _i, _len, _ref2, _results; + _ref2 = $$('img[md5]', root); _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - thumb = _ref[_i]; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + thumb = _ref2[_i]; $.bind(thumb.parentNode, 'click', imgExpand.cb.toggle); _results.push(imgExpand.on ? imgExpand.toggle(thumb) : void 0); } @@ -1961,12 +1961,12 @@ } }, typeChange: function(e) { - var img, _i, _len, _ref, _results; + var img, _i, _len, _ref2, _results; imgExpand.foo(); - _ref = $$('img[md5] + img'); + _ref2 = $$('img[md5] + img'); _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - img = _ref[_i]; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + img = _ref2[_i]; _results.push(imgExpand.resize(img)); } return _results; @@ -2010,9 +2010,9 @@ return imgExpand.type = $('#imageType').value; }, resize: function(img) { - var imgHeight, imgWidth, maxHeight, maxWidth, maxWidthOP, maxWidthReply, ratio, type, _, _ref; + var imgHeight, imgWidth, maxHeight, maxWidth, maxWidthOP, maxWidthReply, ratio, type, _, _ref2; maxWidthOP = imgExpand.maxWidthOP, maxWidthReply = imgExpand.maxWidthReply, maxHeight = imgExpand.maxHeight, type = imgExpand.type; - _ref = $.x("preceding::span[@class][1]/text()[2]", img).textContent.match(/(\d+)x(\d+)/), _ = _ref[0], imgWidth = _ref[1], imgHeight = _ref[2]; + _ref2 = $.x("preceding::span[@class][1]/text()[2]", img).textContent.match(/(\d+)x(\d+)/), _ = _ref2[0], imgWidth = _ref2[1], imgHeight = _ref2[2]; imgWidth = Number(imgWidth); imgHeight = Number(imgHeight); if (img.parentNode.parentNode.nodeName === 'TD') { @@ -2036,15 +2036,15 @@ } }, dialog: function() { - var controls, delform, imageType, option, _i, _len, _ref; + var controls, delform, imageType, option, _i, _len, _ref2; controls = $.el('div', { id: 'imgControls', innerHTML: " " }); imageType = $.getValue('imageType', 'full'); - _ref = $$('option', controls); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - option = _ref[_i]; + _ref2 = $$('option', controls); + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + option = _ref2[_i]; if (option.textContent === imageType) { option.selected = true; break; @@ -2065,7 +2065,7 @@ }; main = { init: function() { - var DAY, callback, cutoff, hiddenThreads, id, lastChecked, now, pathname, temp, timestamp, tzOffset, _i, _len, _ref, _ref2; + var DAY, callback, cutoff, hiddenThreads, id, lastChecked, now, pathname, temp, timestamp, tzOffset, _i, _len, _ref2, _ref3; pathname = location.pathname.substring(1).split('/'); g.BOARD = pathname[0], temp = pathname[1]; if (temp === 'res') { @@ -2104,9 +2104,9 @@ delete hiddenThreads[id]; } } - _ref = g.hiddenReplies; - for (id in _ref) { - timestamp = _ref[id]; + _ref2 = g.hiddenReplies; + for (id in _ref2) { + timestamp = _ref2[id]; if (timestamp < cutoff) { delete g.hiddenReplies[id]; } @@ -2186,9 +2186,9 @@ expandComment.init(); } } - _ref2 = g.callbacks; - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - callback = _ref2[_i]; + _ref3 = g.callbacks; + for (_i = 0, _len = _ref3.length; _i < _len; _i++) { + callback = _ref3[_i]; callback(); } $.bind(d.body, 'DOMNodeInserted', nodeInserted);