From cbba07c1e19f7e3fd55ffbf0be4d8f4294241396 Mon Sep 17 00:00:00 2001 From: IHateCaptcha Date: Fri, 14 Jun 2019 07:31:29 +0000 Subject: v1.0.8 GC --- addon_chrome/ismitmlink/bg.js | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'addon_chrome/ismitmlink/bg.js') diff --git a/addon_chrome/ismitmlink/bg.js b/addon_chrome/ismitmlink/bg.js index ce5525dd..5f585ff9 100644 --- a/addon_chrome/ismitmlink/bg.js +++ b/addon_chrome/ismitmlink/bg.js @@ -1,17 +1,15 @@ let apiurl = 'https://searxes.eu.org/collab/open/ismitm.php'; -let TORapiurl = 'http://searxes.nmqnkngye4ct7bgss4bmv5ca3wpa55yugvxen5kz2bbq67lwy6ps54yd.onion/collab/open/ismitm.php'; fetch('http://xxf4en4djo7hhvatax2g3lvj2qgvbwi4yeyyzwpo25zcog4ewhsbrdyd.onion/ok.php', { method: 'GET', mode: 'cors' }).then(r => r.text()).then(r => { if (r == 'ok') { - apiurl = TORapiurl; + apiurl = 'http://searxes.nmqnkngye4ct7bgss4bmv5ca3wpa55yugvxen5kz2bbq67lwy6ps54yd.onion/collab/open/ismitm.php'; } }).catch(() => {}); function is_infected(f) { - console.log(f); return new Promise((g, b) => { fetch(apiurl, { method: 'POST', @@ -49,20 +47,33 @@ function i_already_know_you(f) { }); } -function i_remember_you(f, t) { +function clear_cache_2w() { + chrome.storage.local.clear(); chrome.storage.local.set({ - [f]: ((t) ? 'y' : 'n') + 'lastU': Math.round((new Date()).getTime() / 1000) }); -} - -function clear_cache_week() { - chrome.storage.local.clear(); setTimeout(function () { - clear_cache(); - }, 604800000); + clear_cache_2w(); + }, 1209600000); } -clear_cache_week(); +chrome.storage.local.get('lastxU', (g) => { + if (g.lastU) { + if (Math.abs(Math.round((new Date()).getTime() / 1000) - g.lastU) > 1209600) { + chrome.storage.local.clear(); + chrome.storage.local.set({ + 'lastU': Math.round((new Date()).getTime() / 1000) + }); + } + } else { + chrome.storage.local.set({ + 'lastU': Math.round((new Date()).getTime() / 1000) + }); + } + setTimeout(function () { + clear_cache_2w(); + }, 1209600000); +}); chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { if (request) { @@ -72,7 +83,9 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { } if (r == 0) { is_infected(request).then((a) => { - i_remember_you(request, a); + chrome.storage.local.set({ + [request]: ((a) ? 'y' : 'n') + }); chrome.tabs.sendMessage(sender.tab.id, [request, a]); }, () => { chrome.tabs.sendMessage(sender.tab.id, [request, false]); -- cgit v1.2.3