diff --git a/4chan_x.user.js b/4chan_x.user.js
index 47a47776f..b2b765be3 100644
--- a/4chan_x.user.js
+++ b/4chan_x.user.js
@@ -141,7 +141,7 @@
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')
},
@@ -534,7 +534,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');
@@ -553,31 +553,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]);
}
}
return false;
- } else if (isOP) {
+ }
+ if (isOP) {
if (!g.REPLY) threadHiding.hideHide(root.parentNode);
} else {
replyHiding.hideHide(root.previousSibling);
@@ -2125,7 +2128,8 @@
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. Highlighted OPs will have their threads put on top of board pages. You can specify a class name to use with a userstyle.
For example: highlight; or hightlight:wallpaper;. \
+ - Highlight instead of hiding. You can specify a class name to use with a userstyle.
For example: highlight; or hightlight:wallpaper;. \
+ - Highlighted OPs will have their threads put on top of board pages by default.
For example: top:yes or top:no. \
\
Name:
\
Tripcode:
\
diff --git a/script.coffee b/script.coffee
index ef0b5c4c6..a16d96d43 100644
--- a/script.coffee
+++ b/script.coffee
@@ -75,7 +75,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: [
''
@@ -460,15 +460,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
@@ -477,7 +481,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
@@ -485,7 +489,7 @@ 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.
@@ -493,7 +497,7 @@ filter =
$.before firstThread.parentNode, [thisThread, thisThread.nextElementSibling]
# Continue the filter lookup to add more classes or hide it.
return false
- else if isOP
+ if isOP
unless g.REPLY
threadHiding.hideHide root.parentNode
else
@@ -1719,7 +1723,8 @@ options =
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. Highlighted OPs will have their threads put on top of board pages. You can specify a class name to use with a userstyle.
For example: highlight; or hightlight:wallpaper;.
+ - Highlight instead of hiding. You can specify a class name to use with a userstyle.
For example: highlight; or hightlight:wallpaper;.
+ - Highlighted OPs will have their threads put on top of board pages by default.
For example: top:yes or top:no.
Name:
Tripcode: