From e314c00b53450a11e6ab8e7a172b51a3ae06701b Mon Sep 17 00:00:00 2001 From: Jordan Bates Date: Tue, 7 May 2013 20:58:36 -0700 Subject: [PATCH] Close #59 --- builds/4chan-X.js | 17 ++++++----------- builds/4chan-X.user.js | 17 ++++++----------- builds/crx/script.js | 17 ++++++----------- src/General/Main.coffee | 14 +++----------- 4 files changed, 21 insertions(+), 44 deletions(-) diff --git a/builds/4chan-X.js b/builds/4chan-X.js index 11f550007..156b4c26f 100644 --- a/builds/4chan-X.js +++ b/builds/4chan-X.js @@ -10161,27 +10161,22 @@ } }, checkUpdate: function() { - var freq, items, now; + var now; if (!(Conf['Check for Updates'] && Main.isThisPageLegit())) { return; } now = Date.now(); - freq = 6 * $.HOUR; - items = { - lastupdate: 0, - lastchecked: 0 - }; - return $.get(items, function(_arg) { - var lastchecked, lastupdate; + return $.get('lastchecked', 0, function(_arg) { + var lastchecked; - lastupdate = _arg.lastupdate, lastchecked = _arg.lastchecked; - if ((lastupdate > now - freq) || (lastchecked > now - $.DAY)) { + lastchecked = _arg.lastchecked; + if (lastchecked > now - $.DAY) { return; } return $.ready(function() { $.on(window, 'message', Main.message); - $.set('lastUpdate', now); + $.set('lastchecked', now); return $.add(d.head, $.el('script', { src: 'https://github.com/seaweedchan/4chan-x/raw/master/latest.js' })); diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 1c3322c20..f5a42e1c1 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -10184,27 +10184,22 @@ } }, checkUpdate: function() { - var freq, items, now; + var now; if (!(Conf['Check for Updates'] && Main.isThisPageLegit())) { return; } now = Date.now(); - freq = 7 * $.DAY; - items = { - lastupdate: 0, - lastchecked: 0 - }; - return $.get(items, function(_arg) { - var lastchecked, lastupdate; + return $.get('lastchecked', 0, function(_arg) { + var lastchecked; - lastupdate = _arg.lastupdate, lastchecked = _arg.lastchecked; - if ((lastupdate > now - freq) || (lastchecked > now - $.DAY)) { + lastchecked = _arg.lastchecked; + if (lastchecked > now - $.DAY) { return; } return $.ready(function() { $.on(window, 'message', Main.message); - $.set('lastUpdate', now); + $.set('lastchecked', now); return $.add(d.head, $.el('script', { src: 'https://github.com/seaweedchan/4chan-x/raw/master/latest.js' })); diff --git a/builds/crx/script.js b/builds/crx/script.js index 34fe64746..355f30b01 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -10166,27 +10166,22 @@ } }, checkUpdate: function() { - var freq, items, now; + var now; if (!(Conf['Check for Updates'] && Main.isThisPageLegit())) { return; } now = Date.now(); - freq = 7 * $.DAY; - items = { - lastupdate: 0, - lastchecked: 0 - }; - return $.get(items, function(_arg) { - var lastchecked, lastupdate; + return $.get('lastchecked', 0, function(_arg) { + var lastchecked; - lastupdate = _arg.lastupdate, lastchecked = _arg.lastchecked; - if ((lastupdate > now - freq) || (lastchecked > now - $.DAY)) { + lastchecked = _arg.lastchecked; + if (lastchecked > now - $.DAY) { return; } return $.ready(function() { $.on(window, 'message', Main.message); - $.set('lastUpdate', now); + $.set('lastchecked', now); return $.add(d.head, $.el('script', { src: 'https://github.com/seaweedchan/4chan-x/raw/master/latest.js' })); diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 975c8e115..e28d94179 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -297,21 +297,13 @@ Main = checkUpdate: -> 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() - freq = <% if (type === 'userjs') { %>6 * $.HOUR<% } else { %>7 * $.DAY<% } %> - items = - lastupdate: 0 - lastchecked: 0 - $.get items, ({lastupdate, lastchecked}) -> - if (lastupdate > now - freq) or (lastchecked > now - $.DAY) + $.get 'lastchecked', 0, ({lastchecked}) -> + if (lastchecked > now - $.DAY) return $.ready -> $.on window, 'message', Main.message - $.set 'lastUpdate', now + $.set 'lastchecked', now $.add d.head, $.el 'script', src: '<%= meta.repo %>raw/<%= meta.mainBranch %>/latest.js'