diff options
author | anonymous <anonymous@gmail.com> | 2019-02-18 19:53:18 -0500 |
---|---|---|
committer | anonymous <anonymous@gmail.com> | 2019-02-18 19:53:18 -0500 |
commit | 4a7113db6b83cc7780674f005996d814002a25c2 (patch) | |
tree | ea448b43812e0ec8d96d60e429baa1940ad9b072 /ismitmlink/bg.js | |
parent | 10598f55061ebdfd32240f704b94a655a7055197 (diff) | |
download | cloudflare-tor-4a7113db6b83cc7780674f005996d814002a25c2.tar cloudflare-tor-4a7113db6b83cc7780674f005996d814002a25c2.tar.gz cloudflare-tor-4a7113db6b83cc7780674f005996d814002a25c2.tar.lz cloudflare-tor-4a7113db6b83cc7780674f005996d814002a25c2.tar.xz cloudflare-tor-4a7113db6b83cc7780674f005996d814002a25c2.zip |
ismitmlink
Diffstat (limited to 'ismitmlink/bg.js')
-rw-r--r-- | ismitmlink/bg.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/ismitmlink/bg.js b/ismitmlink/bg.js new file mode 100644 index 00000000..a3e3bfbe --- /dev/null +++ b/ismitmlink/bg.js @@ -0,0 +1,50 @@ +const apiurl = 'https://searxes.danwin1210.me/collab/open/ismitm.php'; +let mymemory = {}; + +function ismitm(f) { + return new Promise((g, b) => { + fetch(apiurl, { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + body: 'f=' + f + }).then(function (r) { + return r.json(); + }).then(function (r) { + if (r[0]) { + g(r[1]); + } else { + b(); + } + }).catch(b); + }); +} + +browser.runtime.onMessage.addListener((request, sender, sendResponse) => { + if (request && sender) { + if (mymemory[request] != undefined) { + let rlt = mymemory[request]; + if (Object.keys(mymemory).length > 800) { + let cnt = 1; + for (let t in mymemory) { + if (cnt > 10) { + break; + } + mymemory[t] = null; + delete mymemory[t]; + cnt++; + } + } + browser.tabs.sendMessage(sender.tab.id, [request, rlt]); + } else { + ismitm(request).then(function (a) { + mymemory[request] = a; + browser.tabs.sendMessage(sender.tab.id, [request, a]); + }, function () { + browser.tabs.sendMessage(sender.tab.id, [request, false]); + }); + } + } +});
\ No newline at end of file |