0
0
mirror of https://git.sdf.org/deCloudflare/cloudflare-tor synced 2024-12-27 14:12:25 +01:00

Upload files to 'addons/isattlinkFX'

This commit is contained in:
letssync 2020-07-31 01:12:51 +02:00
parent 1df9363a31
commit dfcc5984a4
3 changed files with 425 additions and 0 deletions

270
addons/isattlinkFX/bg.js Normal file
View File

@ -0,0 +1,270 @@
let localUse = false,
localDB = [],
timr, memcache = {},
forcePurge = false,
apiurl = 'http://api.wodferndripvpe6ib4uz4rtngrnzichnirgn7t5x64gxcyroopbhsuqd.onion/_/is_antitor.php';
/*
browser.storage.local.get(['cep']).then(g => {
if (g.cep == 'y') {
apiurl = 'http://api.wodferndripvpe6ib4uz4rtngrnzichnirgn7t5x64gxcyroopbhsuqd.onion/_/is_antitor.php';
} else {
if (g.cep != 'n') {
browser.storage.local.set({
'cep': 'n'
});
fetch('http://api.wodferndripvpe6ib4uz4rtngrnzichnirgn7t5x64gxcyroopbhsuqd.onion/_/ok.php', {
method: 'GET',
mode: 'cors'
}).then(r => r.text()).then(r => {
if (r == 'ok') {
apiurl = 'http://api.wodferndripvpe6ib4uz4rtngrnzichnirgn7t5x64gxcyroopbhsuqd.onion/_/is_antitor.php';
browser.storage.local.set({
'cep': 'y'
});
}
}).catch(() => {});
}
}
});
*/
function is_hostile(f) {
if (localUse) {
return new Promise((g, b) => {
g(localDB.includes(f) ? true : false);
});
}
return new Promise((g, b) => {
fetch(apiurl, {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: 'f=' + f
}).then(r => r.json()).then(r => {
if (r[0]) {
g(r[1]);
} else {
b();
}
}).catch(b);
});
}
function i_know_you(f) {
if (!/^([a-z0-9_.-]{1,255})\.([a-z]{2,80})$/.test(f)) {
return new Promise((g, b) => {
g(200);
});
}
let m;
if (memcache[f] != undefined) {
m = memcache[f];
return new Promise((g, b) => {
g(m);
});
}
return new Promise((g, b) => {
browser.storage.local.get([f]).then((ff) => {
if (ff[f]) {
if (ff[f] == 'y') {
memcache[f] = 1;
g(1);
} else {
memcache[f] = -1;
g(-1);
}
} else {
g(0);
}
}, () => {
g(0);
});
});
}
function forget_cache() {
browser.storage.local.get(['ign1', 'obs', 'dbg', 'alt', 'cep', 'mul', 'opd', 'ldb']).then(g => {
browser.storage.local.clear();
memcache = {};
browser.storage.local.set({
'ign1': (g.ign1 == 'y' ? 'y' : 'n')
});
browser.storage.local.set({
'obs': (g.obs == 'y' ? 'y' : 'n')
});
browser.storage.local.set({
'dbg': (g.dbg == 'y' ? 'y' : 'n')
});
browser.storage.local.set({
'alt': (g.alt == 'y' ? 'y' : 'n')
});
browser.storage.local.set({
'cep': (g.cep == 'y' ? 'y' : 'n')
});
browser.storage.local.set({
'mul': (g.mul != undefined ? g.mul : 'eo')
});
browser.storage.local.set({
'opd': (g.opd == 'n' ? 'n' : 'y')
});
browser.storage.local.set({
'ldb': (g.ldb != undefined ? g.ldb : '[]')
});
browser.storage.local.set({
'lastU': Math.round((new Date()).getTime() / 1000)
});
browser.storage.local.set({
'lastV': (browser.runtime.getManifest()).version
});
});
clearTimeout(timr);
timr = setTimeout(function () {
forget_cache();
}, 1814400000);
}
browser.storage.local.get(['lastU', 'lastV', 'ldb', 'opd']).then(g => {
localUse = (g.opd == 'n') ? true : false;
localDB = JSON.parse(g.ldb || '[]');
if (g.lastU) {
if (Math.abs(Math.round((new Date()).getTime() / 1000) - g.lastU) > 1814400) {
browser.storage.local.get(['ign1', 'obs', 'dbg', 'alt', 'cep', 'mul', 'opd', 'ldb']).then(g => {
browser.storage.local.clear();
memcache = {};
browser.storage.local.set({
'ign1': (g.ign1 == 'y' ? 'y' : 'n')
});
browser.storage.local.set({
'obs': (g.obs == 'y' ? 'y' : 'n')
});
browser.storage.local.set({
'dbg': (g.dbg == 'y' ? 'y' : 'n')
});
browser.storage.local.set({
'alt': (g.alt == 'y' ? 'y' : 'n')
});
browser.storage.local.set({
'cep': (g.cep == 'y' ? 'y' : 'n')
});
browser.storage.local.set({
'mul': (g.mul != undefined ? g.mul : 'eo')
});
browser.storage.local.set({
'opd': (g.opd == 'n' ? 'n' : 'y')
});
browser.storage.local.set({
'ldb': (g.ldb != undefined ? g.ldb : '[]')
});
browser.storage.local.set({
'lastU': Math.round((new Date()).getTime() / 1000)
});
});
}
} else {
browser.storage.local.set({
'lastU': Math.round((new Date()).getTime() / 1000)
});
}
let nowVer = (browser.runtime.getManifest()).version;
if (g.lastV != nowVer || forcePurge) {
console.log('Updated', nowVer);
browser.storage.local.get(['ign1', 'obs', 'dbg', 'alt', 'cep', 'mul', 'opd', 'ldb']).then(g => {
browser.storage.local.clear();
memcache = {};
browser.storage.local.set({
'ign1': (g.ign1 == 'y' ? 'y' : 'n')
});
browser.storage.local.set({
'obs': (g.obs == 'y' ? 'y' : 'n')
});
browser.storage.local.set({
'dbg': (g.dbg == 'y' ? 'y' : 'n')
});
browser.storage.local.set({
'alt': (g.alt == 'y' ? 'y' : 'n')
});
browser.storage.local.set({
'cep': (g.cep == 'y' ? 'y' : 'n')
});
browser.storage.local.set({
'mul': (g.mul != undefined ? g.mul : 'eo')
});
browser.storage.local.set({
'opd': (g.opd == 'n' ? 'n' : 'y')
});
browser.storage.local.set({
'ldb': (g.ldb != undefined ? g.ldb : '[]')
});
browser.storage.local.set({
'lastU': Math.round((new Date()).getTime() / 1000)
});
browser.storage.local.set({
'lastV': (browser.runtime.getManifest()).version
});
});
}
timr = setTimeout(function () {
forget_cache();
}, 1814400000);
});
browser.runtime.onMessage.addListener((requests, sender, sendResponse) => {
if (requests) {
if (requests === 'clear') {
forget_cache();
return;
}
if (requests.indexOf('dbmode,') === 0) {
switch (requests) {
case 'dbmode,s1':
browser.storage.local.set({
'opd': 'y'
});
localUse = false;
break;
case 'dbmode,s0':
browser.storage.local.set({
'opd': 'n'
});
localUse = true;
break;
case 'dbmode,cl':
browser.storage.local.set({
'ldb': '[]'
});
localDB = [];
break;
case 'dbmode,rl':
browser.storage.local.get(['ldb']).then(g => {
localDB = JSON.parse(g.ldb || '[]');
});
break;
}
return;
}
requests.forEach(request => {
i_know_you(request).then((r) => {
if (r == 1 || r == -1) {
browser.tabs.sendMessage(sender.tab.id, [request, ((r == 1) ? true : false)]);
}
if (r == 0) {
is_hostile(request).then((a) => {
if (a) {
browser.storage.local.set({
[request]: 'y'
});
} else {
browser.storage.local.set({
[request]: 'n'
});
}
if (Object.keys(memcache).length > 650) {
memcache = {};
}
browser.tabs.sendMessage(sender.tab.id, [request, a]);
}, () => {
browser.tabs.sendMessage(sender.tab.id, [request, false]);
});
}
}, () => {});
});
}
return;
});

