Merge branch 'master' of https://github.com/MayhemYDG/4chan-x into aho

This commit is contained in:
James Campos 2012-02-21 11:44:07 -08:00
commit 1490837d3d
3 changed files with 43 additions and 27 deletions

View File

@ -137,13 +137,13 @@
}
},
filter: {
name: [''].join('\n'),
tripcode: [''].join('\n'),
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;boards:w,wg'].join('\n'),
dimensions: ['# Highlight potential wallpapers:', '#/1920x1080/;op:yes;highlight;top:no;boards:w,wg'].join('\n'),
filesize: [''].join('\n'),
md5: [''].join('\n')
},
@ -536,7 +536,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');
@ -555,30 +555,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);
if (isOP && !g.REPLY) {
if (isOP && top && !g.REPLY) {
thisThread = root.parentNode;
if (firstThread = $('div[class=op]')) {
$.before(firstThread.parentNode, [thisThread, thisThread.nextElementSibling]);
}
}
} else if (isOP) {
return false;
}
if (isOP) {
if (!g.REPLY) threadHiding.hideHide(root.parentNode);
} else {
replyHiding.hideHide(root.previousSibling);
@ -2130,7 +2134,8 @@
<ul>You can use these settings with each regular expression, separate them with semicolons:\
<li>Per boards, separate them with commas. It is global if not specified.<br>For example: <code>boards:a,jp;</code>.</li>\
<li>Filter OPs only along with their threads (`only`), replies only (`no`, this is default), or both (`yes`).<br>For example: <code>op:only;</code>, <code>op:no;</code> or <code>op:yes;</code>.</li>\
<li>Highlight instead of hiding. Highlighted OPs will have their threads put on top of board pages. You can specify a class name to use with a userstyle.<br>For example: <code>highlight;</code> or <code>hightlight:wallpaper;</code>.</li>\
<li>Highlight instead of hiding. You can specify a class name to use with a userstyle.<br>For example: <code>highlight;</code> or <code>hightlight:wallpaper;</code>.</li>\
<li>Highlighted OPs will have their threads put on top of board pages by default.<br>For example: <code>top:yes</code> or <code>top:no</code>.</li>\
</ul>\
<p>Name:<br><textarea name=name></textarea></p>\
<p>Tripcode:<br><textarea name=tripcode></textarea></p>\
@ -3488,8 +3493,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 {

View File

@ -3,11 +3,13 @@ master
expand images from current position
- ahodesuka
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.
- Mayhem
The Filter now has per filter settings:
- Filter the OP only along its thread, replies only, or both.
- Per boards, or global.
- Highlight, or hide. Highlighted OPs will have their threads put on top of the board page.
- Highlight, or hide.
- Highlighted OPs will have their threads put on top of the board page by default.
New filter group: Image dimensions.
Fix posting on Safari.
Fix rare case where the QR would not accept certain image types.

View File

@ -13,8 +13,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']
@ -55,10 +55,12 @@ config =
'Forward Hiding': [true, 'Hide original posts of inlined backlinks']
filter:
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/:'
@ -77,7 +79,7 @@ config =
].join '\n'
dimensions: [
'# Highlight potential wallpapers:'
'#/1920x1080/;op:yes;highlight;boards:w,wg'
'#/1920x1080/;op:yes;highlight;top:no;boards:w,wg'
].join '\n'
filesize: [
''
@ -462,15 +464,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
@ -479,7 +485,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
@ -487,13 +493,15 @@ filter =
return false
if hl
$.addClass root, hl
if isOP and not g.REPLY
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]
else if isOP
# Continue the filter lookup to add more classes or hide it.
return false
if isOP
unless g.REPLY
threadHiding.hideHide root.parentNode
else
@ -1722,7 +1730,8 @@ options =
<ul>You can use these settings with each regular expression, separate them with semicolons:
<li>Per boards, separate them with commas. It is global if not specified.<br>For example: <code>boards:a,jp;</code>.</li>
<li>Filter OPs only along with their threads (`only`), replies only (`no`, this is default), or both (`yes`).<br>For example: <code>op:only;</code>, <code>op:no;</code> or <code>op:yes;</code>.</li>
<li>Highlight instead of hiding. Highlighted OPs will have their threads put on top of board pages. You can specify a class name to use with a userstyle.<br>For example: <code>highlight;</code> or <code>hightlight:wallpaper;</code>.</li>
<li>Highlight instead of hiding. You can specify a class name to use with a userstyle.<br>For example: <code>highlight;</code> or <code>hightlight:wallpaper;</code>.</li>
<li>Highlighted OPs will have their threads put on top of board pages by default.<br>For example: <code>top:yes</code> or <code>top:no</code>.</li>
</ul>
<p>Name:<br><textarea name=name></textarea></p>
<p>Tripcode:<br><textarea name=tripcode></textarea></p>
@ -2802,8 +2811,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