mirror of
https://0xacab.org/dCF/deCloudflare.git
synced 2025-01-15 19:57:11 -05:00
Maybe event
This commit is contained in:
parent
8843fcd790
commit
072acce258
@ -1,5 +1,6 @@
|
|||||||
let timr, memcache = {},
|
let timr, memcache = {},
|
||||||
forcePurge = false,
|
forcePurge = false,
|
||||||
|
withCloudflare = false,
|
||||||
apiHost = ['https://karma.crimeflare.eu.org:1984', 'http://karma.im5wixghmfmt7gf7wb4xrgdm6byx2gj26zn47da6nwo7xvybgxnqryid.onion'],
|
apiHost = ['https://karma.crimeflare.eu.org:1984', 'http://karma.im5wixghmfmt7gf7wb4xrgdm6byx2gj26zn47da6nwo7xvybgxnqryid.onion'],
|
||||||
apiBase = apiHost[0];
|
apiBase = apiHost[0];
|
||||||
function get_matrix_cat(domain) {
|
function get_matrix_cat(domain) {
|
||||||
@ -20,7 +21,7 @@ function get_matrix_cat(domain) {
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
},
|
},
|
||||||
body: 'f=' + domain
|
body: (withCloudflare ? 'wcf=1&' : '') + 'f=' + domain
|
||||||
}).then(r => r.json()).then(r => {
|
}).then(r => r.json()).then(r => {
|
||||||
if (r && r.length == 2) {
|
if (r && r.length == 2) {
|
||||||
let m = {
|
let m = {
|
||||||
@ -45,7 +46,7 @@ function get_matrix_cat(domain) {
|
|||||||
}
|
}
|
||||||
function forget_cache(x) {
|
function forget_cache(x) {
|
||||||
if (x) {
|
if (x) {
|
||||||
browser.storage.local.get(['opt00', 'opt01', 'opt02', 'opt03', 'opt04', 'lastU', 'lastV']).then(g => {
|
browser.storage.local.get(['opt00', 'opt01', 'opt02', 'opt03', 'opt04', 'opt05', 'lastU', 'lastV']).then(g => {
|
||||||
browser.storage.local.clear();
|
browser.storage.local.clear();
|
||||||
memcache = {};
|
memcache = {};
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
@ -63,6 +64,9 @@ function forget_cache(x) {
|
|||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
'opt04': (g.opt04 == 'y' ? 'y' : 'n')
|
'opt04': (g.opt04 == 'y' ? 'y' : 'n')
|
||||||
});
|
});
|
||||||
|
browser.storage.local.set({
|
||||||
|
'opt05': (g.opt05 == 'y' ? 'y' : 'n')
|
||||||
|
});
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
'lastU': Math.round((new Date()).getTime() / 1000)
|
'lastU': Math.round((new Date()).getTime() / 1000)
|
||||||
});
|
});
|
||||||
@ -76,7 +80,7 @@ function forget_cache(x) {
|
|||||||
forget_cache(true);
|
forget_cache(true);
|
||||||
}, 1814400000);
|
}, 1814400000);
|
||||||
}
|
}
|
||||||
browser.storage.local.get(['lastU', 'lastV', 'opt04']).then(g => {
|
browser.storage.local.get(['lastU', 'lastV', 'opt04', 'opt05']).then(g => {
|
||||||
if (g.lastU == undefined || Math.abs(Math.round((new Date()).getTime() / 1000) - g.lastU) > 1814400 || g.lastV != (browser.runtime.getManifest()).version || forcePurge) {
|
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);
|
forget_cache(true);
|
||||||
} else {
|
} else {
|
||||||
@ -85,6 +89,9 @@ browser.storage.local.get(['lastU', 'lastV', 'opt04']).then(g => {
|
|||||||
if (g.opt04 == 'y') {
|
if (g.opt04 == 'y') {
|
||||||
apiBase = apiHost[1];
|
apiBase = apiHost[1];
|
||||||
}
|
}
|
||||||
|
if (g.opt05 == 'y') {
|
||||||
|
withCloudflare = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
browser.runtime.onMessage.addListener((requests, sender, sendResponse) => {
|
browser.runtime.onMessage.addListener((requests, sender, sendResponse) => {
|
||||||
if (requests) {
|
if (requests) {
|
||||||
@ -100,6 +107,14 @@ browser.runtime.onMessage.addListener((requests, sender, sendResponse) => {
|
|||||||
apiBase = apiHost[0];
|
apiBase = apiHost[0];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (requests == 'withcf-y') {
|
||||||
|
withCloudflare = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (requests == 'withcf-n') {
|
||||||
|
withCloudflare = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
requests.forEach(request => {
|
requests.forEach(request => {
|
||||||
get_matrix_cat(request).then((r) => {
|
get_matrix_cat(request).then((r) => {
|
||||||
browser.tabs.sendMessage(sender.tab.id, [request, r]);
|
browser.tabs.sendMessage(sender.tab.id, [request, r]);
|
||||||
|
Loading…
Reference in New Issue
Block a user