View File

@ -0,0 +1,59 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
</head>
<body style="display:none">
&nbsp;<br>
<label><input type="checkbox" id="ign1"> <span tek="tlign1"></span></label><br>
<label><input type="checkbox" id="obs"> <span tek="tlobs"></span></label><br>
<label><input type="checkbox" id="alt"> <span tek="tlalt"></span></label><br>
<label><input type="checkbox" id="dbg"> <span tek="tldbg"></span></label><br>
<br>&nbsp;<br>
<span tek="opmode"></span><br>
<label><input type="radio" name="opm" id="opon"> <span tek="opmon"></span></label> [ &rarr; <a href="https://ss.wodferndripvpe6ib4uz4rtngrnzichnirgn7t5x64gxcyroopbhsuqd.onion/#!op=info/api" target="_blank">Ss API</a> ]<br>
<label><input type="radio" name="opm" id="opoff"> <span tek="opmoff"></span></label> [ &rarr; <a href="./localdb.html" target="_blank"><span tek="opmode"></span></a> ]<br>
<br>&nbsp;<br>
&#128172;
<select id="myul">
<option value="" selected> --- </option>
<option value="ar">العربية</option>
<option value="bn">বাংলা</option>
<option value="de">Deutsch</option>
<option value="eo">Esperanto &#127942;</option>
<option value="es">Español</option>
<option value="fa">فارسی</option>
<option value="fr">Français</option>
<option value="ha">Harshen</option>
<option value="hi">हिंदी</option>
<option value="id">Indonesia</option>
<option value="it">Italiano</option>
<option value="ja">日本語</option>
<option value="jv">ꦧꦱꦗꦮ</option>
<option value="ko">힌디어</option>
<option value="mr">मराठी</option>
<option value="ms">bahasa Melayu</option>
<option value="nl">Nederlands</option>
<option value="pt">Português</option>
<option value="ru">Русский</option>
<option value="sw">Kiswahili</option>
<option value="ta">தமிழ்</option>
<option value="th">ภาษาไทย</option>
<option value="tr">Türkçe</option>
<option value="ur">اردو</option>
<option value="vi">Tiếng Việt</option>
<option value="zh">中文</option>
</select>
<br>&nbsp;<br>&nbsp;<br>
<span tek="aboutcache"></span><br>
<span id="smsa"><button type="button" id="sms"> <span tek="statsshow"></span> </button></span>
<span id="smsb" style="display:none">
&nbsp;<br>
<span tek="hostile"></span>: <span id="viry">?</span><br>
<span tek="neutral"></span>: <span id="virn">?</span><br>
<span tek="total"></span>: <span id="viro">?</span><br>
&nbsp;<br>
<button type="button" id="crs"> <span tek="statsclear"></span> </button>
</span>
<br><br><script src="cg.js"></script>
</body>
</html>

