mirror of
https://0xacab.org/dCF/deCloudflare.git
synced 2025-01-28 01:59:13 -05:00
Implement build
This commit is contained in:
parent
291b292aa9
commit
1866547fd3
@ -1,6 +1,7 @@
|
||||
let timr, memcache = {},
|
||||
forcePurge = false,
|
||||
apiurl = 'https://karma.crimeflare.eu.org:1984/api/mypdns/cat/';
|
||||
apiHost = ['https://karma.crimeflare.eu.org:1984', 'http://karma.im5wixghmfmt7gf7wb4xrgdm6byx2gj26zn47da6nwo7xvybgxnqryid.onion'],
|
||||
apiBase = apiHost[0];
|
||||
function get_matrix_cat(domain) {
|
||||
if (memcache[domain]) {
|
||||
return new Promise((g, b) => {
|
||||
@ -13,7 +14,7 @@ function get_matrix_cat(domain) {
|
||||
memcache[domain] = c[domain];
|
||||
g(memcache[domain]);
|
||||
} else {
|
||||
fetch(apiurl, {
|
||||
fetch(apiBase + '/api/mypdns/cat/', {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
@ -44,7 +45,7 @@ function get_matrix_cat(domain) {
|
||||
}
|
||||
function forget_cache(x) {
|
||||
if (x) {
|
||||
browser.storage.local.get(['opt00', 'opt01', 'opt02', 'opt03', 'lastU', 'lastV']).then(g => {
|
||||
browser.storage.local.get(['opt00', 'opt01', 'opt02', 'opt03', 'opt04', 'lastU', 'lastV']).then(g => {
|
||||
browser.storage.local.clear();
|
||||
memcache = {};
|
||||
browser.storage.local.set({
|
||||
@ -59,6 +60,9 @@ function forget_cache(x) {
|
||||
browser.storage.local.set({
|
||||
'opt03': (g.opt03 == 'y' ? 'y' : 'n')
|
||||
});
|
||||
browser.storage.local.set({
|
||||
'opt04': (g.opt04 == 'y' ? 'y' : 'n')
|
||||
});
|
||||
browser.storage.local.set({
|
||||
'lastU': Math.round((new Date()).getTime() / 1000)
|
||||
});
|
||||
@ -72,12 +76,15 @@ function forget_cache(x) {
|
||||
forget_cache(true);
|
||||
}, 1814400000);
|
||||
}
|
||||
browser.storage.local.get(['lastU', 'lastV']).then(g => {
|
||||
browser.storage.local.get(['lastU', 'lastV', 'opt04']).then(g => {
|
||||
if (g.lastU == undefined || Math.abs(Math.round((new Date()).getTime() / 1000) - g.lastU) > 1814400 || g.lastV != (browser.runtime.getManifest()).version || forcePurge) {
|
||||
forget_cache(true);
|
||||
} else {
|
||||
forget_cache(false);
|
||||
}
|
||||
if (g.opt04 == 'y') {
|
||||
apiBase = apiHost[1];
|
||||
}
|
||||
});
|
||||
browser.runtime.onMessage.addListener((requests, sender, sendResponse) => {
|
||||
if (requests) {
|
||||
@ -85,6 +92,14 @@ browser.runtime.onMessage.addListener((requests, sender, sendResponse) => {
|
||||
forget_cache(true);
|
||||
return;
|
||||
}
|
||||
if (requests == 'abase-y') {
|
||||
apiBase = apiHost[1];
|
||||
return;
|
||||
}
|
||||
if (requests == 'abase-n') {
|
||||
apiBase = apiHost[0];
|
||||
return;
|
||||
}
|
||||
requests.forEach(request => {
|
||||
get_matrix_cat(request).then((r) => {
|
||||
browser.tabs.sendMessage(sender.tab.id, [request, r]);
|
||||
|
Loading…
Reference in New Issue
Block a user