Cooldown with the normal post form. close #149
This commit is contained in:
parent
1c9a0a6412
commit
e6dc2f5a58
@ -1144,14 +1144,33 @@
|
|||||||
};
|
};
|
||||||
cooldown = {
|
cooldown = {
|
||||||
init: function() {
|
init: function() {
|
||||||
|
var input, time, _, _ref;
|
||||||
|
if (location.search) {
|
||||||
|
_ref = location.search.match(/cooldown=(\d+)/), _ = _ref[0], time = _ref[1];
|
||||||
|
if ($.getValue(g.BOARD + '/cooldown', 0 < time)) {
|
||||||
|
$.setValue(g.BOARD + '/cooldown', time);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (Date.now() < $.getValue(g.BOARD + '/cooldown', 0)) {
|
if (Date.now() < $.getValue(g.BOARD + '/cooldown', 0)) {
|
||||||
cooldown.start();
|
cooldown.start();
|
||||||
}
|
}
|
||||||
return $.bind(window, 'storage', function(e) {
|
$.bind(window, 'storage', function(e) {
|
||||||
if (e.key === ("" + NAMESPACE + g.BOARD + "/cooldown")) {
|
if (e.key === ("" + NAMESPACE + g.BOARD + "/cooldown")) {
|
||||||
return cooldown.start();
|
return cooldown.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
input = $('.postarea input[name=email]');
|
||||||
|
if (/sage/i.test(input.value)) {
|
||||||
|
$('.postarea form').action = "http://sys.4chan.org/" + g.BOARD + "/post?sage";
|
||||||
|
}
|
||||||
|
return $.bind(input, 'keyup', cooldown.sage);
|
||||||
|
},
|
||||||
|
sage: function() {
|
||||||
|
if (/sage/i.test(this.value)) {
|
||||||
|
return $('.postarea form').action = "http://sys.4chan.org/" + g.BOARD + "/post?sage";
|
||||||
|
} else {
|
||||||
|
return $('.postarea form').action = "http://sys.4chan.org/" + g.BOARD + "/post";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
var submit, _i, _len, _ref;
|
var submit, _i, _len, _ref;
|
||||||
@ -1345,7 +1364,7 @@
|
|||||||
return qr.autohide.set();
|
return qr.autohide.set();
|
||||||
},
|
},
|
||||||
sys: function() {
|
sys: function() {
|
||||||
var c, id, otoNoko, otoNokoPattern, otoWatchPattern, recaptcha, thread, _, _ref;
|
var c, duration, id, noko, otoNoko, otoWatch, recaptcha, thread, _, _ref;
|
||||||
if (recaptcha = $('#recaptcha_response_field')) {
|
if (recaptcha = $('#recaptcha_response_field')) {
|
||||||
$.bind(recaptcha, 'keydown', Recaptcha.listener);
|
$.bind(recaptcha, 'keydown', Recaptcha.listener);
|
||||||
return;
|
return;
|
||||||
@ -1365,17 +1384,30 @@
|
|||||||
c = $('b').lastChild;
|
c = $('b').lastChild;
|
||||||
if (c.nodeType === 8) {
|
if (c.nodeType === 8) {
|
||||||
_ref = c.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref[0], thread = _ref[1], id = _ref[2];
|
_ref = c.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref[0], thread = _ref[1], id = _ref[2];
|
||||||
otoNokoPattern = new RegExp("" + NAMESPACE + "auto_noko=true");
|
otoNoko = new RegExp("" + NAMESPACE + "auto_noko=true");
|
||||||
otoWatchPattern = new RegExp("" + NAMESPACE + "auto_watch=true");
|
otoWatch = new RegExp("" + NAMESPACE + "auto_watch=true");
|
||||||
otoNoko = otoNokoPattern.test(d.cookie);
|
cooldown = new RegExp("" + NAMESPACE + "cooldown=true");
|
||||||
|
noko = otoNoko.test(d.cookie);
|
||||||
if (thread === '0') {
|
if (thread === '0') {
|
||||||
if (otoWatchPattern.test(d.cookie)) {
|
if (otoWatch.test(d.cookie)) {
|
||||||
return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id + "#watch";
|
return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id + "#watch";
|
||||||
} else if (otoNoko) {
|
} else if (noko) {
|
||||||
return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id;
|
return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id;
|
||||||
}
|
}
|
||||||
} else if (otoNoko) {
|
} else if (cooldown.test(d.cookie)) {
|
||||||
|
duration = Date.now() + 30000;
|
||||||
|
if (/sage/.test(location.search)) {
|
||||||
|
duration += 30000;
|
||||||
|
}
|
||||||
|
if (noko) {
|
||||||
|
return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + thread + "?cooldown=" + duration + "#" + id;
|
||||||
|
} else {
|
||||||
|
return window.location = "http://boards.4chan.org/" + g.BOARD + "?cooldown=" + duration;
|
||||||
|
}
|
||||||
|
} else if (noko) {
|
||||||
return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + thread + "#" + id;
|
return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + thread + "#" + id;
|
||||||
|
} else {
|
||||||
|
return window.location = "http://boards.4chan.org/" + g.BOARD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2676,6 +2708,9 @@
|
|||||||
}
|
}
|
||||||
if ($.config('Cooldown')) {
|
if ($.config('Cooldown')) {
|
||||||
cooldown.init();
|
cooldown.init();
|
||||||
|
d.cookie = "" + NAMESPACE + "cooldown=true;path=/;domain=.4chan.org";
|
||||||
|
} else {
|
||||||
|
d.cookie = "" + NAMESPACE + "cooldown=false;path=/;domain=.4chan.org";
|
||||||
}
|
}
|
||||||
if ($.config('Image Expansion')) {
|
if ($.config('Image Expansion')) {
|
||||||
imgExpand.init();
|
imgExpand.init();
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
- optional auto noko
|
- optional auto noko
|
||||||
- fix options centering on Opera
|
- fix options centering on Opera
|
||||||
- fix append '#watch' only when auto watch is enabled
|
- fix append '#watch' only when auto watch is enabled
|
||||||
|
- fix cooldown with the normal post form
|
||||||
- aeosynth:
|
- aeosynth:
|
||||||
- keep options dialog at constant size
|
- keep options dialog at constant size
|
||||||
- drop firefox 3.6 support (again...)
|
- drop firefox 3.6 support (again...)
|
||||||
|
|||||||
@ -911,9 +911,23 @@ options =
|
|||||||
|
|
||||||
cooldown =
|
cooldown =
|
||||||
init: ->
|
init: ->
|
||||||
|
if location.search
|
||||||
|
[_, time] = location.search.match /cooldown=(\d+)/
|
||||||
|
$.setValue g.BOARD+'/cooldown', time if $.getValue g.BOARD+'/cooldown', 0 < time
|
||||||
cooldown.start() if Date.now() < $.getValue g.BOARD+'/cooldown', 0
|
cooldown.start() if Date.now() < $.getValue g.BOARD+'/cooldown', 0
|
||||||
$.bind window, 'storage', (e) -> cooldown.start() if e.key is "#{NAMESPACE}#{g.BOARD}/cooldown"
|
$.bind window, 'storage', (e) -> cooldown.start() if e.key is "#{NAMESPACE}#{g.BOARD}/cooldown"
|
||||||
|
|
||||||
|
input = $('.postarea input[name=email]')
|
||||||
|
if /sage/i.test input.value
|
||||||
|
$('.postarea form').action = "http://sys.4chan.org/#{g.BOARD}/post?sage"
|
||||||
|
$.bind input, 'keyup', cooldown.sage
|
||||||
|
|
||||||
|
sage: ->
|
||||||
|
if /sage/i.test @value
|
||||||
|
$('.postarea form').action = "http://sys.4chan.org/#{g.BOARD}/post?sage"
|
||||||
|
else
|
||||||
|
$('.postarea form').action = "http://sys.4chan.org/#{g.BOARD}/post"
|
||||||
|
|
||||||
start: ->
|
start: ->
|
||||||
cooldown.duration = Math.ceil ($.getValue(g.BOARD+'/cooldown', 0) - Date.now()) / 1000
|
cooldown.duration = Math.ceil ($.getValue(g.BOARD+'/cooldown', 0) - Date.now()) / 1000
|
||||||
for submit in $$ '#com_submit'
|
for submit in $$ '#com_submit'
|
||||||
@ -1112,16 +1126,26 @@ qr =
|
|||||||
c = $('b').lastChild
|
c = $('b').lastChild
|
||||||
if c.nodeType is 8 #comment node
|
if c.nodeType is 8 #comment node
|
||||||
[_, thread, id] = c.textContent.match(/thread:(\d+),no:(\d+)/)
|
[_, thread, id] = c.textContent.match(/thread:(\d+),no:(\d+)/)
|
||||||
otoNokoPattern = new RegExp "#{NAMESPACE}auto_noko=true"
|
otoNoko = new RegExp "#{NAMESPACE}auto_noko=true"
|
||||||
otoWatchPattern = new RegExp "#{NAMESPACE}auto_watch=true"
|
otoWatch = new RegExp "#{NAMESPACE}auto_watch=true"
|
||||||
otoNoko = otoNokoPattern.test d.cookie
|
cooldown = new RegExp "#{NAMESPACE}cooldown=true"
|
||||||
|
noko = otoNoko.test d.cookie
|
||||||
if thread is '0'
|
if thread is '0'
|
||||||
if otoWatchPattern.test d.cookie
|
if otoWatch.test d.cookie
|
||||||
window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}#watch"
|
window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}#watch"
|
||||||
else if otoNoko
|
else if noko
|
||||||
window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}"
|
window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}"
|
||||||
else if otoNoko
|
else if cooldown.test d.cookie
|
||||||
|
duration = Date.now() + 30000
|
||||||
|
duration += 30000 if /sage/.test location.search
|
||||||
|
if noko
|
||||||
|
window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{thread}?cooldown=#{duration}##{id}"
|
||||||
|
else
|
||||||
|
window.location = "http://boards.4chan.org/#{g.BOARD}?cooldown=#{duration}"
|
||||||
|
else if noko
|
||||||
window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{thread}##{id}"
|
window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{thread}##{id}"
|
||||||
|
else
|
||||||
|
window.location = "http://boards.4chan.org/#{g.BOARD}"
|
||||||
|
|
||||||
threading =
|
threading =
|
||||||
init: ->
|
init: ->
|
||||||
@ -2094,6 +2118,9 @@ main =
|
|||||||
|
|
||||||
if $.config 'Cooldown'
|
if $.config 'Cooldown'
|
||||||
cooldown.init()
|
cooldown.init()
|
||||||
|
d.cookie = "#{NAMESPACE}cooldown=true;path=/;domain=.4chan.org"
|
||||||
|
else
|
||||||
|
d.cookie = "#{NAMESPACE}cooldown=false;path=/;domain=.4chan.org"
|
||||||
|
|
||||||
if $.config 'Image Expansion'
|
if $.config 'Image Expansion'
|
||||||
imgExpand.init()
|
imgExpand.init()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user