diff --git a/4chan_x.user.js b/4chan_x.user.js index 9352cae3a..bf9032389 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -141,7 +141,7 @@ filesize: '', md5: '' }, - flavors: ['http://iqdb.org/?url=', 'http://google.com/searchbyimage?image_url=', '#http://tineye.com/search?url=', '#http://saucenao.com/search.php?db=999&url=', '#http://3d.iqdb.org/?url=', '#http://regex.info/exif.cgi?imgurl=', '#http://imgur.com/upload?url=', '#http://ompldr.org/upload?url1='].join('\n'), + sauces: ['http://iqdb.org/?url=$1', 'http://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', '#http://imgur.com/upload?url=$2', '#http://ompldr.org/upload?url1=$2'].join('\n'), time: '%m/%d/%y(%a)%H:%M', backlink: '>>%id', favicon: 'ferongr', @@ -305,7 +305,6 @@ val = properties[key]; object[key] = val; } - return object; }; $.extend($, { @@ -408,14 +407,12 @@ return el.parentNode.removeChild(el); }, add: function() { - var child, children, parent, _i, _len, _results; + var child, children, parent, _i, _len; parent = arguments[0], children = 2 <= arguments.length ? __slice.call(arguments, 1) : []; - _results = []; for (_i = 0, _len = children.length; _i < _len; _i++) { child = children[_i]; - _results.push(parent.appendChild(child)); + parent.appendChild(child); } - return _results; }, prepend: function(parent, child) { return parent.insertBefore(child, parent.firstChild); @@ -1979,7 +1976,7 @@
\ \ | \ - | \ + | \ | \ | \
\ @@ -1988,10 +1985,15 @@
\ \
\ - \ + \
\
Sauce is disabled.
\ - \ +
Lines starting with a # will be ignored.
\ + \ + \
\ \
\ @@ -2571,26 +2573,38 @@ sauce = { init: function() { - if (!(sauce.prefixes = conf['flavors'].match(/^[^#].+$/gm))) return; - sauce.names = sauce.prefixes.map(function(prefix) { - return prefix.match(/(\w+)\./)[1]; - }); - return g.callbacks.push(function(root) { - var i, link, prefix, span, suffix, _len, _ref, _results; - if (root.className === 'inline' || !(span = $('.filesize', root))) return; - suffix = $('a', span).href; - _ref = sauce.prefixes; - _results = []; - for (i = 0, _len = _ref.length; i < _len; i++) { - prefix = _ref[i]; - link = $.el('a', { - textContent: sauce.names[i], - href: prefix + suffix, - target: '_blank' - }); - _results.push($.add(span, $.tn(' '), link)); + var link, links, _i, _len; + links = conf['sauces'].match(/^[^#].+$/gm); + this.links = []; + for (_i = 0, _len = links.length; _i < _len; _i++) { + link = links[_i]; + this.links.push([link, link.match(/(\w+)\./)[1]]); + } + return g.callbacks.push(this.node); + }, + node: function(root) { + var a, img, link, span, _i, _len, _ref; + if (root.className === 'inline' || !(span = $('.filesize', root))) return; + img = $('img', root); + _ref = sauce.links; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + link = _ref[_i]; + a = $.el('a', { + textContent: link[1], + href: sauce.href(link[0], img), + target: '_blank' + }); + $.add(span, $.tn(' '), a); + } + }, + href: function(link, img) { + return link.replace(/\$\d/, function(fragment) { + switch (fragment) { + case '$1': + return img.src; + case '$2': + return img.parentNode.href; } - return _results; }); } }; @@ -3819,8 +3833,8 @@ img[md5], img[md5] + img {\ resize: vertical;\ width: 100%;\ }\ -#flavors {\ - height: 100%;\ +#sauces {\ + height: 350px;\ }\ \ #updater {\ diff --git a/changelog b/changelog index beb07180f..c8aa80bbb 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,7 @@ master +- Mayhem + Increase Sauce linking possibilites: + Thumbnails, full images. 2.25.5 - Mayhem diff --git a/script.coffee b/script.coffee index 56c8f669f..fe6ceecff 100644 --- a/script.coffee +++ b/script.coffee @@ -57,15 +57,15 @@ config = filename: '' filesize: '' md5: '' - flavors: [ - 'http://iqdb.org/?url=' - 'http://google.com/searchbyimage?image_url=' - '#http://tineye.com/search?url=' - '#http://saucenao.com/search.php?db=999&url=' - '#http://3d.iqdb.org/?url=' - '#http://regex.info/exif.cgi?imgurl=' - '#http://imgur.com/upload?url=' - '#http://ompldr.org/upload?url1=' + sauces: [ + 'http://iqdb.org/?url=$1' + 'http://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' + '#http://imgur.com/upload?url=$2' + '#http://ompldr.org/upload?url1=$2' ].join '\n' time: '%m/%d/%y(%a)%H:%M' backlink: '>>%id' @@ -217,7 +217,7 @@ $ = (selector, root=d.body) -> $.extend = (object, properties) -> for key, val of properties object[key] = val - object + return $.extend $, ready: (fc) -> @@ -282,6 +282,7 @@ $.extend $, add: (parent, children...) -> for child in children parent.appendChild child + return prepend: (parent, child) -> parent.insertBefore child, parent.firstChild after: (root, el) -> @@ -1516,7 +1517,7 @@ options =
| - | + | | |
@@ -1525,10 +1526,15 @@ options =
- +
Sauce is disabled.
- +
Lines starting with a # will be ignored.
+
    These variables will be replaced by the corresponding url: +
  • $1: Thumbnail.
  • +
  • $2: Full image.
  • +
+
@@ -2025,17 +2031,29 @@ anonymize = sauce = init: -> - return unless sauce.prefixes = conf['flavors'].match /^[^#].+$/gm - sauce.names = sauce.prefixes.map (prefix) -> prefix.match(/(\w+)\./)[1] - g.callbacks.push (root) -> - return if root.className is 'inline' or not span = $ '.filesize', root - suffix = $('a', span).href - for prefix, i in sauce.prefixes - link = $.el 'a', - textContent: sauce.names[i] - href: prefix + suffix - target: '_blank' - $.add span, $.tn(' '), link + # return unless + links = conf['sauces'].match /^[^#].+$/gm + @links = [] + for link in links + @links.push [link, link.match(/(\w+)\./)[1]] + g.callbacks.push @node + node: (root) -> + return if root.className is 'inline' or not span = $ '.filesize', root + img = $ 'img', root + for link in sauce.links + a = $.el 'a', + textContent: link[1] + href: sauce.href link[0], img + target: '_blank' + $.add span, $.tn(' '), a + return + href: (link, img) -> + link.replace /\$\d/, (fragment) -> + switch fragment + when '$1' + img.src + when '$2' + img.parentNode.href revealSpoilers = init: -> @@ -3060,8 +3078,8 @@ img[md5], img[md5] + img { resize: vertical; width: 100%; } -#flavors { - height: 100%; +#sauces { + height: 350px; } #updater {