Auto noko, auto watch, and cooldown cookie-free.
This commit is contained in:
parent
a458b3fb6d
commit
990dd25c50
@ -1165,8 +1165,8 @@
|
|||||||
};
|
};
|
||||||
cooldown = {
|
cooldown = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var input, time, _, _ref;
|
var form, input, time, _, _ref;
|
||||||
if (location.search) {
|
if (/cooldown/.test(location.search)) {
|
||||||
_ref = location.search.match(/cooldown=(\d+)/), _ = _ref[0], time = _ref[1];
|
_ref = location.search.match(/cooldown=(\d+)/), _ = _ref[0], time = _ref[1];
|
||||||
if ($.getValue(g.BOARD + '/cooldown', 0) < time) {
|
if ($.getValue(g.BOARD + '/cooldown', 0) < time) {
|
||||||
$.setValue(g.BOARD + '/cooldown', time);
|
$.setValue(g.BOARD + '/cooldown', time);
|
||||||
@ -1180,17 +1180,25 @@
|
|||||||
return cooldown.start();
|
return cooldown.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
input = $('.postarea input[name=email]');
|
if (g.REPLY) {
|
||||||
if (/sage/i.test(input.value)) {
|
form = $('.postarea form');
|
||||||
$('.postarea form').action += "?sage";
|
form.action += '?cooldown';
|
||||||
|
input = $('.postarea input[name=email]');
|
||||||
|
if (/sage/i.test(input.value)) {
|
||||||
|
form.action += '?sage';
|
||||||
|
}
|
||||||
|
return $.bind(input, 'keyup', cooldown.sage);
|
||||||
}
|
}
|
||||||
return $.bind(input, 'keyup', cooldown.sage);
|
|
||||||
},
|
},
|
||||||
sage: function() {
|
sage: function() {
|
||||||
|
var form;
|
||||||
|
form = $('.postarea form');
|
||||||
if (/sage/i.test(this.value)) {
|
if (/sage/i.test(this.value)) {
|
||||||
return $('.postarea form').action = "http://sys.4chan.org/" + g.BOARD + "/post?sage";
|
if (!/sage/.test(form.action)) {
|
||||||
|
return form.action += '?sage';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return $('.postarea form').action = "http://sys.4chan.org/" + g.BOARD + "/post";
|
return form.action = form.action.replace('?sage', '');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
@ -1385,7 +1393,7 @@
|
|||||||
return qr.autohide.set();
|
return qr.autohide.set();
|
||||||
},
|
},
|
||||||
sys: function() {
|
sys: function() {
|
||||||
var c, duration, id, noko, otoNoko, otoWatch, recaptcha, thread, _, _ref;
|
var c, duration, id, noko, 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;
|
||||||
@ -1405,17 +1413,14 @@
|
|||||||
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];
|
||||||
otoNoko = new RegExp("" + NAMESPACE + "auto_noko=true");
|
noko = /auto_noko/.test(location.search);
|
||||||
otoWatch = new RegExp("" + NAMESPACE + "auto_watch=true");
|
|
||||||
cooldown = new RegExp("" + NAMESPACE + "cooldown=true");
|
|
||||||
noko = otoNoko.test(d.cookie);
|
|
||||||
if (thread === '0') {
|
if (thread === '0') {
|
||||||
if (otoWatch.test(d.cookie)) {
|
if (/auto_watch/.test(location.search)) {
|
||||||
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 (noko) {
|
} 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 (cooldown.test(d.cookie)) {
|
} else if (/cooldown/.test(location.search)) {
|
||||||
duration = Date.now() + 30000;
|
duration = Date.now() + 30000;
|
||||||
if (/sage/.test(location.search)) {
|
if (/sage/.test(location.search)) {
|
||||||
duration += 30000;
|
duration += 30000;
|
||||||
@ -2723,15 +2728,10 @@
|
|||||||
$.bind(form, 'submit', qr.cb.submit);
|
$.bind(form, 'submit', qr.cb.submit);
|
||||||
}
|
}
|
||||||
if ($.config('Auto Noko')) {
|
if ($.config('Auto Noko')) {
|
||||||
d.cookie = "" + NAMESPACE + "auto_noko=true;path=/;domain=.4chan.org";
|
$('.postarea form').action += '?auto_noko';
|
||||||
} else {
|
|
||||||
d.cookie = "" + NAMESPACE + "auto_noko=false;path=/;domain=.4chan.org";
|
|
||||||
}
|
}
|
||||||
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();
|
||||||
@ -2782,14 +2782,6 @@
|
|||||||
keybinds.init();
|
keybinds.init();
|
||||||
}
|
}
|
||||||
threading.init();
|
threading.init();
|
||||||
if ($.config('Auto Watch') && $.config('Thread Watcher')) {
|
|
||||||
d.cookie = "" + NAMESPACE + "auto_watch=true;path=/;domain=.4chan.org";
|
|
||||||
if (g.REPLY && location.hash === '#watch' && $('img.favicon').src === Favicon.empty) {
|
|
||||||
watcher.watch(null, g.THREAD_ID);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
d.cookie = "" + NAMESPACE + "auto_watch=false;path=/;domain=.4chan.org";
|
|
||||||
}
|
|
||||||
if (g.REPLY) {
|
if (g.REPLY) {
|
||||||
if ($.config('Thread Updater')) {
|
if ($.config('Thread Updater')) {
|
||||||
updater.init();
|
updater.init();
|
||||||
@ -2812,6 +2804,9 @@
|
|||||||
if ($.config('Reply Navigation')) {
|
if ($.config('Reply Navigation')) {
|
||||||
nav.init();
|
nav.init();
|
||||||
}
|
}
|
||||||
|
if ($.config('Auto Watch') && $.config('Thread Watcher') && location.hash === '#watch' && $('img.favicon').src === Favicon.empty) {
|
||||||
|
watcher.watch(null, g.THREAD_ID);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($.config('Index Navigation')) {
|
if ($.config('Index Navigation')) {
|
||||||
nav.init();
|
nav.init();
|
||||||
@ -2825,6 +2820,9 @@
|
|||||||
if ($.config('Comment Expansion')) {
|
if ($.config('Comment Expansion')) {
|
||||||
expandComment.init();
|
expandComment.init();
|
||||||
}
|
}
|
||||||
|
if ($.config('Auto Watch')) {
|
||||||
|
$('.postarea form').action += '?auto_watch';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ref3 = $$('div.op');
|
_ref3 = $$('div.op');
|
||||||
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
|
||||||
|
|||||||
@ -926,22 +926,27 @@ options =
|
|||||||
|
|
||||||
cooldown =
|
cooldown =
|
||||||
init: ->
|
init: ->
|
||||||
if location.search
|
if /cooldown/.test location.search
|
||||||
[_, time] = location.search.match /cooldown=(\d+)/
|
[_, time] = location.search.match /cooldown=(\d+)/
|
||||||
$.setValue g.BOARD+'/cooldown', time if $.getValue(g.BOARD+'/cooldown', 0) < time
|
$.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 g.REPLY
|
||||||
if /sage/i.test input.value
|
form = $('.postarea form')
|
||||||
$('.postarea form').action += "?sage"
|
form.action += '?cooldown'
|
||||||
$.bind input, 'keyup', cooldown.sage
|
input = $('.postarea input[name=email]')
|
||||||
|
if /sage/i.test input.value
|
||||||
|
form.action += '?sage'
|
||||||
|
$.bind input, 'keyup', cooldown.sage
|
||||||
|
|
||||||
sage: ->
|
sage: ->
|
||||||
|
form = $('.postarea form')
|
||||||
if /sage/i.test @value
|
if /sage/i.test @value
|
||||||
$('.postarea form').action = "http://sys.4chan.org/#{g.BOARD}/post?sage"
|
unless /sage/.test form.action
|
||||||
|
form.action += '?sage'
|
||||||
else
|
else
|
||||||
$('.postarea form').action = "http://sys.4chan.org/#{g.BOARD}/post"
|
form.action = form.action.replace '?sage', ''
|
||||||
|
|
||||||
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
|
||||||
@ -1141,16 +1146,14 @@ 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+)/)
|
||||||
otoNoko = new RegExp "#{NAMESPACE}auto_noko=true"
|
|
||||||
otoWatch = new RegExp "#{NAMESPACE}auto_watch=true"
|
noko = /auto_noko/.test location.search
|
||||||
cooldown = new RegExp "#{NAMESPACE}cooldown=true"
|
|
||||||
noko = otoNoko.test d.cookie
|
|
||||||
if thread is '0'
|
if thread is '0'
|
||||||
if otoWatch.test d.cookie
|
if /auto_watch/.test location.search
|
||||||
window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}#watch"
|
window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}#watch"
|
||||||
else if noko
|
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 cooldown.test d.cookie
|
else if /cooldown/.test location.search
|
||||||
duration = Date.now() + 30000
|
duration = Date.now() + 30000
|
||||||
duration += 30000 if /sage/.test location.search
|
duration += 30000 if /sage/.test location.search
|
||||||
if noko
|
if noko
|
||||||
@ -2127,15 +2130,10 @@ main =
|
|||||||
|
|
||||||
#major features
|
#major features
|
||||||
if $.config 'Auto Noko'
|
if $.config 'Auto Noko'
|
||||||
d.cookie = "#{NAMESPACE}auto_noko=true;path=/;domain=.4chan.org"
|
$('.postarea form').action += '?auto_noko'
|
||||||
else
|
|
||||||
d.cookie = "#{NAMESPACE}auto_noko=false;path=/;domain=.4chan.org"
|
|
||||||
|
|
||||||
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()
|
||||||
@ -2187,13 +2185,6 @@ main =
|
|||||||
|
|
||||||
threading.init()
|
threading.init()
|
||||||
|
|
||||||
if $.config('Auto Watch') and $.config('Thread Watcher')
|
|
||||||
d.cookie = "#{NAMESPACE}auto_watch=true;path=/;domain=.4chan.org"
|
|
||||||
if g.REPLY and location.hash is '#watch' and $('img.favicon').src is Favicon.empty
|
|
||||||
watcher.watch null, g.THREAD_ID
|
|
||||||
else
|
|
||||||
d.cookie = "#{NAMESPACE}auto_watch=false;path=/;domain=.4chan.org"
|
|
||||||
|
|
||||||
if g.REPLY
|
if g.REPLY
|
||||||
if $.config 'Thread Updater'
|
if $.config 'Thread Updater'
|
||||||
updater.init()
|
updater.init()
|
||||||
@ -2216,6 +2207,10 @@ main =
|
|||||||
if $.config 'Reply Navigation'
|
if $.config 'Reply Navigation'
|
||||||
nav.init()
|
nav.init()
|
||||||
|
|
||||||
|
if $.config('Auto Watch') and $.config('Thread Watcher') and
|
||||||
|
location.hash is '#watch' and $('img.favicon').src is Favicon.empty
|
||||||
|
watcher.watch null, g.THREAD_ID
|
||||||
|
|
||||||
else #not reply
|
else #not reply
|
||||||
if $.config 'Index Navigation'
|
if $.config 'Index Navigation'
|
||||||
nav.init()
|
nav.init()
|
||||||
@ -2229,6 +2224,9 @@ main =
|
|||||||
if $.config 'Comment Expansion'
|
if $.config 'Comment Expansion'
|
||||||
expandComment.init()
|
expandComment.init()
|
||||||
|
|
||||||
|
if $.config('Auto Watch')
|
||||||
|
$('.postarea form').action += '?auto_watch'
|
||||||
|
|
||||||
for op in $$ 'div.op'
|
for op in $$ 'div.op'
|
||||||
for callback in g.callbacks
|
for callback in g.callbacks
|
||||||
callback op
|
callback op
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user