From 3efffe8a6edf3e469d9c6e9f9e1dedc03252f596 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Thu, 5 Dec 2013 17:44:01 +0100 Subject: [PATCH] Fix 4chan X for markup change. --- CHANGELOG.md | 2 ++ css/style.css | 3 +++ src/General/Build.coffee | 8 ++++---- src/General/Clone.coffee | 3 +-- src/General/Post.coffee | 15 ++++++++------- src/Images/Sauce.coffee | 2 +- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c505b232b..97e101ba9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +- Fix 4chan X breaking in threads following a 4chan markup change. + ### 3.14.1 - *2013-11-25* - Minor cooldown fix: diff --git a/css/style.css b/css/style.css index 278565f97..d0bdfff8d 100644 --- a/css/style.css +++ b/css/style.css @@ -55,6 +55,9 @@ a[href="javascript:;"] { .post { overflow: visible !important; } +.fileText { + margin: 0 20px; +} [hidden] { display: none !important; } diff --git a/src/General/Build.coffee b/src/General/Build.coffee index 28b66a699..292d9362b 100644 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -167,15 +167,15 @@ Build = filename = a.innerHTML.replace /'/g, ''' fileDims = if ext is 'pdf' then 'PDF' else "#{file.width}x#{file.height}" - fileInfo = "File: #{file.timestamp}" + + fileInfo = "
File: #{file.timestamp}" + "-(#{fileSize}, #{fileDims}#{ if file.isSpoiler '' else - ", #{shortFilename}" - }" + ")" + ", #{shortFilename}" + }" + ")
" - fileHTML = "
#{fileInfo}
#{imgSrc}
" + fileHTML = "
#{fileInfo}#{imgSrc}
" else fileHTML = '' diff --git a/src/General/Clone.coffee b/src/General/Clone.coffee index abb51c327..50d1da316 100644 --- a/src/General/Clone.coffee +++ b/src/General/Clone.coffee @@ -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 diff --git a/src/General/Post.coffee b/src/General/Post.coffee index f7bc31918..2da5ed5e3 100644 --- a/src/General/Post.coffee +++ b/src/General/Post.coffee @@ -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() diff --git a/src/Images/Sauce.coffee b/src/Images/Sauce.coffee index 10ffeff95..b7ce89779 100644 --- a/src/Images/Sauce.coffee +++ b/src/Images/Sauce.coffee @@ -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