LowTechFilter/Surge/check_futadns.js
2022-07-04 10:53:55 +08:00

32 lines
805 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const { v4, v6 } = $network;
let errorMessage = {
title: 'FutaDNS',
content: '無已被設定的 FutaGuard DNS 伺服器',
icon: 'xmark.shield.fill',
'icon-color': '#FE6245',
};
const successMessage = {
title: 'FutaDNS',
content: '已指定的 FutaGuard DNS 伺服器\n正在正確地運作',
icon: 'checkmark.shield.fill',
'icon-color': '#1FCFB4',
};
if (!v4.primaryAddress && !v6.primaryAddress) {
errorMessage.content = '\n錯誤未連上網路';
$done(errorMessage);
} else {
$httpClient.get('https://check.futa.gg', function (error, response, data) {
if (error) {
errorMessage.content += '\n錯誤' + error;
$done(errorMessage);
}
if (data.includes('正在正確地運作')) {
$done(successMessage);
}
$done(errorMessage);
});
}