This commit is contained in:
Jordan Bates 2013-05-07 20:58:36 -07:00
parent 015bc15641
commit e314c00b53
4 changed files with 21 additions and 44 deletions

View File

@ -10161,27 +10161,22 @@
} }
}, },
checkUpdate: function() { checkUpdate: function() {
var freq, items, now; var now;
if (!(Conf['Check for Updates'] && Main.isThisPageLegit())) { if (!(Conf['Check for Updates'] && Main.isThisPageLegit())) {
return; return;
} }
now = Date.now(); now = Date.now();
freq = 6 * $.HOUR; return $.get('lastchecked', 0, function(_arg) {
items = { var lastchecked;
lastupdate: 0,
lastchecked: 0
};
return $.get(items, function(_arg) {
var lastchecked, lastupdate;
lastupdate = _arg.lastupdate, lastchecked = _arg.lastchecked; lastchecked = _arg.lastchecked;
if ((lastupdate > now - freq) || (lastchecked > now - $.DAY)) { if (lastchecked > now - $.DAY) {
return; return;
} }
return $.ready(function() { return $.ready(function() {
$.on(window, 'message', Main.message); $.on(window, 'message', Main.message);
$.set('lastUpdate', now); $.set('lastchecked', now);
return $.add(d.head, $.el('script', { return $.add(d.head, $.el('script', {
src: 'https://github.com/seaweedchan/4chan-x/raw/master/latest.js' src: 'https://github.com/seaweedchan/4chan-x/raw/master/latest.js'
})); }));

View File

@ -10184,27 +10184,22 @@
} }
}, },
checkUpdate: function() { checkUpdate: function() {
var freq, items, now; var now;
if (!(Conf['Check for Updates'] && Main.isThisPageLegit())) { if (!(Conf['Check for Updates'] && Main.isThisPageLegit())) {
return; return;
} }
now = Date.now(); now = Date.now();
freq = 7 * $.DAY; return $.get('lastchecked', 0, function(_arg) {
items = { var lastchecked;
lastupdate: 0,
lastchecked: 0
};
return $.get(items, function(_arg) {
var lastchecked, lastupdate;
lastupdate = _arg.lastupdate, lastchecked = _arg.lastchecked; lastchecked = _arg.lastchecked;
if ((lastupdate > now - freq) || (lastchecked > now - $.DAY)) { if (lastchecked > now - $.DAY) {
return; return;
} }
return $.ready(function() { return $.ready(function() {
$.on(window, 'message', Main.message); $.on(window, 'message', Main.message);
$.set('lastUpdate', now); $.set('lastchecked', now);
return $.add(d.head, $.el('script', { return $.add(d.head, $.el('script', {
src: 'https://github.com/seaweedchan/4chan-x/raw/master/latest.js' src: 'https://github.com/seaweedchan/4chan-x/raw/master/latest.js'
})); }));

View File

@ -10166,27 +10166,22 @@
} }
}, },
checkUpdate: function() { checkUpdate: function() {
var freq, items, now; var now;
if (!(Conf['Check for Updates'] && Main.isThisPageLegit())) { if (!(Conf['Check for Updates'] && Main.isThisPageLegit())) {
return; return;
} }
now = Date.now(); now = Date.now();
freq = 7 * $.DAY; return $.get('lastchecked', 0, function(_arg) {
items = { var lastchecked;
lastupdate: 0,
lastchecked: 0
};
return $.get(items, function(_arg) {
var lastchecked, lastupdate;
lastupdate = _arg.lastupdate, lastchecked = _arg.lastchecked; lastchecked = _arg.lastchecked;
if ((lastupdate > now - freq) || (lastchecked > now - $.DAY)) { if (lastchecked > now - $.DAY) {
return; return;
} }
return $.ready(function() { return $.ready(function() {
$.on(window, 'message', Main.message); $.on(window, 'message', Main.message);
$.set('lastUpdate', now); $.set('lastchecked', now);
return $.add(d.head, $.el('script', { return $.add(d.head, $.el('script', {
src: 'https://github.com/seaweedchan/4chan-x/raw/master/latest.js' src: 'https://github.com/seaweedchan/4chan-x/raw/master/latest.js'
})); }));

View File

@ -297,21 +297,13 @@ Main =
checkUpdate: -> checkUpdate: ->
return unless Conf['Check for Updates'] and Main.isThisPageLegit() return unless Conf['Check for Updates'] and Main.isThisPageLegit()
# Check for updates after:
# - 6 hours since the last update on Opera because it lacks auto-updating.
# - 7 days since the last update on Chrome/Firefox.
# After that, check for updates every day if we still haven't updated.
now = Date.now() now = Date.now()
freq = <% if (type === 'userjs') { %>6 * $.HOUR<% } else { %>7 * $.DAY<% } %> $.get 'lastchecked', 0, ({lastchecked}) ->
items = if (lastchecked > now - $.DAY)
lastupdate: 0
lastchecked: 0
$.get items, ({lastupdate, lastchecked}) ->
if (lastupdate > now - freq) or (lastchecked > now - $.DAY)
return return
$.ready -> $.ready ->
$.on window, 'message', Main.message $.on window, 'message', Main.message
$.set 'lastUpdate', now $.set 'lastchecked', now
$.add d.head, $.el 'script', $.add d.head, $.el 'script',
src: '<%= meta.repo %>raw/<%= meta.mainBranch %>/latest.js' src: '<%= meta.repo %>raw/<%= meta.mainBranch %>/latest.js'