96
addons/isattlinkFX/cg.js Normal file
View File

@ -0,0 +1,96 @@
document.addEventListener('DOMContentLoaded', () => {
browser.storage.local.get(['ign1', 'obs', 'dbg', 'alt', 'mul', 'opd']).then(g => {
document.getElementById('ign1').checked = (g.ign1 == 'y') ? true : false;
document.getElementById('obs').checked = (g.obs == 'y') ? true : false;
document.getElementById('dbg').checked = (g.dbg == 'y') ? true : false;
document.getElementById('alt').checked = (g.alt == 'y') ? true : false;
document.getElementById('opon').checked = (g.opd != 'n') ? true : false;
document.getElementById('opoff').checked = (g.opd == 'n') ? true : false;
let ul = g.mul || 'eo';
fetch('i18n/' + ul + '.json', {
method: 'GET'
}).then(j => j.json()).then(j => {
document.querySelectorAll('span[tek]').forEach(x => {
x.innerText = j[x.getAttribute('tek')];
});
document.body.style.display = 'block';
});
});
});
document.getElementById('myul').addEventListener('change', () => {
let xul = document.getElementById('myul').value;
if (xul.length == 2) {
browser.storage.local.set({
'mul': xul
});
location.reload(true);
}
});
document.getElementById('ign1').addEventListener('click', () => {
browser.storage.local.set({
'ign1': (document.getElementById('ign1').checked ? 'y' : 'n')
});
});
document.getElementById('obs').addEventListener('click', () => {
browser.storage.local.set({
'obs': (document.getElementById('obs').checked ? 'y' : 'n')
});
});
document.getElementById('dbg').addEventListener('click', () => {
browser.storage.local.set({
'dbg': (document.getElementById('dbg').checked ? 'y' : 'n')
});
});
document.getElementById('alt').addEventListener('click', () => {
browser.storage.local.set({
'alt': (document.getElementById('alt').checked ? 'y' : 'n')
});
});
document.getElementById('opon').addEventListener('click', () => {
browser.runtime.sendMessage('dbmode,s1').then(() => {
location.reload();
});
});
document.getElementById('opoff').addEventListener('click', () => {
browser.runtime.sendMessage('dbmode,s0').then(() => {
location.reload();
});
});
document.getElementById('crs').addEventListener('click', () => {
browser.runtime.sendMessage('clear').then(() => {
location.reload();
});
});
document.getElementById('sms').addEventListener('click', () => {
document.getElementById('smsa').style.display = 'none';
browser.storage.local.get().then(g => {
let iY = 0,
iN = 0,
iT, tmp, akd = [];
Object.keys(g).forEach(a => {
if (!['ign1', 'obs', 'dbg', 'alt', 'lastU', 'lastV', 'cep', 'mul', 'opd', 'ldb'].includes(a) && (g[a] == 'y' || g[a] == 'n')) {
if (!akd.includes(a)) {
akd.push(a);
if (g[a] == 'y') {
iY++;
} else {
iN++;
}
}
}
});
iT = iY + iN;
if (iT > 0) {
tmp = (iY * 100 / iT).toFixed(1);
document.getElementById('viry').innerText = iY + ' (' + tmp + '%)';
tmp = (iN * 100 / iT).toFixed(1);
document.getElementById('virn').innerText = iN + ' (' + tmp + '%)';
document.getElementById('viro').innerText = (iY + iN);
} else {
document.getElementById('viry').innerText = 0;
document.getElementById('virn').innerText = 0;
document.getElementById('viro').innerText = 0;
}
document.getElementById('smsb').style.display = 'inline';
});
});