From a0b80062506b269a9021f523bf4c62926436f239 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 2 Feb 2012 20:01:16 +0100 Subject: [PATCH 01/18] Fix #167. keyup isn't triggered when pasting for example. --- 4chan_x.user.js | 10 +++++++--- changelog | 2 ++ script.coffee | 6 ++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index cd8480063..61537f442 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1562,7 +1562,7 @@ } }, dialog: function() { - var e, fileInput, input, mimeTypes, spoiler, thread, threads, _i, _j, _len, _len2, _ref, _ref2; + var e, fileInput, input, mimeTypes, name, spoiler, thread, threads, _i, _j, _len, _len2, _ref, _ref2; qr.el = ui.dialog('qr', 'top:0;right:0;', '\
\ Quick Reply \ @@ -1629,8 +1629,12 @@ new qr.reply().select(); _ref2 = ['name', 'email', 'sub', 'com']; for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { - input = _ref2[_j]; - $.on($("[name=" + input + "]", qr.el), 'keyup', function() { + name = _ref2[_j]; + input = $("[name=" + input + "]", qr.el); + $.on(input, 'keyup', function() { + return qr.selected[this.name] = this.value; + }); + $.on(input, 'change', function() { return qr.selected[this.name] = this.value; }); } diff --git a/changelog b/changelog index 462108b6a..85d3929cd 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master +- Mayhem + Fix text inputs not saved correctly in the QR. 2.25.3 - Mayhem diff --git a/script.coffee b/script.coffee index 2e236083c..7a713487b 100644 --- a/script.coffee +++ b/script.coffee @@ -1201,8 +1201,10 @@ qr = new qr.reply().select() # save selected reply's data - for input in ['name', 'email', 'sub', 'com'] - $.on $("[name=#{input}]", qr.el), 'keyup', -> qr.selected[@name] = @value + for name in ['name', 'email', 'sub', 'com'] + input = $ "[name=#{input}]", qr.el + $.on input, 'keyup', -> qr.selected[@name] = @value + $.on input, 'change', -> qr.selected[@name] = @value # sync between tabs $.sync 'qr.persona', (persona) -> return if qr.replies.length isnt 1 From f1eca3da2e37d2da9c3300816aaf8883a7b0dc5a Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 2 Feb 2012 20:11:36 +0100 Subject: [PATCH 02/18] Fix #165. Fix selector. --- 4chan_x.user.js | 15 +++++++++++---- script.coffee | 13 +++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 61537f442..e72cde4b2 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1539,9 +1539,16 @@ return this.input.value = null; }, count: function(count) { - var s; - s = count === 1 ? '' : 's'; - this.input.placeholder = "Verification (" + count + " cached captcha" + s + ")"; + this.input.placeholder = (function() { + switch (count) { + case 0: + return 'Verification (Shift + Enter to cache)'; + case 1: + return 'Vertification (1 cached captcha)'; + default: + return "Verification (" + count + " cached captchas)"; + } + })(); return this.input.alt = count; }, reload: function(focus) { @@ -1630,7 +1637,7 @@ _ref2 = ['name', 'email', 'sub', 'com']; for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { name = _ref2[_j]; - input = $("[name=" + input + "]", qr.el); + input = $("[name=" + name + "]", qr.el); $.on(input, 'keyup', function() { return qr.selected[this.name] = this.value; }); diff --git a/script.coffee b/script.coffee index 7a713487b..562cf7f5c 100644 --- a/script.coffee +++ b/script.coffee @@ -1130,9 +1130,14 @@ qr = @img.src = "http://www.google.com/recaptcha/api/image?c=#{challenge}" @input.value = null count: (count) -> - s = if count is 1 then '' else 's' - @input.placeholder = "Verification (#{count} cached captcha#{s})" - @input.alt = count # For XTRM RICE. + @input.placeholder = switch count + when 0 + 'Verification (Shift + Enter to cache)' + when 1 + 'Vertification (1 cached captcha)' + else + "Verification (#{count} cached captchas)" + @input.alt = count # For XTRM RICE. reload: (focus) -> window.location = 'javascript:Recaptcha.reload()' # Focus if we meant to. @@ -1202,7 +1207,7 @@ qr = new qr.reply().select() # save selected reply's data for name in ['name', 'email', 'sub', 'com'] - input = $ "[name=#{input}]", qr.el + input = $ "[name=#{name}]", qr.el $.on input, 'keyup', -> qr.selected[@name] = @value $.on input, 'change', -> qr.selected[@name] = @value # sync between tabs From 32878d7e2ffefe87318438a1585d91050318ba0c Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 2 Feb 2012 20:21:51 +0100 Subject: [PATCH 03/18] Fix #171. --- 4chan_x.user.js | 14 ++++++++------ script.coffee | 11 +++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index e72cde4b2..2bc4a77b4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1200,7 +1200,7 @@ qr = { init: function() { - var h1, iframe; + var h1, iframe, loadChecking; if (!$.id('recaptcha_challenge_field_holder')) return; $('form[name=post]').hidden = true; h1 = $.el('h1', { @@ -1219,14 +1219,16 @@ $.on(iframe, 'error', function() { return this.src = this.src; }); - $.on(iframe, 'load', function() { - var _this = this; - if (!(qr.status.ready || this.src === 'about:blank')) { - this.src = 'about:blank'; + loadChecking = function(iframe) { + if (!qr.status.ready) { + iframe.src = 'about:blank'; return setTimeout((function() { - return _this.src = 'http://sys.4chan.org/post'; + return iframe.src = 'http://sys.4chan.org/post'; }), 250); } + }; + $.on(iframe, 'load', function() { + if (this.src !== 'about:blank') return setTimeout(loadChecking, 250, this); }); $.add(d.body, iframe); if (conf['Persistent QR']) { diff --git a/script.coffee b/script.coffee index 562cf7f5c..24ff8362f 100644 --- a/script.coffee +++ b/script.coffee @@ -869,17 +869,20 @@ qr = $.add $('.postarea'), h1 g.callbacks.push (root) -> $.on $('.quotejs + .quotejs', root), 'click', qr.quote + iframe = $.el 'iframe', id: 'iframe' hidden: true src: 'http://sys.4chan.org/post' $.on iframe, 'error', -> @src = @src # Greasemonkey ghetto fix - $.on iframe, 'load', -> - unless qr.status.ready or @src is 'about:blank' - @src = 'about:blank' - setTimeout (=> @src = 'http://sys.4chan.org/post'), 250 + loadChecking = (iframe) -> + unless qr.status.ready + iframe.src = 'about:blank' + setTimeout (-> iframe.src = 'http://sys.4chan.org/post'), 250 + $.on iframe, 'load', -> unless @src is 'about:blank' then setTimeout loadChecking, 250, @ $.add d.body, iframe + if conf['Persistent QR'] qr.dialog() qr.hide() if conf['Auto Hide QR'] From 028b30d3f0b457ed420bcca1be138946e6e82c43 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 2 Feb 2012 20:25:43 +0100 Subject: [PATCH 04/18] Fix #147 --- 4chan_x.user.js | 7 ++++--- script.coffee | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 2bc4a77b4..9e8824081 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1575,11 +1575,11 @@ qr.el = ui.dialog('qr', 'top:0;right:0;', '\
\ Quick Reply \ - x\ + x\
\
\
\ - \ +
\
\
\
\ @@ -1612,7 +1612,8 @@ threads += ""; } $.prepend($('.move > span', qr.el), $.el('select', { - innerHTML: threads + innerHTML: threads, + title: 'Create a new thread / Reply to a thread' })); $.on($('select', qr.el), 'mousedown', function(e) { return e.stopPropagation(); diff --git a/script.coffee b/script.coffee index 24ff8362f..bbd8424b6 100644 --- a/script.coffee +++ b/script.coffee @@ -1159,11 +1159,11 @@ qr = qr.el = ui.dialog 'qr', 'top:0;right:0;', '
- +
@@ -1195,7 +1195,9 @@ qr = threads = '' for thread in $$ '.op' threads += "" - $.prepend $('.move > span', qr.el), $.el 'select', innerHTML: threads + $.prepend $('.move > span', qr.el), $.el 'select' + innerHTML: threads + title: 'Create a new thread / Reply to a thread' $.on $('select', qr.el), 'mousedown', (e) -> e.stopPropagation() $.on $('#autohide', qr.el), 'change', qr.toggleHide $.on $('.close', qr.el), 'click', qr.close From ed913bcc32cdce48f9b314a4c78dc5e070f0c45d Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 2 Feb 2012 20:29:34 +0100 Subject: [PATCH 05/18] Fix 170. Revert "We retard friendly now!" This reverts commit c5af521a48b108c4864d786a0fc7ec4148bd7e63. Conflicts: 4chan_x.user.js --- 4chan_x.user.js | 8 +------- script.coffee | 5 ----- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 9e8824081..81e19ccc1 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1200,14 +1200,8 @@ qr = { init: function() { - var h1, iframe, loadChecking; + var iframe, loadChecking; if (!$.id('recaptcha_challenge_field_holder')) return; - $('form[name=post]').hidden = true; - h1 = $.el('h1', { - innerHTML: '
Open the Quick Reply' - }); - $.on($('a', h1), 'click', qr.open); - $.add($('.postarea'), h1); g.callbacks.push(function(root) { return $.on($('.quotejs + .quotejs', root), 'click', qr.quote); }); diff --git a/script.coffee b/script.coffee index bbd8424b6..336d60297 100644 --- a/script.coffee +++ b/script.coffee @@ -862,11 +862,6 @@ nav = qr = init: -> return unless $.id 'recaptcha_challenge_field_holder' - $('form[name=post]').hidden = true - h1 = $.el 'h1' - innerHTML: 'Open the Quick Reply' - $.on $('a', h1), 'click', qr.open - $.add $('.postarea'), h1 g.callbacks.push (root) -> $.on $('.quotejs + .quotejs', root), 'click', qr.quote From c94bce44b16a2bd906df7b49421c7a830a81c558 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 2 Feb 2012 20:44:13 +0100 Subject: [PATCH 06/18] Fix typo. Update changelog. --- 4chan_x.user.js | 2 +- changelog | 3 ++- script.coffee | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 81e19ccc1..fbdad8288 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1573,7 +1573,7 @@
\ \
\ -
\ +
+
\
\
\
\ diff --git a/changelog b/changelog index 85d3929cd..d07451316 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,7 @@ master - Mayhem - Fix text inputs not saved correctly in the QR. + Fix text inputs not sent/saved correctly in the QR when pasted for example. + Revert hidding normal post form. 2.25.3 - Mayhem diff --git a/script.coffee b/script.coffee index 336d60297..2177a4be1 100644 --- a/script.coffee +++ b/script.coffee @@ -1158,7 +1158,7 @@ qr =
-
+
+
From 7506274a84338361329871e0544faaa26441a9af Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 2 Feb 2012 20:48:56 +0100 Subject: [PATCH 07/18] Release 2.25.4. --- 4chan_x.user.js | 6 +++--- Cakefile | 2 +- changelog | 2 ++ latest.js | 2 +- script.coffee | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index fbdad8288..0ac1abb5a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan x -// @version 2.25.3 +// @version 2.25.4 // @namespace aeosynth // @description Adds various features. // @copyright 2009-2011 James Campos @@ -19,7 +19,7 @@ * Copyright (c) 2009-2011 James Campos * Copyright (c) 2012 Nicolas Stepien * http://mayhemydg.github.com/4chan-x/ - * 4chan X 2.25.3 + * 4chan X 2.25.4 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -205,7 +205,7 @@ NAMESPACE = '4chan_x.'; - VERSION = '2.25.3'; + VERSION = '2.25.4'; SECOND = 1000; diff --git a/Cakefile b/Cakefile index 611a21218..6c0495fd8 100644 --- a/Cakefile +++ b/Cakefile @@ -2,7 +2,7 @@ {exec} = require 'child_process' fs = require 'fs' -VERSION = '2.25.3' +VERSION = '2.25.4' HEADER = """ // ==UserScript== diff --git a/changelog b/changelog index d07451316..abe57db4c 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master + +2.25.4 - Mayhem Fix text inputs not sent/saved correctly in the QR when pasted for example. Revert hidding normal post form. diff --git a/latest.js b/latest.js index 4e3a36f0a..86d878f36 100644 --- a/latest.js +++ b/latest.js @@ -1 +1 @@ -postMessage({version:'2.25.3'},'*'); +postMessage({version:'2.25.4'},'*'); diff --git a/script.coffee b/script.coffee index 2177a4be1..b4d5d4116 100644 --- a/script.coffee +++ b/script.coffee @@ -120,7 +120,7 @@ conf = {} ) null, config NAMESPACE = '4chan_x.' -VERSION = '2.25.3' +VERSION = '2.25.4' SECOND = 1000 MINUTE = 60*SECOND HOUR = 60*MINUTE From ad3e363bf2eadca59c6f80114a623f5e65f48b8d Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 2 Feb 2012 21:42:05 +0100 Subject: [PATCH 08/18] Small refactor. --- 4chan_x.user.js | 6 ++---- script.coffee | 10 +++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 0ac1abb5a..3c0a62ea3 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1349,11 +1349,9 @@ } ta = $('textarea', qr.el); caretPos = ta.selectionStart; - ta.value = ta.value.slice(0, caretPos) + text + ta.value.slice(ta.selectionEnd, ta.value.length); + qr.selected.el.lastChild.textContent = qr.selected.com = ta.value = ta.value.slice(0, caretPos) + text + ta.value.slice(ta.selectionEnd, ta.value.length); ta.focus(); - ta.selectionEnd = ta.selectionStart = caretPos + text.length; - qr.selected.com = ta.value; - return qr.selected.el.lastChild.textContent = ta.value; + return ta.selectionEnd = ta.selectionStart = caretPos + text.length; }, fileDrop: function(e) { if (/TEXTAREA|INPUT/.test(e.target.nodeName)) return; diff --git a/script.coffee b/script.coffee index b4d5d4116..dcd1862fe 100644 --- a/script.coffee +++ b/script.coffee @@ -983,15 +983,15 @@ qr = ta = $ 'textarea', qr.el caretPos = ta.selectionStart # Replace selection for text. - ta.value = ta.value[0...caretPos] + text + ta.value[ta.selectionEnd...ta.value.length] + # onchange event isn't triggered, save value. + qr.selected.el.lastChild.textContent = + qr.selected.com = + ta.value = + ta.value[0...caretPos] + text + ta.value[ta.selectionEnd...ta.value.length] ta.focus() # Move the caret to the end of the new quote. ta.selectionEnd = ta.selectionStart = caretPos + text.length - # onchange event isn't triggered, save value. - qr.selected.com = ta.value - qr.selected.el.lastChild.textContent = ta.value - fileDrop: (e) -> return if /TEXTAREA|INPUT/.test e.target.nodeName e.preventDefault() From 6e06d6b945d2afabd2cc49bea678d11b6e2128ca Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 3 Feb 2012 15:01:02 +0100 Subject: [PATCH 09/18] Hide the normal post form by default, optional. Close #173. --- 4chan_x.user.js | 14 ++++++++++++-- changelog | 2 ++ script.coffee | 7 +++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3c0a62ea3..8a274de2f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -117,7 +117,8 @@ 'Persistent QR': [false, 'The Quick reply won\'t disappear after posting.'], 'Auto Hide QR': [true, 'Automatically hide the quick reply when posting.'], 'Remember Subject': [false, 'Remember the subject field, instead of resetting after posting.'], - 'Remember Spoiler': [false, 'Remember the spoiler state, instead of resetting after posting.'] + 'Remember Spoiler': [false, 'Remember the spoiler state, instead of resetting after posting.'], + 'Hide Original Post Form': [true, 'Replace the normal post form with a shortcut to open the QR.'] }, Quoting: { 'Quote Backlinks': [true, 'Add quote backlinks'], @@ -1200,8 +1201,17 @@ qr = { init: function() { - var iframe, loadChecking; + var form, iframe, link, loadChecking; if (!$.id('recaptcha_challenge_field_holder')) return; + if (conf['Hide Original Post Form']) { + link = $.el('h1', { + innerHTML: "" + (g.REPLY ? 'Open the Quick Reply' : 'Create a New Thread') + "" + }); + $.on($('a', link), 'click', qr.open); + form = d.forms[0]; + form.hidden = true; + $.before(form, link); + } g.callbacks.push(function(root) { return $.on($('.quotejs + .quotejs', root), 'click', qr.quote); }); diff --git a/changelog b/changelog index abe57db4c..16f4827aa 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master +- Mayhem + Hide the normal post form by default, optional. 2.25.4 - Mayhem diff --git a/script.coffee b/script.coffee index dcd1862fe..bf592066b 100644 --- a/script.coffee +++ b/script.coffee @@ -38,6 +38,7 @@ config = 'Auto Hide QR': [true, 'Automatically hide the quick reply when posting.'] 'Remember Subject': [false, 'Remember the subject field, instead of resetting after posting.'] 'Remember Spoiler': [false, 'Remember the spoiler state, instead of resetting after posting.'] + 'Hide Original Post Form': [true, 'Replace the normal post form with a shortcut to open the QR.'] Quoting: 'Quote Backlinks': [true, 'Add quote backlinks'] 'OP Backlinks': [false, 'Add backlinks to the OP'] @@ -862,6 +863,12 @@ nav = qr = init: -> return unless $.id 'recaptcha_challenge_field_holder' + if conf['Hide Original Post Form'] + link = $.el 'h1', innerHTML: "#{if g.REPLY then 'Open the Quick Reply' else 'Create a New Thread'}" + $.on $('a', link), 'click', qr.open + form = d.forms[0] + form.hidden = true + $.before form, link g.callbacks.push (root) -> $.on $('.quotejs + .quotejs', root), 'click', qr.quote From 61621178c614f2febdca2de00874ce1cd7909325 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 3 Feb 2012 16:39:42 +0100 Subject: [PATCH 10/18] Don't remove images when unexpanding, hide them: this will avoid another redirections if it fails to load again, and will keep it loaded in memory even if it's not in the cache anymore (sup preloading users). Image expanding selector optimization. --- 4chan_x.user.js | 13 +++++++++---- script.coffee | 14 ++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 8a274de2f..6c29c7cc0 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3308,7 +3308,7 @@ var thumb, _i, _j, _len, _len2, _ref, _ref2, _results, _results2; imgExpand.on = this.checked; if (imgExpand.on) { - _ref = $$('.op > a > img[md5]:last-child, table:not([hidden]) img[md5]:last-child'); + _ref = $$('img[md5]'); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { thumb = _ref[_i]; @@ -3364,11 +3364,16 @@ }, contract: function(thumb) { thumb.hidden = false; - return $.rm(thumb.nextSibling); + return thumb.nextSibling.hidden = true; }, expand: function(thumb, url) { var a, filesize, img, max; - if (thumb.hidden) return; + if ($.x('ancestor-or-self::*[@hidden]', thumb)) return; + thumb.hidden = true; + if (img = thumb.nextSibling) { + img.hidden = false; + return; + } a = thumb.parentNode; img = $.el('img', { src: url || a.href @@ -3379,7 +3384,6 @@ img.style.maxWidth = "" + max[1] + "px"; } if (conf['404 Redirect']) $.on(img, 'error', imgExpand.error); - thumb.hidden = true; return $.add(a, img); }, error: function() { @@ -3388,6 +3392,7 @@ thumb = this.previousSibling; src = href.split('/'); imgExpand.contract(thumb); + $.rm(this); if (!(this.src.split('/')[2] === 'images.4chan.org' && (url = redirect.image(src[3], src[5])))) { if (g.dead) return; url = href + '?' + Date.now(); diff --git a/script.coffee b/script.coffee index bf592066b..b751e1a17 100644 --- a/script.coffee +++ b/script.coffee @@ -2541,7 +2541,7 @@ imgExpand = all: -> imgExpand.on = @checked if imgExpand.on #expand - for thumb in $$ '.op > a > img[md5]:last-child, table:not([hidden]) img[md5]:last-child' + for thumb in $$ 'img[md5]' imgExpand.expand thumb else #contract for thumb in $$ 'img[md5][hidden]' @@ -2577,10 +2577,16 @@ imgExpand = contract: (thumb) -> thumb.hidden = false - $.rm thumb.nextSibling + thumb.nextSibling.hidden = true expand: (thumb, url) -> - return if thumb.hidden + # Do not expand images of hidden/filtered replies, or already expanded pictures. + return if $.x 'ancestor-or-self::*[@hidden]', thumb + thumb.hidden = true + if img = thumb.nextSibling + # Expand already loaded picture + img.hidden = false + return a = thumb.parentNode img = $.el 'img', src: url or a.href @@ -2589,7 +2595,6 @@ imgExpand = max = filesize.match /(\d+)x/ img.style.maxWidth = "#{max[1]}px" $.on img, 'error', imgExpand.error if conf['404 Redirect'] - thumb.hidden = true $.add a, img error: -> @@ -2597,6 +2602,7 @@ imgExpand = thumb = @previousSibling src = href.split '/' imgExpand.contract thumb + $.rm @ unless @src.split('/')[2] is 'images.4chan.org' and url = redirect.image src[3], src[5] return if g.dead # CloudFlare may cache banned pages instead of images. From e64271c27b0050e60e9954762caeceed5645c041 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 3 Feb 2012 17:27:21 +0100 Subject: [PATCH 11/18] Remove outdated Firefox specific code to prevent expanded pictures from having their width fit the table instead of it's natural width. That was fixed in Fx10 I believe. --- 4chan_x.user.js | 7 +------ script.coffee | 4 ---- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 6c29c7cc0..ed871e72f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3367,7 +3367,7 @@ return thumb.nextSibling.hidden = true; }, expand: function(thumb, url) { - var a, filesize, img, max; + var a, img; if ($.x('ancestor-or-self::*[@hidden]', thumb)) return; thumb.hidden = true; if (img = thumb.nextSibling) { @@ -3378,11 +3378,6 @@ img = $.el('img', { src: url || a.href }); - if (engine === 'gecko' && a.parentNode.className !== 'op') { - filesize = $.x('preceding-sibling::span[@class="filesize"]', a).textContent; - max = filesize.match(/(\d+)x/); - img.style.maxWidth = "" + max[1] + "px"; - } if (conf['404 Redirect']) $.on(img, 'error', imgExpand.error); return $.add(a, img); }, diff --git a/script.coffee b/script.coffee index b751e1a17..8973f4813 100644 --- a/script.coffee +++ b/script.coffee @@ -2590,10 +2590,6 @@ imgExpand = a = thumb.parentNode img = $.el 'img', src: url or a.href - if engine is 'gecko' and a.parentNode.className isnt 'op' - filesize = $.x('preceding-sibling::span[@class="filesize"]', a).textContent - max = filesize.match /(\d+)x/ - img.style.maxWidth = "#{max[1]}px" $.on img, 'error', imgExpand.error if conf['404 Redirect'] $.add a, img From 547afd0143f6f0e45247099b317b3f43c7480089 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 3 Feb 2012 18:03:33 +0100 Subject: [PATCH 12/18] Release 2.25.5. --- 4chan_x.user.js | 6 +++--- Cakefile | 2 +- changelog | 2 ++ latest.js | 2 +- script.coffee | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ed871e72f..8142ef40e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan x -// @version 2.25.4 +// @version 2.25.5 // @namespace aeosynth // @description Adds various features. // @copyright 2009-2011 James Campos @@ -19,7 +19,7 @@ * Copyright (c) 2009-2011 James Campos * Copyright (c) 2012 Nicolas Stepien * http://mayhemydg.github.com/4chan-x/ - * 4chan X 2.25.4 + * 4chan X 2.25.5 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -206,7 +206,7 @@ NAMESPACE = '4chan_x.'; - VERSION = '2.25.4'; + VERSION = '2.25.5'; SECOND = 1000; diff --git a/Cakefile b/Cakefile index 6c0495fd8..937d63640 100644 --- a/Cakefile +++ b/Cakefile @@ -2,7 +2,7 @@ {exec} = require 'child_process' fs = require 'fs' -VERSION = '2.25.4' +VERSION = '2.25.5' HEADER = """ // ==UserScript== diff --git a/changelog b/changelog index 16f4827aa..beb07180f 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master + +2.25.5 - Mayhem Hide the normal post form by default, optional. diff --git a/latest.js b/latest.js index 86d878f36..ea8868a08 100644 --- a/latest.js +++ b/latest.js @@ -1 +1 @@ -postMessage({version:'2.25.4'},'*'); +postMessage({version:'2.25.5'},'*'); diff --git a/script.coffee b/script.coffee index 8973f4813..9441d6b34 100644 --- a/script.coffee +++ b/script.coffee @@ -121,7 +121,7 @@ conf = {} ) null, config NAMESPACE = '4chan_x.' -VERSION = '2.25.4' +VERSION = '2.25.5' SECOND = 1000 MINUTE = 60*SECOND HOUR = 60*MINUTE From 5bfb3d4c18d5949d09180dd3ef9004dbc41b0c61 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 4 Feb 2012 20:06:51 +0100 Subject: [PATCH 13/18] A bit of random cleaning. --- 4chan_x.user.js | 19 ++++++++----------- script.coffee | 21 +++++++++------------ 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 8142ef40e..b6d854186 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2756,8 +2756,8 @@ quoteBacklink = { init: function() { var format; - format = conf['backlink'].replace(/%id/, "' + id + '"); - quoteBacklink.funk = Function('id', "return'" + format + "'"); + format = conf['backlink'].replace(/%id/g, "' + id + '"); + quoteBacklink.funk = Function('id', "return '" + format + "'"); return g.callbacks.push(function(root) { var a, container, el, id, link, qid, quote, quotes, _i, _len, _ref, _results; if (/\binline\b/.test(root.className)) return; @@ -2765,7 +2765,7 @@ _ref = $$('.quotelink', root); for (_i = 0, _len = _ref.length; _i < _len; _i++) { quote = _ref[_i]; - if (qid = quote.hash.slice(1)) quotes[qid] = quote; + if (qid = quote.hash.slice(1)) quotes[qid] = true; } id = $('input', root).name; a = $.el('a', { @@ -2775,8 +2775,9 @@ }); _results = []; for (qid in quotes) { - if (!(el = $.id(qid))) continue; - if (el.className === 'op' && !conf['OP Backlinks']) continue; + if (!(el = $.id(qid)) || el.className === 'op' && !conf['OP Backlinks']) { + continue; + } link = a.cloneNode(true); if (conf['Quote Preview']) { $.on(link, 'mouseover', quotePreview.mouseover); @@ -3178,15 +3179,11 @@ empty: 'data:image/gif;base64,R0lGODlhEAAQAJEAAAAAAP///9vb2////yH5BAEAAAMALAAAAAAQABAAAAIvnI+pq+D9DBAUoFkPFnbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw==', dead: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAAP8AAP///////yH5BAEKAAIALAAAAAAQABAAAAIvlI+pq+D9DAgUoFkPDlbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw==', update: function() { - var clone, favicon, l; + var favicon, l; l = unread.replies.length; favicon = $('link[rel="shortcut icon"]', d.head); favicon.href = g.dead ? l ? this.unreadDead : this.dead : l ? this.unread : this["default"]; - if (engine !== 'webkit') { - clone = favicon.cloneNode(true); - favicon.href = null; - return $.replace(favicon, clone); - } + if (engine !== 'webkit') return $.add(d.head, $.rm(favicon)); } }; diff --git a/script.coffee b/script.coffee index 9441d6b34..06b0c84df 100644 --- a/script.coffee +++ b/script.coffee @@ -2157,26 +2157,25 @@ titlePost = quoteBacklink = init: -> - format = conf['backlink'].replace /%id/, "' + id + '" - quoteBacklink.funk = Function 'id', "return'#{format}'" + format = conf['backlink'].replace /%id/g, "' + id + '" + quoteBacklink.funk = Function 'id', "return '#{format}'" g.callbacks.push (root) -> return if /\binline\b/.test root.className quotes = {} for quote in $$ '.quotelink', root - #don't process >>>/b/ + # Don't process >>>/b/. if qid = quote.hash[1..] - #duplicate quotes get overwritten - quotes[qid] = quote - # op or reply + # Duplicate quotes get overwritten. + quotes[qid] = true + # OP or reply id. id = $('input', root).name a = $.el 'a', href: "##{id}" className: if root.hidden then 'filtered backlink' else 'backlink' textContent: quoteBacklink.funk id for qid of quotes - continue unless el = $.id qid - #don't backlink the op - continue if el.className is 'op' and !conf['OP Backlinks'] + # Don't backlink the OP. + continue if !(el = $.id qid) or el.className is 'op' and !conf['OP Backlinks'] link = a.cloneNode true if conf['Quote Preview'] $.on link, 'mouseover', quotePreview.mouseover @@ -2472,9 +2471,7 @@ Favicon = #`favicon.href = href` isn't enough on Opera #Opera won't always update the favicon if the href do not change if engine isnt 'webkit' - clone = favicon.cloneNode true - favicon.href = null - $.replace favicon, clone + $.add d.head, $.rm favicon redirect = init: -> From 0fe6de623653835d73574155431c1d3c4ead48b9 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 4 Feb 2012 20:43:37 +0100 Subject: [PATCH 14/18] Set a max-height for the thread watcher, until you hover over it. Close #177. --- 4chan_x.user.js | 24 +++++++++++++----------- script.coffee | 24 +++++++++++++----------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index b6d854186..208bba20b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3858,22 +3858,24 @@ img[md5], img[md5] + img {\ }\ \ #watcher {\ + padding-bottom: 5px;\ position: absolute;\ -}\ -#watcher > div {\ overflow: hidden;\ - padding-right: 5px;\ - padding-left: 5px;\ - text-overflow: ellipsis;\ - max-width: 200px;\ white-space: nowrap;\ }\ -#watcher > div.move {\ - text-decoration: underline;\ - padding-top: 5px;\ +#watcher:not(:hover) {\ + max-height: 220px;\ }\ -#watcher > div:last-child {\ - padding-bottom: 5px;\ +#watcher > div {\ + max-width: 200px;\ + overflow: hidden;\ + padding-left: 5px;\ + padding-right: 5px;\ + text-overflow: ellipsis;\ +}\ +#watcher > .move {\ + padding-top: 5px;\ + text-decoration: underline;\ }\ \ #qp {\ diff --git a/script.coffee b/script.coffee index 06b0c84df..783613eb3 100644 --- a/script.coffee +++ b/script.coffee @@ -3099,22 +3099,24 @@ img[md5], img[md5] + img { } #watcher { + padding-bottom: 5px; position: absolute; -} -#watcher > div { overflow: hidden; - padding-right: 5px; - padding-left: 5px; - text-overflow: ellipsis; - max-width: 200px; white-space: nowrap; } -#watcher > div.move { - text-decoration: underline; - padding-top: 5px; +#watcher:not(:hover) { + max-height: 220px; } -#watcher > div:last-child { - padding-bottom: 5px; +#watcher > div { + max-width: 200px; + overflow: hidden; + padding-left: 5px; + padding-right: 5px; + text-overflow: ellipsis; +} +#watcher > .move { + padding-top: 5px; + text-decoration: underline; } #qp { From b936b6bfcbf17a6b4e72930e0766e1e19abf40da Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 4 Feb 2012 22:02:59 +0100 Subject: [PATCH 15/18] Simplify config flattening. Added a list of allowed keys for keybinds. Refactor keybinds settings. --- 4chan_x.user.js | 105 ++++++++++++++++++++---------------------------- script.coffee | 97 ++++++++++++++++++-------------------------- 2 files changed, 82 insertions(+), 120 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 208bba20b..9352cae3a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -146,28 +146,28 @@ backlink: '>>%id', favicon: 'ferongr', hotkeys: { - openOptions: 'ctrl+o', - close: 'Esc', - spoiler: 'ctrl+s', - openQR: 'i', - openEmptyQR: 'I', - submit: 'alt+s', - nextReply: 'J', - previousReply: 'K', - nextThread: 'n', - previousThread: 'p', - nextPage: 'L', - previousPage: 'H', - zero: '0', - openThreadTab: 'o', - openThread: 'O', - expandThread: 'e', - watch: 'w', - hide: 'x', - expandImages: 'm', - expandAllImages: 'M', - update: 'u', - unreadCountTo0: 'z' + openOptions: ['ctrl+o', 'Open Options'], + close: ['Esc', 'Close Options or QR'], + spoiler: ['ctrl+s', 'Quick spoiler'], + openQR: ['i', 'Open QR with post number inserted'], + openEmptyQR: ['I', 'Open QR without post number inserted'], + submit: ['alt+s', 'Submit post'], + nextReply: ['J', 'Select next reply'], + previousReply: ['K', 'Select previous reply'], + nextThread: ['n', 'See next thread'], + previousThread: ['p', 'See previous thread'], + nextPage: ['L', 'Jump to the next page'], + previousPage: ['H', 'Jump to the previous page'], + zero: ['0', 'Jump to page 0'], + openThreadTab: ['o', 'Open thread in current tab'], + openThread: ['O', 'Open thread in new tab'], + expandThread: ['e', 'Expand thread'], + watch: ['w', 'Watch thread'], + hide: ['x', 'Hide thread'], + expandImages: ['m', 'Expand selected image'], + expandAllImages: ['M', 'Expand all images'], + update: ['u', 'Update now'], + unreadCountTo0: ['z', 'Reset unread count to 0'] }, updater: { checkbox: { @@ -186,19 +186,17 @@ (flatten = function(parent, obj) { var key, val, _results; - if (obj.length) { - if (typeof obj[0] === 'boolean') { + if (typeof obj === 'object') { + if (obj.length) { return conf[parent] = obj[0]; } else { - return conf[parent] = obj; + _results = []; + for (key in obj) { + val = obj[key]; + _results.push(flatten(key, val)); + } + return _results; } - } else if (typeof obj === 'object') { - _results = []; - for (key in obj) { - val = obj[key]; - _results.push(flatten(key, val)); - } - return _results; } else { return conf[parent] = obj; } @@ -1969,7 +1967,7 @@ } }, dialog: function() { - var arr, back, checked, description, dialog, favicon, hiddenNum, hiddenThreads, indicator, indicators, input, key, li, obj, overlay, ta, time, ul, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4; + var arr, back, checked, description, dialog, favicon, hiddenNum, hiddenThreads, indicator, indicators, input, key, li, obj, overlay, ta, time, tr, ul, _i, _j, _len, _len2, _ref, _ref2, _ref3, _ref4; dialog = $.el('div', { id: 'options', className: 'reply dialog', @@ -2041,30 +2039,9 @@ \
\
Keybinds are disabled.
\ +
Allowed keys: Ctrl, Alt, a-z, A-Z, 0-1, Up, Down, Right, Left.
\ \ \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \
ActionsKeybinds
Open Options
Close Options or QR
Quick spoiler
Open QR with post number inserted
Open QR without post number inserted
Submit post
Select next reply
Select previous reply
See next thread
See previous thread
Jump to the next page
Jump to the previous page
Jump to page 0
Open thread in current tab
Open thread in new tab
Expand thread
Watch thread
Hide thread
Expand selected image
Expand all images
Update now
Reset the unread count to 0
\
\ ' @@ -2110,17 +2087,21 @@ favicon.value = conf['favicon']; $.on(favicon, 'change', $.cb.value); $.on(favicon, 'change', options.favicon); - _ref3 = $$('#keybinds_tab + div input', dialog); - for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) { - input = _ref3[_j]; - input.type = 'text'; - input.value = conf[input.name]; + _ref3 = config.hotkeys; + for (key in _ref3) { + arr = _ref3[key]; + tr = $.el('tr', { + innerHTML: "" + arr[1] + "" + }); + input = $('input', tr); + input.value = conf[key]; $.on(input, 'keydown', options.keybind); + $.add($('#keybinds_tab + div tbody', dialog), tr); } indicators = {}; _ref4 = $$('.warning', dialog); - for (_k = 0, _len3 = _ref4.length; _k < _len3; _k++) { - indicator = _ref4[_k]; + for (_j = 0, _len2 = _ref4.length; _j < _len2; _j++) { + indicator = _ref4[_j]; key = indicator.firstChild.textContent; indicator.hidden = conf[key]; indicators[key] = indicator; diff --git a/script.coffee b/script.coffee index 783613eb3..56c8f669f 100644 --- a/script.coffee +++ b/script.coffee @@ -71,34 +71,34 @@ config = backlink: '>>%id' favicon: 'ferongr' hotkeys: - openOptions: 'ctrl+o' - close: 'Esc' - spoiler: 'ctrl+s' - openQR: 'i' - openEmptyQR: 'I' - submit: 'alt+s' - nextReply: 'J' - previousReply: 'K' - nextThread: 'n' - previousThread: 'p' - nextPage: 'L' - previousPage: 'H' - zero: '0' - openThreadTab: 'o' - openThread: 'O' - expandThread: 'e' - watch: 'w' - hide: 'x' - expandImages: 'm' - expandAllImages: 'M' - update: 'u' - unreadCountTo0: 'z' + openOptions: ['ctrl+o', 'Open Options'] + close: ['Esc', 'Close Options or QR'] + spoiler: ['ctrl+s', 'Quick spoiler'] + openQR: ['i', 'Open QR with post number inserted'] + openEmptyQR: ['I', 'Open QR without post number inserted'] + submit: ['alt+s', 'Submit post'] + nextReply: ['J', 'Select next reply'] + previousReply: ['K', 'Select previous reply'] + nextThread: ['n', 'See next thread'] + previousThread: ['p', 'See previous thread'] + nextPage: ['L', 'Jump to the next page'] + previousPage: ['H', 'Jump to the previous page'] + zero: ['0', 'Jump to page 0'] + openThreadTab: ['o', 'Open thread in current tab'] + openThread: ['O', 'Open thread in new tab'] + expandThread: ['e', 'Expand thread'] + watch: ['w', 'Watch thread'] + hide: ['x', 'Hide thread'] + expandImages: ['m', 'Expand selected image'] + expandAllImages: ['M', 'Expand all images'] + update: ['u', 'Update now'] + unreadCountTo0: ['z', 'Reset unread count to 0'] updater: checkbox: - 'Scrolling': [false, 'Scroll updated posts into view. Only enabled at bottom of page.'] - 'Scroll BG': [false, 'Scroll background tabs'] - 'Verbose': [true, 'Show countdown timer, new post count'] - 'Auto Update': [true, 'Automatically fetch new posts'] + 'Scrolling': [false, 'Scroll updated posts into view. Only enabled at bottom of page.'] + 'Scroll BG': [false, 'Scroll background tabs'] + 'Verbose': [true, 'Show countdown timer, new post count'] + 'Auto Update': [true, 'Automatically fetch new posts'] 'Interval': 30 # XXX Chrome can't into {log} = console @@ -108,15 +108,14 @@ log = console.log.bind? console # flatten the config conf = {} (flatten = (parent, obj) -> - if obj.length #array - if typeof obj[0] is 'boolean' + if typeof obj is 'object' + # array + if obj.length conf[parent] = obj[0] - else - conf[parent] = obj - else if typeof obj is 'object' - for key, val of obj + # object + else for key, val of obj flatten key, val - else #constant + else # string or number conf[parent] = obj ) null, config @@ -1577,30 +1576,9 @@ options =
Keybinds are disabled.
+
Allowed keys: Ctrl, Alt, a-z, A-Z, 0-1, Up, Down, Right, Left.
- - - - - - - - - - - - - - - - - - - - - -
ActionsKeybinds
Open Options
Close Options or QR
Quick spoiler
Open QR with post number inserted
Open QR without post number inserted
Submit post
Select next reply
Select previous reply
See next thread
See previous thread
Jump to the next page
Jump to the previous page
Jump to page 0
Open thread in current tab
Open thread in new tab
Expand thread
Watch thread
Hide thread
Expand selected image
Expand all images
Update now
Reset the unread count to 0
' @@ -1643,10 +1621,13 @@ options = $.on favicon, 'change', options.favicon #keybinds - for input in $$ '#keybinds_tab + div input', dialog - input.type = 'text' - input.value = conf[input.name] + for key, arr of config.hotkeys + tr = $.el 'tr', + innerHTML: "#{arr[1]}" + input = $ 'input', tr + input.value = conf[key] $.on input, 'keydown', options.keybind + $.add $('#keybinds_tab + div tbody', dialog), tr #indicate if the settings require a feature to be enabled indicators = {} From bd542eb4b590623b50e8f743002ab12ba36781f1 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 5 Feb 2012 01:07:53 +0100 Subject: [PATCH 16/18] Increase Sauce linking possibilites. --- 4chan_x.user.js | 74 +++++++++++++++++++++++++++++-------------------- changelog | 3 ++ script.coffee | 70 +++++++++++++++++++++++++++++----------------- 3 files changed, 91 insertions(+), 56 deletions(-) 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.
\ +
    These variables will be replaced by the corresponding url:\ +
  • $1: Thumbnail.
  • \ +
  • $2: Full image.
  • \ +
\ + \
\ \
\ @@ -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 { From 60d071cb3919f41614c2bd4ef456a470f7de5147 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 5 Feb 2012 01:15:58 +0100 Subject: [PATCH 17/18] Add MD5 hashes to sauce linking. --- 4chan_x.user.js | 3 +++ changelog | 2 +- script.coffee | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index bf9032389..2e87b86a0 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1992,6 +1992,7 @@
    These variables will be replaced by the corresponding url:\
  • $1: Thumbnail.
  • \
  • $2: Full image.
  • \ +
  • $3: MD5 hash.
  • \
\ \
\ @@ -2604,6 +2605,8 @@ return img.src; case '$2': return img.parentNode.href; + case '$3': + return img.getAttribute('md5').replace(/\=+$/, ''); } }); } diff --git a/changelog b/changelog index c8aa80bbb..b08c04753 100644 --- a/changelog +++ b/changelog @@ -1,7 +1,7 @@ master - Mayhem Increase Sauce linking possibilites: - Thumbnails, full images. + Thumbnails, full images, MD5 hashes. 2.25.5 - Mayhem diff --git a/script.coffee b/script.coffee index fe6ceecff..490d44a46 100644 --- a/script.coffee +++ b/script.coffee @@ -1533,6 +1533,7 @@ options =
    These variables will be replaced by the corresponding url:
  • $1: Thumbnail.
  • $2: Full image.
  • +
  • $3: MD5 hash.
@@ -2054,6 +2055,8 @@ sauce = img.src when '$2' img.parentNode.href + when '$3' + img.getAttribute('md5').replace /\=+$/, '' revealSpoilers = init: -> From ea742de5d2a50439429b8ee42717689e1b401008 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 5 Feb 2012 01:33:26 +0100 Subject: [PATCH 18/18] Add 'View Same' MD5 flavor examples. Match the domain, not subdomain. --- 4chan_x.user.js | 6 +++--- script.coffee | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 2e87b86a0..58309cfd8 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -141,7 +141,7 @@ filesize: '', md5: '' }, - 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'), + 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://ompldr.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', favicon: 'ferongr', @@ -2579,7 +2579,7 @@ this.links = []; for (_i = 0, _len = links.length; _i < _len; _i++) { link = links[_i]; - this.links.push([link, link.match(/(\w+)\./)[1]]); + this.links.push([link, link.match(/(\w+)\.\w+\//)[1]]); } return g.callbacks.push(this.node); }, @@ -3837,7 +3837,7 @@ img[md5], img[md5] + img {\ width: 100%;\ }\ #sauces {\ - height: 350px;\ + height: 320px;\ }\ \ #updater {\ diff --git a/script.coffee b/script.coffee index 490d44a46..8994a342f 100644 --- a/script.coffee +++ b/script.coffee @@ -59,13 +59,17 @@ config = md5: '' sauces: [ 'http://iqdb.org/?url=$1' - 'http://google.com/searchbyimage?image_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://ompldr.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' @@ -2036,7 +2040,7 @@ sauce = links = conf['sauces'].match /^[^#].+$/gm @links = [] for link in links - @links.push [link, link.match(/(\w+)\./)[1]] + @links.push [link, link.match(/(\w+)\.\w+\//)[1]] g.callbacks.push @node node: (root) -> return if root.className is 'inline' or not span = $ '.filesize', root @@ -3082,7 +3086,7 @@ img[md5], img[md5] + img { width: 100%; } #sauces { - height: 350px; + height: 320px; } #updater {