From c5fd4455dca3b9dfef30fd5b6762954f1c219063 Mon Sep 17 00:00:00 2001 From: ahodesuka Date: Tue, 21 Feb 2012 16:47:37 -0600 Subject: [PATCH] Add original file name to links inside threads. Add truncated/untrancated parameters. --- 4chan_x.user.js | 27 ++++++++++++++++++++------- changelog | 4 ++-- script.coffee | 22 +++++++++++++++------- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3fa4323f1..bb8e48d38 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -149,8 +149,8 @@ sauces: ['http://iqdb.org/?url=$1', 'http://www.google.com/searchbyimage?image_url=$1', '#http://tineye.com/search?url=$1', '#http://saucenao.com/search.php?db=999&url=$1', '#http://3d.iqdb.org/?url=$1', '#http://regex.info/exif.cgi?imgurl=$2', '# uploaders:', '#http://imgur.com/upload?url=$2', '#http://omploader.org/upload?url1=$2', '# "View Same" in archives:', '#http://archive.foolz.us/a/image/$3/', '#http://archive.installgentoo.net/g/image/$3'].join('\n'), time: '%m/%d/%y(%a)%H:%M', backlink: '>>%id', - fileInfoR: '%l (%s, %r, %n)', - fileInfoT: '%l (%s, %r)', + fileInfoR: '%l, %s, %r', + fileInfoT: '%l, %s, %r', favicon: 'ferongr', hotkeys: { openOptions: ['ctrl+o', 'Open Options'], @@ -2146,14 +2146,16 @@ \
File Info Formatting is disabled.
\ \
Unread Favicon is disabled.
\ Unread favicons
\ @@ -2294,6 +2296,7 @@ resolution: '1366x768', filename: 'Untitled.png' }; + FileInfo.funks = FileInfo.setFormats(); return $.id("" + this.name + "Preview").innerHTML = FileInfo.funks[this.name === 'fileInfoR' ? 0 : 1](FileInfo); }, favicon: function() { @@ -2893,7 +2896,7 @@ init: function() { if (g.BOARD === 'f') return; FileInfo.ffConf = ['fileInfoR', 'fileInfoT']; - FileInfo.ffMtrs = [/%([BKlMnrs])/g, /%([BKlMrs])/g]; + FileInfo.ffMtrs = [/%([BKlLMnNrs])/g, /%([BKlMrs])/g]; FileInfo.ffRgex = [/File:\s()-\((?:Spoiler Image,\s)?([\d\.]+)\s([BKM]{1,2}),\s(\d+x\d+|PDF),\s/, /File:\s()-\((?:Spoiler Image,\s)?([\d\.]+)\s([BKM]{1,2}),\s(\d+x\d+|PDF)\)/]; this.parse = function(node) { var filename, link, resolution, size, unit, _, _ref; @@ -2962,7 +2965,14 @@ return FileInfo.convertUnit('KB'); }, l: function() { - return FileInfo.data.link; + if (FileInfo.ffType === 0) { + return FileInfo.data.link.replace(/>\d+\.\w+' + FileInfo.formatters.n() + '<'); + } else { + return FileInfo.data.link; + } + }, + L: function() { + return FileInfo.data.link.replace(/>\d+\.\w+' + FileInfo.data.filename + '<'); }, M: function() { return FileInfo.convertUnit('MB'); @@ -2975,6 +2985,9 @@ return FileInfo.data.filename; } }, + N: function() { + return FileInfo.data.filename; + }, r: function() { return FileInfo.data.resolution; }, diff --git a/changelog b/changelog index 6e22cf309..dc82babf8 100644 --- a/changelog +++ b/changelog @@ -5,10 +5,10 @@ master Add Open Reply in New Tab option for replies made from the main board (not dumping). Scroll back up (top of anchor - 42px) when unexpanding images. Reply/Thread File Info Formatting: - - Link: %l. + - Link: %l, %L (Original file names are shown inside threads). - Size: %B (Bytes), %K (KB), %M (MB), %s (4chan default). - Resolution/PDF: %r - - Original filename: %n (truncated if longer than 40~ character, on hover the entire string is shown. + - Original filename: %n, %N. - Mayhem The Filter now has per filter settings: - Filter the OP only along its thread, replies only, or both. diff --git a/script.coffee b/script.coffee index 8227551ca..bd685753d 100644 --- a/script.coffee +++ b/script.coffee @@ -78,8 +78,8 @@ config = ].join '\n' time: '%m/%d/%y(%a)%H:%M' backlink: '>>%id' - fileInfoR: '%l (%s, %r, %n)' - fileInfoT: '%l (%s, %r)' + fileInfoR: '%l, %s, %r' + fileInfoT: '%l, %s, %r' favicon: 'ferongr' hotkeys: openOptions: ['ctrl+o', 'Open Options'] @@ -1718,14 +1718,16 @@ options =
File Info Formatting is disabled.
    - Reply File Info Formatting -
  • :
  • Thread File Info Formatting
  • :
  • Link: %l (lowercase L)
  • Size: %B (Bytes), %K (KB), %M (MB), %s (4chan default)
  • Resolution: %r (Displays PDF on /po/, for PDF\'s)
  • -
  • Original filename: %n (Reply only)
  • + Reply File Info Formatting +
  • :
  • +
  • All thread formatters also work for reply formatting.
  • +
  • Link (with original file name): %l (lowercase L)(Truncated), %L (Untruncated)
  • +
  • Original file name: %n (Truncated), %N (Untruncated)
Unread Favicon is disabled.
Unread favicons
@@ -1852,6 +1854,7 @@ options = unit : 'KB' resolution: '1366x768' filename : 'Untitled.png' + FileInfo.funks = FileInfo.setFormats() $.id("#{@name}Preview").innerHTML = FileInfo.funks[if @name is 'fileInfoR' then 0 else 1] FileInfo favicon: -> Favicon.switch() @@ -2333,7 +2336,7 @@ FileInfo = init: -> return if g.BOARD is 'f' FileInfo.ffConf = [ 'fileInfoR', 'fileInfoT' ] - FileInfo.ffMtrs = [ /%([BKlMnrs])/g, /%([BKlMrs])/g ] + FileInfo.ffMtrs = [ /%([BKlLMnNrs])/g, /%([BKlMrs])/g ] FileInfo.ffRgex = [ /File:\s()-\((?:Spoiler Image,\s)?([\d\.]+)\s([BKM]{1,2}),\s(\d+x\d+|PDF),\s/, /File:\s()-\((?:Spoiler Image,\s)?([\d\.]+)\s([BKM]{1,2}),\s(\d+x\d+|PDF)\)/ ] @parse = (node) -> @@ -2377,12 +2380,17 @@ FileInfo = formatters: B: -> FileInfo.convertUnit 'B' K: -> FileInfo.convertUnit 'KB' - l: -> FileInfo.data.link + l: -> if FileInfo.ffType is 0 + FileInfo.data.link.replace />\d+\.\w+' + FileInfo.formatters.n() + '<' + else + FileInfo.data.link + L: -> FileInfo.data.link.replace />\d+\.\w+' + FileInfo.data.filename + '<' M: -> FileInfo.convertUnit 'MB' n: -> if (ext = FileInfo.data.filename.lastIndexOf '.') > 38 '' + FileInfo.data.filename + '' + FileInfo.data.filename.substr(0, 32) + ' (...)' + FileInfo.data.filename.substr(ext) + '' else FileInfo.data.filename + N: -> FileInfo.data.filename r: -> FileInfo.data.resolution s: -> "#{FileInfo.data.size} #{FileInfo.data.unit}"