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: { filter: {
name: [''].join('\n'), name: ['# Filter any namefags:', '#/^(?!Anonymous$)/'].join('\n'),
tripcode: [''].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'), 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'), 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'), comment: ['# Filter Stallman copypasta on /g/:', '#/what you\'re refer+ing to as linux/i;boards:g'].join('\n'),
filename: [''].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'), filesize: [''].join('\n'),
md5: [''].join('\n') md5: [''].join('\n')
}, },
@ -536,7 +536,7 @@
filter = { filter = {
filters: {}, filters: {},
init: function() { 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) { for (key in config.filter) {
this.filters[key] = []; this.filters[key] = [];
_ref = conf[key].split('\n'); _ref = conf[key].split('\n');
@ -555,30 +555,34 @@
alert(e.message); alert(e.message);
continue; 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)) { if (hl = /highlight/.test(filter)) {
hl = ((_ref4 = filter.match(/highlight:(\w+)/)) != null ? _ref4[1].toLowerCase() : void 0) || 'filter_highlight'; 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 (!this.filters[key].length) delete this.filters[key];
} }
if (Object.keys(this.filters).length) return g.callbacks.push(this.node); 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) { return function(root, value, isOP) {
var firstThread, thisThread; var firstThread, thisThread;
if (isOP && op === 'no' || !isOP && op === 'only') return false; if (isOP && op === 'no' || !isOP && op === 'only') return false;
if (!regexp.test(value)) return false; if (!regexp.test(value)) return false;
if (hl) { if (hl) {
$.addClass(root, hl); $.addClass(root, hl);
if (isOP && !g.REPLY) { if (isOP && top && !g.REPLY) {
thisThread = root.parentNode; thisThread = root.parentNode;
if (firstThread = $('div[class=op]')) { if (firstThread = $('div[class=op]')) {
$.before(firstThread.parentNode, [thisThread, thisThread.nextElementSibling]); $.before(firstThread.parentNode, [thisThread, thisThread.nextElementSibling]);
} }
} }
} else if (isOP) { return false;
}
if (isOP) {
if (!g.REPLY) threadHiding.hideHide(root.parentNode); if (!g.REPLY) threadHiding.hideHide(root.parentNode);
} else { } else {
replyHiding.hideHide(root.previousSibling); replyHiding.hideHide(root.previousSibling);
@ -2130,7 +2134,8 @@
<ul>You can use these settings with each regular expression, separate them with semicolons:\ <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>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>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>\ </ul>\
<p>Name:<br><textarea name=name></textarea></p>\ <p>Name:<br><textarea name=name></textarea></p>\
<p>Tripcode:<br><textarea name=tripcode></textarea></p>\ <p>Tripcode:<br><textarea name=tripcode></textarea></p>\
@ -3488,8 +3493,8 @@
var rect, thumb; var rect, thumb;
thumb = a.firstChild; thumb = a.firstChild;
if (thumb.hidden) { if (thumb.hidden) {
rect = a.parentNode.getBoundingClientRect(); rect = a.getBoundingClientRect();
if (rect.top < 0) d.body.scrollTop += rect.top; if (rect.top < 0) d.body.scrollTop += rect.top - 42;
if (rect.left < 0) d.body.scrollLeft += rect.left; if (rect.left < 0) d.body.scrollLeft += rect.left;
return imgExpand.contract(thumb); return imgExpand.contract(thumb);
} else { } else {

View File

@ -3,11 +3,13 @@ master
expand images from current position expand images from current position
- ahodesuka - ahodesuka
Add Open Reply in New Tab option for replies made from the main board (not dumping). 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 - Mayhem
The Filter now has per filter settings: The Filter now has per filter settings:
- Filter the OP only along its thread, replies only, or both. - Filter the OP only along its thread, replies only, or both.
- Per boards, or global. - 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. New filter group: Image dimensions.
Fix posting on Safari. Fix posting on Safari.
Fix rare case where the QR would not accept certain image types. 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'] 'Check for Updates': [true, 'Check for updated versions of 4chan X']
Filtering: Filtering:
'Anonymize': [false, 'Make everybody anonymous'] 'Anonymize': [false, 'Make everybody anonymous']
'Filter': [true, 'Self-moderation placebo'] 'Filter': [true, 'Self-moderation placebo']
'Recursive Filtering': [true, 'Filter replies of filtered posts, recursively'] 'Recursive Filtering': [true, 'Filter replies of filtered posts, recursively']
'Reply Hiding': [true, 'Hide single replies'] 'Reply Hiding': [true, 'Hide single replies']
'Thread Hiding': [true, 'Hide entire threads'] 'Thread Hiding': [true, 'Hide entire threads']
'Show Stubs': [true, 'Of hidden threads / replies'] 'Show Stubs': [true, 'Of hidden threads / replies']
@ -55,10 +55,12 @@ config =
'Forward Hiding': [true, 'Hide original posts of inlined backlinks'] 'Forward Hiding': [true, 'Hide original posts of inlined backlinks']
filter: filter:
name: [ name: [
'' '# Filter any namefags:'
'#/^(?!Anonymous$)/'
].join '\n' ].join '\n'
tripcode: [ tripcode: [
'' '# Filter any tripfags'
'#/^!/'
].join '\n' ].join '\n'
email: [ email: [
'# Filter any e-mails that are not `sage` on /a/ and /jp/:' '# Filter any e-mails that are not `sage` on /a/ and /jp/:'
@ -77,7 +79,7 @@ config =
].join '\n' ].join '\n'
dimensions: [ dimensions: [
'# Highlight potential wallpapers:' '# Highlight potential wallpapers:'
'#/1920x1080/;op:yes;highlight;boards:w,wg' '#/1920x1080/;op:yes;highlight;top:no;boards:w,wg'
].join '\n' ].join '\n'
filesize: [ filesize: [
'' ''
@ -462,15 +464,19 @@ filter =
# Filter OPs along with their threads, replies only, or both. # Filter OPs along with their threads, replies only, or both.
# Defaults to replies only. # 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. # Highlight the post, or hide it.
# If not specified, the highlight class will be filter_highlight. # If not specified, the highlight class will be filter_highlight.
# Defaults to post hiding. # Defaults to post hiding.
if hl = /highlight/.test filter 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. # Only execute filter types that contain valid filters.
unless @filters[key].length unless @filters[key].length
@ -479,7 +485,7 @@ filter =
if Object.keys(@filters).length if Object.keys(@filters).length
g.callbacks.push @node g.callbacks.push @node
createFilter: (regexp, op, hl) -> createFilter: (regexp, op, hl, top) ->
(root, value, isOP) -> (root, value, isOP) ->
if isOP and op is 'no' or !isOP and op is 'only' if isOP and op is 'no' or !isOP and op is 'only'
return false return false
@ -487,13 +493,15 @@ filter =
return false return false
if hl if hl
$.addClass root, 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... # Put the highlighted OPs' threads on top of the board pages...
thisThread = root.parentNode thisThread = root.parentNode
# ...before the first non highlighted thread. # ...before the first non highlighted thread.
if firstThread = $ 'div[class=op]' if firstThread = $ 'div[class=op]'
$.before firstThread.parentNode, [thisThread, thisThread.nextElementSibling] $.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 unless g.REPLY
threadHiding.hideHide root.parentNode threadHiding.hideHide root.parentNode
else else
@ -1722,7 +1730,8 @@ options =
<ul>You can use these settings with each regular expression, separate them with semicolons: <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>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>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> </ul>
<p>Name:<br><textarea name=name></textarea></p> <p>Name:<br><textarea name=name></textarea></p>
<p>Tripcode:<br><textarea name=tripcode></textarea></p> <p>Tripcode:<br><textarea name=tripcode></textarea></p>
@ -2802,8 +2811,8 @@ imgExpand =
toggle: (a) -> toggle: (a) ->
thumb = a.firstChild thumb = a.firstChild
if thumb.hidden if thumb.hidden
rect = a.parentNode.getBoundingClientRect() rect = a.getBoundingClientRect()
d.body.scrollTop += rect.top if rect.top < 0 d.body.scrollTop += rect.top - 42 if rect.top < 0
d.body.scrollLeft += rect.left if rect.left < 0 d.body.scrollLeft += rect.left if rect.left < 0
imgExpand.contract thumb imgExpand.contract thumb
else else