More new HTML work.

This commit is contained in:
Nicolas Stepien 2012-04-28 16:24:17 +02:00
parent 55cbf0ddf4
commit 1cdac37ecf
2 changed files with 108 additions and 111 deletions

View File

@ -621,8 +621,8 @@
if (post.isInlined) { if (post.isInlined) {
return; return;
} }
post.isOP = post["class"] === 'op'; isOP = post["class"] === 'op';
isOP = post.isOP, el = post.el; el = post.el;
for (key in Filter.filters) { for (key in Filter.filters) {
value = Filter[key](post); value = Filter[key](post);
if (value === false) { if (value === false) {
@ -647,13 +647,13 @@
return; return;
} }
if (isOP) { if (isOP) {
$.addClass(el, result[0]);
} else {
$.addClass(el.parentNode, result[0]); $.addClass(el.parentNode, result[0]);
} else {
$.addClass(el, result[0]);
} }
if (isOP && result[1] && !g.REPLY) { if (isOP && result[1] && !g.REPLY) {
thisThread = el.parentNode; thisThread = el.parentNode.parentNode;
if (firstThread = $('div[class=op]')) { if (firstThread = $('div[class="postContainer opContainer"]')) {
$.before(firstThread.parentNode, [thisThread, thisThread.nextElementSibling]); $.before(firstThread.parentNode, [thisThread, thisThread.nextElementSibling]);
} }
} }
@ -661,9 +661,7 @@
} }
}, },
name: function(post) { name: function(post) {
var name; return $('.name', post.el).textContent || false;
name = post.isOP ? $('.postername', post.el) : $('.commentpostername', post.el);
return name.textContent;
}, },
uniqueid: function(post) { uniqueid: function(post) {
var uid; var uid;
@ -681,44 +679,42 @@
}, },
mod: function(post) { mod: function(post) {
var mod; var mod;
if (mod = (post.isOP ? $('.commentpostername', post.el) : $('.commentpostername ~ .commentpostername', post.el))) { if (mod = $('.capcode', post.el)) {
return mod.textContent; return mod.textContent;
} }
return false; return false;
}, },
email: function(post) { email: function(post) {
var mail; var mail;
if (mail = $('.linkmail', post.el)) { if (mail = $('.useremail', post.el)) {
return mail.href; return mail.href;
} }
return false; return false;
}, },
subject: function(post) { subject: function(post) {
var sub; return $('.subject', post.el).textContent || false;
sub = post.isOP ? $('.filetitle', post.el) : $('.replytitle', post.el);
return sub.textContent;
}, },
comment: function(post) { comment: function(post) {
var data, i, nodes, text, _i, _ref; var data, i, nodes, text, _i, _ref;
text = []; text = [];
nodes = d.evaluate('.//br|.//text()', post.el.lastChild, null, 7, null); nodes = d.evaluate('.//br|.//text()', post.el.lastElementChild, null, 7, null);
for (i = _i = 0, _ref = nodes.snapshotLength; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) { for (i = _i = 0, _ref = nodes.snapshotLength; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
text.push((data = nodes.snapshotItem(i).data) ? data : '\n'); text.push((data = nodes.snapshotItem(i).data) ? data : '\n');
} }
return text.join(''); return text.join('');
}, },
filename: function(post) { filename: function(post) {
var file, filesize; var file, fileinfo;
filesize = post.filesize; fileinfo = post.fileinfo;
if (filesize && (file = $('span', filesize))) { if (fileinfo && (file = $('span', fileinfo))) {
return file.title; return file.title;
} }
return false; return false;
}, },
dimensions: function(post) { dimensions: function(post) {
var filesize, match; var fileinfo, match;
filesize = post.filesize; fileinfo = post.fileinfo;
if (filesize && (match = filesize.textContent.match(/\d+x\d+/))) { if (fileinfo && (match = fileinfo.textContent.match(/\d+x\d+/))) {
return match[0]; return match[0];
} }
return false; return false;
@ -735,7 +731,7 @@
var img; var img;
img = post.img; img = post.img;
if (img) { if (img) {
return img.getAttribute('md5'); return img.dataset.md5;
} }
return false; return false;
} }
@ -1197,7 +1193,7 @@
if (all) { if (all) {
return $.id('imageExpand').click(); return $.id('imageExpand').click();
} else { } else {
thumb = $('img[md5]', $('.replyhl', thread) || thread); thumb = $('img[data-md5]', $('.replyhl', thread) || thread);
return ImageExpand.toggle(thumb.parentNode); return ImageExpand.toggle(thumb.parentNode);
} }
}, },
@ -2807,11 +2803,10 @@
node: function(post) { node: function(post) {
var img; var img;
img = post.img; img = post.img;
if (!(img && /^Spoil/.test(img.alt)) || post["class"] === 'inline') { if (!(img && /\bimgspoiler\b/.test(img.parentNode.className)) || post["class"] === 'inline') {
return; return;
} }
img.removeAttribute('height'); img.removeAttribute('style');
img.removeAttribute('width');
return img.src = "//thumbs.4chan.org" + (img.parentNode.pathname.replace(/src(\/\d+).+$/, 'thumb$1s.jpg')); return img.src = "//thumbs.4chan.org" + (img.parentNode.pathname.replace(/src(\/\d+).+$/, 'thumb$1s.jpg'));
} }
}; };
@ -2824,11 +2819,11 @@
if ($.isDST()) { if ($.isDST()) {
chanOffset--; chanOffset--;
} }
this.parse = Date.parse('10/11/11(Tue)18:53') === 1318351980000 ? function(node) { this.parse = Date.parse('10/11/11(Tue)18:53') === 1318351980000 ? function(text) {
return new Date(Date.parse(node.textContent) + chanOffset * $.HOUR); return new Date(Date.parse(text) + chanOffset * $.HOUR);
} : function(node) { } : function(text) {
var day, hour, min, month, year, _, _ref; var day, hour, min, month, year, _, _ref;
_ref = node.textContent.match(/(\d+)\/(\d+)\/(\d+)\(\w+\)(\d+):(\d+)/), _ = _ref[0], month = _ref[1], day = _ref[2], year = _ref[3], hour = _ref[4], min = _ref[5]; _ref = text.match(/(\d+)\/(\d+)\/(\d+)\(\w+\)(\d+):(\d+)/), _ = _ref[0], month = _ref[1], day = _ref[2], year = _ref[3], hour = _ref[4], min = _ref[5];
year = "20" + year; year = "20" + year;
month--; month--;
hour = chanOffset + Number(hour); hour = chanOffset + Number(hour);
@ -2837,17 +2832,14 @@
return Main.callbacks.push(this.node); return Main.callbacks.push(this.node);
}, },
node: function(post) { node: function(post) {
var node, time; var node;
if (post["class"] === 'inline') { if (post["class"] === 'inline') {
return; return;
} }
node = $('.posttime', post.el) || $('span[id]', post.el).previousSibling; node = $('.dateTime', post.el);
Time.date = Time.parse(node); Time.date = Time.parse(node.textContent);
time = $.el('time', { node.textContent = Time.funk(Time);
textContent: ' ' + Time.funk(Time) + ' ' return node.dataset.time = Time.date.toISOString();
});
time.setAttribute('datetime', Time.date.toISOString());
return $.replace(node, time);
}, },
foo: function() { foo: function() {
var code; var code;
@ -3320,7 +3312,7 @@
post = { post = {
root: qp, root: qp,
filesize: $('.filesize', qp), filesize: $('.filesize', qp),
img: $('img[md5]', qp) img: $('img[data-md5]', qp)
}; };
if (Conf['Image Auto-Gif']) { if (Conf['Image Auto-Gif']) {
AutoGif.node(post); AutoGif.node(post);
@ -3346,7 +3338,7 @@
_ref = post.quotes; _ref = post.quotes;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
quote = _ref[_i]; quote = _ref[_i];
if (quote.hash.slice(1) === post.threadId) { if (quote.hash.slice(2) === post.threadId) {
$.add(quote, $.tn('\u00A0(OP)')); $.add(quote, $.tn('\u00A0(OP)'));
} }
} }
@ -3385,7 +3377,7 @@
if (post["class"] === 'inline') { if (post["class"] === 'inline') {
return; return;
} }
snapshot = d.evaluate('.//text()[not(parent::a)]', post.el.lastChild, null, 6, null); snapshot = d.evaluate('.//text()[not(parent::a)]', post.el.lastElementChild, null, 6, null);
for (i = _i = 0, _ref = snapshot.snapshotLength; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) { for (i = _i = 0, _ref = snapshot.snapshotLength; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
node = snapshot.snapshotItem(i); node = snapshot.snapshotItem(i);
data = node.data; data = node.data;
@ -3505,7 +3497,7 @@
if (post.root.hidden || post["class"]) { if (post.root.hidden || post["class"]) {
return; return;
} }
count = Unread.replies.push(post.root); count = Unread.replies.push(post.el);
return Unread.update(count === 1); return Unread.update(count === 1);
}, },
scroll: function() { scroll: function() {
@ -3773,7 +3765,7 @@
var i, thumb, thumbs, _i, _j, _k, _len, _len1, _len2, _ref; var i, thumb, thumbs, _i, _j, _k, _len, _len1, _len2, _ref;
ImageExpand.on = this.checked; ImageExpand.on = this.checked;
if (ImageExpand.on) { if (ImageExpand.on) {
thumbs = $$('img[md5]'); thumbs = $$('img[data-md5]');
if (Conf['Expand From Current']) { if (Conf['Expand From Current']) {
for (i = _i = 0, _len = thumbs.length; _i < _len; i = ++_i) { for (i = _i = 0, _len = thumbs.length; _i < _len; i = ++_i) {
thumb = thumbs[i]; thumb = thumbs[i];
@ -3788,7 +3780,7 @@
ImageExpand.expand(thumb); ImageExpand.expand(thumb);
} }
} else { } else {
_ref = $$('img[md5][hidden]'); _ref = $$('img[data-md5][hidden]');
for (_k = 0, _len2 = _ref.length; _k < _len2; _k++) { for (_k = 0, _len2 = _ref.length; _k < _len2; _k++) {
thumb = _ref[_k]; thumb = _ref[_k];
ImageExpand.contract(thumb); ImageExpand.contract(thumb);
@ -3886,7 +3878,7 @@
}); });
}, },
dialog: function() { dialog: function() {
var controls, form, imageType, select; var controls, imageType, select;
controls = $.el('div', { controls = $.el('div', {
id: 'imgControls', id: 'imgControls',
innerHTML: "<select id=imageType name=imageType><option value=full>Full</option><option value='fit width'>Fit Width</option><option value='fit height'>Fit Height</option value='fit screen'><option value='fit screen'>Fit Screen</option></select><label>Expand Images<input type=checkbox id=imageExpand></label>" innerHTML: "<select id=imageType name=imageType><option value=full>Full</option><option value='fit width'>Fit Width</option><option value='fit height'>Fit Height</option value='fit screen'><option value='fit screen'>Fit Screen</option></select><label>Expand Images<input type=checkbox id=imageExpand></label>"
@ -3898,11 +3890,10 @@
$.on(select, 'change', $.cb.value); $.on(select, 'change', $.cb.value);
$.on(select, 'change', ImageExpand.cb.typeChange); $.on(select, 'change', ImageExpand.cb.typeChange);
$.on($('input', controls), 'click', ImageExpand.cb.all); $.on($('input', controls), 'click', ImageExpand.cb.all);
form = $('body > form'); return $.prepend($.id('delform'), controls);
return $.prepend(form, controls);
}, },
resize: function() { resize: function() {
return ImageExpand.style.textContent = ".fitheight img[md5] + img {max-height:" + d.body.clientHeight + "px;}"; return ImageExpand.style.textContent = ".fitheight img[data-md5] + img {max-height:" + d.body.clientHeight + "px;}";
} }
}; };
@ -4154,7 +4145,7 @@
} }
}, },
preParse: function(node) { preParse: function(node) {
var klass, post; var file, klass, post;
klass = node.className; klass = node.className;
post = { post = {
root: node.parentNode, root: node.parentNode,
@ -4163,11 +4154,16 @@
id: node.id.slice(1), id: node.id.slice(1),
threadId: g.THREAD_ID || $.x('ancestor::div[@class="thread"]', node).id.slice(1), threadId: g.THREAD_ID || $.x('ancestor::div[@class="thread"]', node).id.slice(1),
isInlined: /\binline\b/.test(klass), isInlined: /\binline\b/.test(klass),
fileinfo: node.getElementsByClassName('fileInfo')[0] || false,
quotes: node.getElementsByClassName('quotelink'), quotes: node.getElementsByClassName('quotelink'),
backlinks: node.getElementsByClassName('backlink') backlinks: node.getElementsByClassName('backlink')
}; };
post.img = post.filesize ? node.getElementsByTagName('img')[0] : false; if (file = $('.file', node)) {
post.fileinfo = file.firstElementChild;
post.img = file.lastElementChild.firstElementChild;
} else {
post.fileinfo = false;
post.img = false;
}
return post; return post;
}, },
node: function(nodes, notify) { node: function(nodes, notify) {
@ -4195,7 +4191,7 @@
_ref = mutation.addedNodes; _ref = mutation.addedNodes;
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
addedNode = _ref[_j]; addedNode = _ref[_j];
if (addedNode.nodeName === 'TABLE') { if (addedNode.nodeName === 'DIV' && /\bpostContainer\b/.test(addedNode.className)) {
nodes.push(Main.preParse(addedNode)); nodes.push(Main.preParse(addedNode));
} }
} }
@ -4207,7 +4203,7 @@
listener: function(e) { listener: function(e) {
var target; var target;
target = e.target; target = e.target;
if (target.nodeName === 'TABLE') { if (target.nodeName === 'DIV' && /\bpostContainer\b/.test(addedNode.className)) {
return Main.node([Main.preParse(target)]); return Main.node([Main.preParse(target)]);
} }
}, },
@ -4445,23 +4441,23 @@ textarea.field {\
.filename:not(:hover) > .fnfull {\ .filename:not(:hover) > .fnfull {\
display: none;\ display: none;\
}\ }\
img[md5], img[md5] + img {\ img[data-md5], img[data-md5] + img {\
pointer-events: all;\ pointer-events: all;\
}\ }\
.fitwidth img[md5] + img {\ .fitwidth img[data-md5] + img {\
max-width: 100%;\ max-width: 100%;\
}\ }\
.gecko > .fitwidth img[md5] + img,\ .gecko > .fitwidth img[data-md5] + img,\
.presto > .fitwidth img[md5] + img {\ .presto > .fitwidth img[data-md5] + img {\
width: 100%;\ width: 100%;\
}\ }\
/* revealed spoilers do not have height/width,\ /* revealed spoilers do not have height/width,\
this fixes "expanded" auto-gifs */\ this fixes "expanded" auto-gifs */\
img[md5] {\ img[data-md5] {\
max-height: 252px;\ max-height: 252px;\
max-width: 252px;\ max-width: 252px;\
}\ }\
input ~ a > img[md5] {\ input ~ a > img[data-md5] {\
max-height: 127px;\ max-height: 127px;\
max-width: 127px;\ max-width: 127px;\
}\ }\

View File

@ -513,8 +513,8 @@ Filter =
node: (post) -> node: (post) ->
return if post.isInlined return if post.isInlined
post.isOP = post.class is 'op' isOP = post.class is 'op'
{isOP, el} = post {el} = post
for key of Filter.filters for key of Filter.filters
value = Filter[key] post value = Filter[key] post
if value is false if value is false
@ -537,20 +537,20 @@ Filter =
# Highlight # Highlight
if isOP if isOP
$.addClass el, result[0]
else
$.addClass el.parentNode, result[0] $.addClass el.parentNode, result[0]
else
$.addClass el, result[0]
if isOP and result[1] and not g.REPLY if isOP and result[1] and not g.REPLY
# Put the highlighted OPs' threads on top of the board pages... # Put the highlighted OPs' threads on top of the board pages...
thisThread = el.parentNode thisThread = el.parentNode.parentNode
# ...before the first non highlighted thread. # ...before the first non highlighted thread.
if firstThread = $ 'div[class=op]' if firstThread = $ 'div[class="postContainer opContainer"]'
$.before firstThread.parentNode, [thisThread, thisThread.nextElementSibling] $.before firstThread.parentNode, [thisThread, thisThread.nextElementSibling]
name: (post) -> name: (post) ->
name = if post.isOP then $ '.postername', post.el else $ '.commentpostername', post.el $('.name', post.el).textContent or false
name.textContent
uniqueid: (post) -> uniqueid: (post) ->
# NEW FORMAT ???
if uid = $ '.posteruid', post.el if uid = $ '.posteruid', post.el
return uid.textContent return uid.textContent
false false
@ -559,31 +559,30 @@ Filter =
return trip.textContent return trip.textContent
false false
mod: (post) -> mod: (post) ->
if mod = (if post.isOP then $ '.commentpostername', post.el else $ '.commentpostername ~ .commentpostername', post.el) if mod = $ '.capcode', post.el
return mod.textContent return mod.textContent
false false
email: (post) -> email: (post) ->
if mail = $ '.linkmail', post.el if mail = $ '.useremail', post.el
return mail.href return mail.href
false false
subject: (post) -> subject: (post) ->
sub = if post.isOP then $ '.filetitle', post.el else $ '.replytitle', post.el $('.subject', post.el).textContent or false
sub.textContent
comment: (post) -> comment: (post) ->
text = [] text = []
# XPathResult.ORDERED_NODE_SNAPSHOT_TYPE is 7 # XPathResult.ORDERED_NODE_SNAPSHOT_TYPE is 7
nodes = d.evaluate './/br|.//text()', post.el.lastChild, null, 7, null nodes = d.evaluate './/br|.//text()', post.el.lastElementChild, null, 7, null
for i in [0...nodes.snapshotLength] for i in [0...nodes.snapshotLength]
text.push if data = nodes.snapshotItem(i).data then data else '\n' text.push if data = nodes.snapshotItem(i).data then data else '\n'
text.join '' text.join ''
filename: (post) -> filename: (post) ->
{filesize} = post {fileinfo} = post
if filesize and file = $ 'span', filesize if fileinfo and file = $ 'span', fileinfo
return file.title return file.title
false false
dimensions: (post) -> dimensions: (post) ->
{filesize} = post {fileinfo} = post
if filesize and match = filesize.textContent.match /\d+x\d+/ if fileinfo and match = fileinfo.textContent.match /\d+x\d+/
return match[0] return match[0]
false false
filesize: (post) -> filesize: (post) ->
@ -594,7 +593,7 @@ Filter =
md5: (post) -> md5: (post) ->
{img} = post {img} = post
if img if img
return img.getAttribute 'md5' return img.dataset.md5
false false
StrikethroughQuotes = StrikethroughQuotes =
@ -895,7 +894,7 @@ Keybinds =
if all if all
$.id('imageExpand').click() $.id('imageExpand').click()
else else
thumb = $ 'img[md5]', $('.replyhl', thread) or thread thumb = $ 'img[data-md5]', $('.replyhl', thread) or thread
ImageExpand.toggle thumb.parentNode ImageExpand.toggle thumb.parentNode
qr: (thread, quote) -> qr: (thread, quote) ->
@ -2220,10 +2219,9 @@ RevealSpoilers =
Main.callbacks.push @node Main.callbacks.push @node
node: (post) -> node: (post) ->
{img} = post {img} = post
if not (img and /^Spoil/.test img.alt) or post.class is 'inline' if not (img and /\bimgspoiler\b/.test img.parentNode.className) or post.class is 'inline'
return return
img.removeAttribute 'height' img.removeAttribute 'style'
img.removeAttribute 'width'
img.src = "//thumbs.4chan.org#{img.parentNode.pathname.replace(/src(\/\d+).+$/, 'thumb$1s.jpg')}" img.src = "//thumbs.4chan.org#{img.parentNode.pathname.replace(/src(\/\d+).+$/, 'thumb$1s.jpg')}"
Time = Time =
@ -2237,11 +2235,11 @@ Time =
@parse = @parse =
if Date.parse('10/11/11(Tue)18:53') is 1318351980000 if Date.parse('10/11/11(Tue)18:53') is 1318351980000
(node) -> new Date Date.parse(node.textContent) + chanOffset*$.HOUR (text) -> new Date Date.parse(text) + chanOffset*$.HOUR
else # Firefox and Opera do not parse 4chan's time format correctly else # Firefox and Opera do not parse 4chan's time format correctly
(node) -> (text) ->
[_, month, day, year, hour, min] = [_, month, day, year, hour, min] =
node.textContent.match /(\d+)\/(\d+)\/(\d+)\(\w+\)(\d+):(\d+)/ text.match /(\d+)\/(\d+)\/(\d+)\(\w+\)(\d+):(\d+)/
year = "20#{year}" year = "20#{year}"
month-- # Months start at 0 month-- # Months start at 0
hour = chanOffset + Number hour hour = chanOffset + Number hour
@ -2251,13 +2249,11 @@ Time =
node: (post) -> node: (post) ->
return if post.class is 'inline' return if post.class is 'inline'
# .posttime exists on every board except /f/ # .posttime exists on every board except /f/
node = $('.posttime', post.el) or $('span[id]', post.el).previousSibling node = $ '.dateTime', post.el
Time.date = Time.parse node Time.date = Time.parse node.textContent
time = $.el 'time', node.textContent = Time.funk(Time)
textContent: ' ' + Time.funk(Time) + ' '
# Set the datetime attribute, ISO'd. # Set the datetime attribute, ISO'd.
time.setAttribute 'datetime', Time.date.toISOString() node.dataset.time = Time.date.toISOString()
$.replace node, time
foo: -> foo: ->
code = Conf['time'].replace /%([A-Za-z])/g, (s, c) -> code = Conf['time'].replace /%([A-Za-z])/g, (s, c) ->
if c of Time.formatters if c of Time.formatters
@ -2566,8 +2562,8 @@ QuotePreview =
qp.innerHTML = node.innerHTML qp.innerHTML = node.innerHTML
post = post =
root: qp root: qp
filesize: $ '.filesize', qp filesize: $ '.filesize', qp
img: $ 'img[md5]', qp img: $ 'img[data-md5]', qp
if Conf['Image Auto-Gif'] if Conf['Image Auto-Gif']
AutoGif.node post AutoGif.node post
if Conf['Time Formatting'] if Conf['Time Formatting']
@ -2581,7 +2577,7 @@ QuoteOP =
node: (post) -> node: (post) ->
return if post.class is 'inline' return if post.class is 'inline'
for quote in post.quotes for quote in post.quotes
if quote.hash[1..] is post.threadId if quote.hash[2..] is post.threadId
# \u00A0 is nbsp # \u00A0 is nbsp
$.add quote, $.tn '\u00A0(OP)' $.add quote, $.tn '\u00A0(OP)'
return return
@ -2610,7 +2606,7 @@ Quotify =
# XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE is 6 # XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE is 6
# Get all the text nodes that are not inside an anchor. # Get all the text nodes that are not inside an anchor.
snapshot = d.evaluate './/text()[not(parent::a)]', post.el.lastChild, null, 6, null snapshot = d.evaluate './/text()[not(parent::a)]', post.el.lastElementChild, null, 6, null
for i in [0...snapshot.snapshotLength] for i in [0...snapshot.snapshotLength]
node = snapshot.snapshotItem i node = snapshot.snapshotItem i
@ -2715,7 +2711,7 @@ Unread =
Unread.foresee.splice index, 1 Unread.foresee.splice index, 1
return return
return if post.root.hidden or post.class return if post.root.hidden or post.class
count = Unread.replies.push post.root count = Unread.replies.push post.el
Unread.update count is 1 Unread.update count is 1
scroll: -> scroll: ->
@ -2895,7 +2891,7 @@ ImageExpand =
all: -> all: ->
ImageExpand.on = @checked ImageExpand.on = @checked
if ImageExpand.on #expand if ImageExpand.on #expand
thumbs = $$ 'img[md5]' thumbs = $$ 'img[data-md5]'
if Conf['Expand From Current'] if Conf['Expand From Current']
for thumb, i in thumbs for thumb, i in thumbs
if thumb.getBoundingClientRect().top > 0 if thumb.getBoundingClientRect().top > 0
@ -2904,7 +2900,7 @@ ImageExpand =
for thumb in thumbs for thumb in thumbs
ImageExpand.expand thumb ImageExpand.expand thumb
else #contract else #contract
for thumb in $$ 'img[md5][hidden]' for thumb in $$ 'img[data-md5][hidden]'
ImageExpand.contract thumb ImageExpand.contract thumb
return return
typeChange: -> typeChange: ->
@ -2985,11 +2981,10 @@ ImageExpand =
$.on select, 'change', ImageExpand.cb.typeChange $.on select, 'change', ImageExpand.cb.typeChange
$.on $('input', controls), 'click', ImageExpand.cb.all $.on $('input', controls), 'click', ImageExpand.cb.all
form = $ 'body > form' $.prepend $.id('delform'), controls
$.prepend form, controls
resize: -> resize: ->
ImageExpand.style.textContent = ".fitheight img[md5] + img {max-height:#{d.body.clientHeight}px;}" ImageExpand.style.textContent = ".fitheight img[data-md5] + img {max-height:#{d.body.clientHeight}px;}"
Main = Main =
init: -> init: ->
@ -3197,17 +3192,21 @@ Main =
preParse: (node) -> preParse: (node) ->
klass = node.className klass = node.className
post = post =
root: node.parentNode root: node.parentNode
el: node el: node
class: klass class: klass
id: node.id[1..] id: node.id[1..]
threadId: g.THREAD_ID or $.x('ancestor::div[@class="thread"]', node).id[1..] threadId: g.THREAD_ID or $.x('ancestor::div[@class="thread"]', node).id[1..]
isInlined: /\binline\b/.test klass isInlined: /\binline\b/.test klass
fileinfo: node.getElementsByClassName('fileInfo')[0] or false
quotes: node.getElementsByClassName 'quotelink' quotes: node.getElementsByClassName 'quotelink'
backlinks: node.getElementsByClassName 'backlink' backlinks: node.getElementsByClassName 'backlink'
post.img = if post.filesize then node.getElementsByTagName('img')[0] else false if file = $ '.file', node
post.fileinfo = file.firstElementChild
post.img = file.lastElementChild.firstElementChild
else
post.fileinfo = false
post.img = false
post post
node: (nodes, notify) -> node: (nodes, notify) ->
for callback in Main.callbacks for callback in Main.callbacks
@ -3220,11 +3219,13 @@ Main =
nodes = [] nodes = []
for mutation in mutations for mutation in mutations
for addedNode in mutation.addedNodes for addedNode in mutation.addedNodes
nodes.push Main.preParse addedNode if addedNode.nodeName is 'TABLE' if addedNode.nodeName is 'DIV' and /\bpostContainer\b/.test addedNode.className
nodes.push Main.preParse addedNode
Main.node nodes if nodes.length Main.node nodes if nodes.length
listener: (e) -> listener: (e) ->
{target} = e {target} = e
Main.node [Main.preParse target] if target.nodeName is 'TABLE' if target.nodeName is 'DIV' and /\bpostContainer\b/.test addedNode.className
Main.node [Main.preParse target]
namespace: '4chan_x.' namespace: '4chan_x.'
version: '2.29.3' version: '2.29.3'
@ -3460,23 +3461,23 @@ textarea.field {
.filename:not(:hover) > .fnfull { .filename:not(:hover) > .fnfull {
display: none; display: none;
} }
img[md5], img[md5] + img { img[data-md5], img[data-md5] + img {
pointer-events: all; pointer-events: all;
} }
.fitwidth img[md5] + img { .fitwidth img[data-md5] + img {
max-width: 100%; max-width: 100%;
} }
.gecko > .fitwidth img[md5] + img, .gecko > .fitwidth img[data-md5] + img,
.presto > .fitwidth img[md5] + img { .presto > .fitwidth img[data-md5] + img {
width: 100%; width: 100%;
} }
/* revealed spoilers do not have height/width, /* revealed spoilers do not have height/width,
this fixes "expanded" auto-gifs */ this fixes "expanded" auto-gifs */
img[md5] { img[data-md5] {
max-height: 252px; max-height: 252px;
max-width: 252px; max-width: 252px;
} }
input ~ a > img[md5] { input ~ a > img[data-md5] {
max-height: 127px; max-height: 127px;
max-width: 127px; max-width: 127px;
} }