Fix 4chan X for markup change.

This commit is contained in:
Mayhem 2013-12-05 17:44:01 +01:00
parent 1e621a7fe4
commit 3efffe8a6e
6 changed files with 19 additions and 14 deletions

View File

@ -1,3 +1,5 @@
- Fix 4chan X breaking in threads following a 4chan markup change.
### 3.14.1 - *2013-11-25*
- Minor cooldown fix:

View File

@ -55,6 +55,9 @@ a[href="javascript:;"] {
.post {
overflow: visible !important;
}
.fileText {
margin: 0 20px;
}
[hidden] {
display: none !important;
}

View File

@ -167,15 +167,15 @@ Build =
filename = a.innerHTML.replace /'/g, '''
fileDims = if ext is 'pdf' then 'PDF' else "#{file.width}x#{file.height}"
fileInfo = "<span class=fileText id=fT#{postID}#{if file.isSpoiler then " title='#{filename}'" else ''}>File: <a href='#{file.url}' target=_blank>#{file.timestamp}</a>" +
fileInfo = "<div class=fileText id=fT#{postID}#{if file.isSpoiler then " title='#{filename}'" else ''}>File: <a href='#{file.url}' target=_blank>#{file.timestamp}</a>" +
"-(#{fileSize}, #{fileDims}#{
if file.isSpoiler
''
else
", <span title='#{filename}'>#{shortFilename}</span>"
}" + ")</span>"
", <span#{if filename isnt shortFilename then " title='#{filename}'" else ''}>#{shortFilename}</span>"
}" + ")</div>"
fileHTML = "<div id=f#{postID} class=file><div class=fileInfo>#{fileInfo}</div>#{imgSrc}</div>"
fileHTML = "<div class=file id=f#{postID}>#{fileInfo}#{imgSrc}</div>"
else
fileHTML = ''

View File

@ -52,8 +52,7 @@ class Clone extends Post
for key, val of origin.file
@file[key] = val
file = $ '.file', post
@file.info = file.firstElementChild
@file.text = @file.info.firstElementChild
@file.text = file.firstElementChild
@file.thumb = $ 'img[data-md5]', file
@file.fullImage = $ '.full-image', file

View File

@ -109,15 +109,13 @@ class Post
return unless (fileEl = $ '.file', @nodes.post) and thumb = $ 'img[data-md5]', fileEl
# Supports JPG/PNG/GIF/PDF.
# Flash files are not supported.
alt = thumb.alt
anchor = thumb.parentNode
fileInfo = fileEl.firstElementChild
fileText = fileEl.firstElementChild
@file =
info: fileInfo
text: fileInfo.firstElementChild
text: fileText
thumb: thumb
URL: anchor.href
size: alt.match(/[\d.]+\s\w+/)[0]
size: thumb.alt.match(/[\d.]+\s\w+/)[0]
MD5: thumb.dataset.md5
isSpoiler: $.hasClass anchor, 'imgspoiler'
size = +@file.size.match(/[\d.]+/)[0]
@ -128,7 +126,10 @@ class Post
thumb.src
else
"#{location.protocol}//t.4cdn.org/#{@board}/thumb/#{@file.URL.match(/(\d+)\./)[1]}s.jpg"
@file.name = $('span[title]', fileInfo).title
@file.name = if nameNode = $ 'span', fileText
nameNode.title or nameNode.textContent
else
fileText.title
<% if (type === 'crx') { %>
# replace %22 with quotes, see:
# crbug.com/81193
@ -138,7 +139,7 @@ class Post
@file.name = @file.name.replace /%22/g, '"'
<% } %>
if @file.isImage = /(jpg|png|gif)$/i.test @file.name
@file.dimensions = @file.text.textContent.match(/\d+x\d+/)[0]
@file.dimensions = fileText.textContent.match(/\d+x\d+/)[0]
kill: (file, now) ->
now or= new Date()

View File

@ -40,4 +40,4 @@ Sauce =
for link in Sauce.links
# \u00A0 is nbsp
nodes.push $.tn('\u00A0'), link @, Sauce.link.cloneNode true
$.add @file.info, nodes
$.add @file.text, nodes