diff --git a/4chan_x.user.js b/4chan_x.user.js
index bb8e48d38..35a910a13 100644
--- a/4chan_x.user.js
+++ b/4chan_x.user.js
@@ -102,7 +102,8 @@
'Image Expansion': [true, 'Expand images'],
'Image Hover': [false, 'Show full image on mouseover'],
'Sauce': [true, 'Add sauce to images'],
- 'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail']
+ 'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail'],
+ 'Expand From Current': [false, 'Expand images from current position to thread end.']
},
Monitoring: {
'Thread Updater': [true, 'Update threads. Has more options in its own dialog.'],
@@ -119,6 +120,7 @@
'Cooldown': [true, 'Prevent "flood detected" errors.'],
'Persistent QR': [false, 'The Quick reply won\'t disappear after posting.'],
'Auto Hide QR': [true, 'Automatically hide the quick reply when posting.'],
+ 'Open Reply in New Tab': [false, 'Open replies in a new tab that are made from the main board.'],
'Remember QR size': [false, 'Remember the size of the Quick reply (Firefox only).'],
'Remember Subject': [false, 'Remember the subject field, instead of resetting after posting.'],
'Remember Spoiler': [false, 'Remember the spoiler state, instead of resetting after posting.'],
@@ -136,15 +138,15 @@
}
},
filter: {
- name: '',
- tripcode: '',
- email: '',
- subject: '',
- comment: '',
- filename: '',
- dimensions: '',
- filesize: '',
- md5: ''
+ name: ['# Filter any namefags:', '#/^(?!Anonymous$)/'].join('\n'),
+ tripcode: ['# Filter any tripfags', '#/^!/'].join('\n'),
+ email: ['# Filter any e-mails that are not `sage` on /a/ and /jp/:', '#/^(?!sage$)/;boards:a,jp'].join('\n'),
+ subject: ['# Filter Generals on /v/:', '#/general/i;boards:v;op:only'].join('\n'),
+ comment: ['# Filter Stallman copypasta on /g/:', '#/what you\'re refer+ing to as linux/i;boards:g'].join('\n'),
+ filename: [''].join('\n'),
+ dimensions: ['# Highlight potential wallpapers:', '#/1920x1080/;op:yes;highlight;top:no;boards:w,wg'].join('\n'),
+ filesize: [''].join('\n'),
+ md5: [''].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://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',
@@ -171,7 +173,7 @@
expandThread: ['e', 'Expand thread'],
watch: ['w', 'Watch thread'],
hide: ['x', 'Hide thread'],
- expandImages: ['m', 'Expand selected image'],
+ expandImage: ['m', 'Expand selected image'],
expandAllImages: ['M', 'Expand all images'],
update: ['u', 'Update now'],
unreadCountTo0: ['z', 'Reset unread status']
@@ -537,7 +539,7 @@
filter = {
filters: {},
init: function() {
- var boards, filter, hl, key, op, regexp, _i, _len, _ref, _ref2, _ref3, _ref4;
+ var boards, filter, hl, key, op, regexp, top, _i, _len, _ref, _ref2, _ref3, _ref4, _ref5;
for (key in config.filter) {
this.filters[key] = [];
_ref = conf[key].split('\n');
@@ -556,23 +558,34 @@
alert(e.message);
continue;
}
- op = ((_ref3 = filter.match(/op:(yes|no|only)/)) != null ? _ref3[1].toLowerCase() : void 0) || 'no';
+ op = ((_ref3 = filter.match(/[^t]op:(yes|no|only)/)) != null ? _ref3[1].toLowerCase() : void 0) || 'no';
if (hl = /highlight/.test(filter)) {
hl = ((_ref4 = filter.match(/highlight:(\w+)/)) != null ? _ref4[1].toLowerCase() : void 0) || 'filter_highlight';
+ top = ((_ref5 = filter.match(/top:(yes|no)/)) != null ? _ref5[1].toLowerCase() : void 0) || 'yes';
+ top = top === 'yes';
}
- this.filters[key].push(this.createFilter(regexp, op, hl));
+ this.filters[key].push(this.createFilter(regexp, op, hl, top));
}
if (!this.filters[key].length) delete this.filters[key];
}
if (Object.keys(this.filters).length) return g.callbacks.push(this.node);
},
- createFilter: function(regexp, op, hl) {
+ createFilter: function(regexp, op, hl, top) {
return function(root, value, isOP) {
+ var firstThread, thisThread;
if (isOP && op === 'no' || !isOP && op === 'only') return false;
if (!regexp.test(value)) return false;
if (hl) {
$.addClass(root, hl);
- } else if (isOP) {
+ if (isOP && top && !g.REPLY) {
+ thisThread = root.parentNode;
+ if (firstThread = $('div[class=op]')) {
+ $.before(firstThread.parentNode, [thisThread, thisThread.nextElementSibling]);
+ }
+ }
+ return false;
+ }
+ if (isOP) {
if (!g.REPLY) threadHiding.hideHide(root.parentNode);
} else {
replyHiding.hideHide(root.previousSibling);
@@ -622,7 +635,7 @@
},
comment: function(root) {
return ($.el('a', {
- innerHTML: $('blockquote', root).innerHTML.replace(/ /g, '\n')
+ innerHTML: root.lastChild.innerHTML.replace(/ /g, '\n')
})).textContent;
},
filename: function(root) {
@@ -964,7 +977,7 @@
case conf.expandThread:
expandThread.toggle(thread);
break;
- case conf.expandImages:
+ case conf.expandImage:
keybinds.img(thread);
break;
case conf.nextThread:
@@ -1871,7 +1884,7 @@
return qr.message.send(post);
},
response: function(html) {
- var b, doc, err, node, persona, postNumber, reply, thread, _, _ref;
+ var b, doc, err, node, open, persona, postNumber, reply, thread, _, _ref;
doc = $.el('a', {
innerHTML: html
});
@@ -1919,6 +1932,10 @@
} else {
qr.cooldown.auto = qr.replies.length > 1;
qr.cooldown.set(/sage/i.test(reply.email) ? 60 : 30);
+ if (conf['Open Reply in New Tab'] && !g.REPLY && !qr.cooldown.auto) {
+ open = GM_openInTab || window.open;
+ open("http://boards.4chan.org/" + g.BOARD + "/res/" + thread + "#" + postNumber, "_blank");
+ }
}
if (conf['Persistent QR'] || qr.cooldown.auto) {
reply.rm();
@@ -2103,7 +2120,7 @@
\
\
Sauce is disabled.
\
-
Lines starting with a # will be ignored.
\
+ Lines starting with a # will be ignored.\
These variables will be replaced by the corresponding url:\
$1: Thumbnail.
\
$2: Full image.
\
@@ -2115,7 +2132,14 @@
\
Filter is disabled.
\
Use regular expressions, one per line. \
+ Lines starting with a # will be ignored. \
For example, /weeaboo/i will filter posts containing `weeaboo` case-insensitive.\
+
You can use these settings with each regular expression, separate them with semicolons:\
+
Per boards, separate them with commas. It is global if not specified. For example: boards:a,jp;.
\
+
Filter OPs only along with their threads (`only`), replies only (`no`, this is default), or both (`yes`). For example: op:only;, op:no; or op:yes;.
\
+
Highlight instead of hiding. You can specify a class name to use with a userstyle. For example: highlight; or highlight:wallpaper;.
\
+
Highlighted OPs will have their threads put on top of board pages by default. For example: top:yes or top:no.
\
+
\
Name:
\
Tripcode:
\
E-mail:
\
@@ -2728,9 +2752,10 @@
var link, _i, _len, _ref;
if (g.BOARD === 'f') return;
this.links = [];
- _ref = conf['sauces'].match(/^[^#].+$/gm);
+ _ref = conf['sauces'].split('\n');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
link = _ref[_i];
+ if (link[0] === '#') continue;
this.links.push(this.funk(link));
}
if (!this.links.length) return;
@@ -3560,18 +3585,25 @@
return imgExpand.toggle(this);
},
all: function() {
- var thumb, _i, _j, _len, _len2, _ref, _ref2;
+ var i, thumb, thumbs, _i, _j, _len, _len2, _len3, _ref;
imgExpand.on = this.checked;
if (imgExpand.on) {
- _ref = $$('img[md5]');
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- thumb = _ref[_i];
+ thumbs = $$('img[md5]');
+ if (conf['Expand From Current']) {
+ for (i = 0, _len = thumbs.length; i < _len; i++) {
+ thumb = thumbs[i];
+ if (thumb.getBoundingClientRect().top > 0) break;
+ }
+ thumbs = thumbs.slice(i);
+ }
+ for (_i = 0, _len2 = thumbs.length; _i < _len2; _i++) {
+ thumb = thumbs[_i];
imgExpand.expand(thumb);
}
} else {
- _ref2 = $$('img[md5][hidden]');
- for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
- thumb = _ref2[_j];
+ _ref = $$('img[md5][hidden]');
+ for (_j = 0, _len3 = _ref.length; _j < _len3; _j++) {
+ thumb = _ref[_j];
imgExpand.contract(thumb);
}
}
@@ -3605,8 +3637,8 @@
var rect, thumb;
thumb = a.firstChild;
if (thumb.hidden) {
- rect = a.parentNode.getBoundingClientRect();
- if (rect.top < 0) d.body.scrollTop += rect.top;
+ rect = a.getBoundingClientRect();
+ if (rect.top < 0) d.body.scrollTop += rect.top - 42;
if (rect.left < 0) d.body.scrollLeft += rect.left;
return imgExpand.contract(thumb);
} else {
@@ -4141,7 +4173,7 @@ img[md5], img[md5] + img {\
padding: 5px;\
text-align: left;\
vertical-align: middle;\
- width: 500px;\
+ width: 600px;\
}\
#credits {\
float: right;\
@@ -4206,6 +4238,10 @@ img[md5], img[md5] + img {\
#qp {\
padding-bottom: 5px;\
}\
+#qp > a > img {\
+ max-height: 300px;\
+ max-width: 500px;\
+}\
.qphl {\
outline: 2px solid rgba(216, 94, 49, .7);\
}\
diff --git a/script.coffee b/script.coffee
index bd685753d..1f20b1a6b 100644
--- a/script.coffee
+++ b/script.coffee
@@ -14,8 +14,8 @@ config =
'Check for Updates': [true, 'Check for updated versions of 4chan X']
Filtering:
'Anonymize': [false, 'Make everybody anonymous']
- 'Filter': [true, 'Self-moderation placebo']
- 'Recursive Filtering': [true, 'Filter replies of filtered posts, recursively']
+ 'Filter': [true, 'Self-moderation placebo']
+ 'Recursive Filtering': [true, 'Filter replies of filtered posts, recursively']
'Reply Hiding': [true, 'Hide single replies']
'Thread Hiding': [true, 'Hide entire threads']
'Show Stubs': [true, 'Of hidden threads / replies']
@@ -25,6 +25,7 @@ config =
'Image Hover': [false, 'Show full image on mouseover']
'Sauce': [true, 'Add sauce to images']
'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail']
+ 'Expand From Current': [false, 'Expand images from current position to thread end.']
Monitoring:
'Thread Updater': [true, 'Update threads. Has more options in its own dialog.']
'Unread Count': [true, 'Show unread post count in tab title']
@@ -39,6 +40,7 @@ config =
'Cooldown': [true, 'Prevent "flood detected" errors.']
'Persistent QR': [false, 'The Quick reply won\'t disappear after posting.']
'Auto Hide QR': [true, 'Automatically hide the quick reply when posting.']
+ 'Open Reply in New Tab': [false, 'Open replies in a new tab that are made from the main board.']
'Remember QR size': [false, 'Remember the size of the Quick reply (Firefox only).']
'Remember Subject': [false, 'Remember the subject field, instead of resetting after posting.']
'Remember Spoiler': [false, 'Remember the spoiler state, instead of resetting after posting.']
@@ -53,15 +55,39 @@ config =
'Indicate Cross-thread Quotes': [true, 'Add \'(Cross-thread)\' to cross-threads quotes']
'Forward Hiding': [true, 'Hide original posts of inlined backlinks']
filter:
- name: ''
- tripcode: ''
- email: ''
- subject: ''
- comment: ''
- filename: ''
- dimensions: ''
- filesize: ''
- md5: ''
+ name: [
+ '# Filter any namefags:'
+ '#/^(?!Anonymous$)/'
+ ].join '\n'
+ tripcode: [
+ '# Filter any tripfags'
+ '#/^!/'
+ ].join '\n'
+ email: [
+ '# Filter any e-mails that are not `sage` on /a/ and /jp/:'
+ '#/^(?!sage$)/;boards:a,jp'
+ ].join '\n'
+ subject: [
+ '# Filter Generals on /v/:'
+ '#/general/i;boards:v;op:only'
+ ].join '\n'
+ comment: [
+ '# Filter Stallman copypasta on /g/:'
+ '#/what you\'re refer+ing to as linux/i;boards:g'
+ ].join '\n'
+ filename: [
+ ''
+ ].join '\n'
+ dimensions: [
+ '# Highlight potential wallpapers:'
+ '#/1920x1080/;op:yes;highlight;top:no;boards:w,wg'
+ ].join '\n'
+ filesize: [
+ ''
+ ].join '\n'
+ md5: [
+ ''
+ ].join '\n'
sauces: [
'http://iqdb.org/?url=$1'
'http://www.google.com/searchbyimage?image_url=$1'
@@ -100,7 +126,7 @@ config =
expandThread: ['e', 'Expand thread']
watch: ['w', 'Watch thread']
hide: ['x', 'Hide thread']
- expandImages: ['m', 'Expand selected image']
+ expandImage: ['m', 'Expand selected image']
expandAllImages: ['M', 'Expand all images']
update: ['u', 'Update now']
unreadCountTo0: ['z', 'Reset unread status']
@@ -441,15 +467,19 @@ filter =
# Filter OPs along with their threads, replies only, or both.
# Defaults to replies only.
- op = filter.match(/op:(yes|no|only)/)?[1].toLowerCase() or 'no'
+ op = filter.match(/[^t]op:(yes|no|only)/)?[1].toLowerCase() or 'no'
# Highlight the post, or hide it.
# If not specified, the highlight class will be filter_highlight.
# Defaults to post hiding.
if hl = /highlight/.test filter
- hl = filter.match(/highlight:(\w+)/)?[1].toLowerCase() or 'filter_highlight'
+ hl = filter.match(/highlight:(\w+)/)?[1].toLowerCase() or 'filter_highlight'
+ # Put highlighted OP's thread on top of the board page or not.
+ # Defaults to on top.
+ top = filter.match(/top:(yes|no)/)?[1].toLowerCase() or 'yes'
+ top = top is 'yes' # Turn it into a boolean
- @filters[key].push @createFilter regexp, op, hl
+ @filters[key].push @createFilter regexp, op, hl, top
# Only execute filter types that contain valid filters.
unless @filters[key].length
@@ -458,7 +488,7 @@ filter =
if Object.keys(@filters).length
g.callbacks.push @node
- createFilter: (regexp, op, hl) ->
+ createFilter: (regexp, op, hl, top) ->
(root, value, isOP) ->
if isOP and op is 'no' or !isOP and op is 'only'
return false
@@ -466,7 +496,15 @@ filter =
return false
if hl
$.addClass root, hl
- else if isOP
+ if isOP and top and not g.REPLY
+ # Put the highlighted OPs' threads on top of the board pages...
+ thisThread = root.parentNode
+ # ...before the first non highlighted thread.
+ if firstThread = $ 'div[class=op]'
+ $.before firstThread.parentNode, [thisThread, thisThread.nextElementSibling]
+ # Continue the filter lookup to add more classes or hide it.
+ return false
+ if isOP
unless g.REPLY
threadHiding.hideHide root.parentNode
else
@@ -508,7 +546,7 @@ filter =
sub = if isOP then $ '.filetitle', root else $ '.replytitle', root
sub.textContent
comment: (root) ->
- ($.el 'a', innerHTML: $('blockquote', root).innerHTML.replace / /g, '\n').textContent
+ ($.el 'a', innerHTML: root.lastChild.innerHTML.replace / /g, '\n').textContent
filename: (root) ->
if file = $ '.filesize > span', root
return file.title
@@ -763,7 +801,7 @@ keybinds =
keybinds.open thread
when conf.expandThread
expandThread.toggle thread
- when conf.expandImages
+ when conf.expandImage
keybinds.img thread
when conf.nextThread
return if g.REPLY
@@ -1523,6 +1561,9 @@ qr =
# Enable auto-posting if we have stuff to post, disable it otherwise.
qr.cooldown.auto = qr.replies.length > 1
qr.cooldown.set if /sage/i.test reply.email then 60 else 30
+ if conf['Open Reply in New Tab'] && !g.REPLY && !qr.cooldown.auto
+ open = GM_openInTab or window.open
+ open "http://boards.4chan.org/#{g.BOARD}/res/#{thread}##{postNumber}", "_blank"
if conf['Persistent QR'] or qr.cooldown.auto
reply.rm()
@@ -1675,7 +1716,7 @@ options =
Sauce is disabled.
-
Lines starting with a # will be ignored.
+ Lines starting with a # will be ignored.
These variables will be replaced by the corresponding url:
$1: Thumbnail.
$2: Full image.
@@ -1687,7 +1728,14 @@ options =
Filter is disabled.
Use regular expressions, one per line.
+ Lines starting with a # will be ignored.
For example, /weeaboo/i will filter posts containing `weeaboo` case-insensitive.
+
You can use these settings with each regular expression, separate them with semicolons:
+
Per boards, separate them with commas. It is global if not specified. For example: boards:a,jp;.
+
Filter OPs only along with their threads (`only`), replies only (`no`, this is default), or both (`yes`). For example: op:only;, op:no; or op:yes;.
+
Highlight instead of hiding. You can specify a class name to use with a userstyle. For example: highlight; or highlight:wallpaper;.
+
Highlighted OPs will have their threads put on top of board pages by default. For example: top:yes or top:no.
+
Name:
Tripcode:
E-mail:
@@ -2216,7 +2264,8 @@ sauce =
init: ->
return if g.BOARD is 'f'
@links = []
- for link in conf['sauces'].match /^[^#].+$/gm
+ for link in conf['sauces'].split '\n'
+ continue if link[0] is '#'
@links.push @funk link
return unless @links.length
g.callbacks.push @node
@@ -2826,7 +2875,13 @@ imgExpand =
all: ->
imgExpand.on = @checked
if imgExpand.on #expand
- for thumb in $$ 'img[md5]'
+ thumbs = $$ 'img[md5]'
+ if conf['Expand From Current']
+ for thumb, i in thumbs
+ if thumb.getBoundingClientRect().top > 0
+ break
+ thumbs = thumbs[i...]
+ for thumb in thumbs
imgExpand.expand thumb
else #contract
for thumb in $$ 'img[md5][hidden]'
@@ -2854,8 +2909,8 @@ imgExpand =
toggle: (a) ->
thumb = a.firstChild
if thumb.hidden
- rect = a.parentNode.getBoundingClientRect()
- d.body.scrollTop += rect.top if rect.top < 0
+ rect = a.getBoundingClientRect()
+ d.body.scrollTop += rect.top - 42 if rect.top < 0
d.body.scrollLeft += rect.left if rect.left < 0
imgExpand.contract thumb
else
@@ -3404,7 +3459,7 @@ img[md5], img[md5] + img {
padding: 5px;
text-align: left;
vertical-align: middle;
- width: 500px;
+ width: 600px;
}
#credits {
float: right;
@@ -3469,6 +3524,10 @@ img[md5], img[md5] + img {
#qp {
padding-bottom: 5px;
}
+#qp > a > img {
+ max-height: 300px;
+ max-width: 500px;
+}
.qphl {
outline: 2px solid rgba(216, 94, 49, .7);
}