anticaptcha.getBalance(async function(err, balance) {
// ...
const API_URL = 'https://api.vk.com/captcha.php?sid=405226711931&s=1';
const body = await image2base64(API_URL).catch((error) => console.log(error));
if (balance > 0) {
anticaptcha.createImageToTextTask({
case: true, // or params can be set for every captcha specially
body
},
// ...
}
});
String.prototype.toUpperCase = function() {
let symbols = {};
function add(a, b) {
symbols[String.fromCharCode(a)] = String.fromCharCode(b);
}
function addRange(start, end, offset) {
for (let i = start; i <= end; ++i) {
add(i + offset, i);
}
}
addRange(65, 90, 32);
addRange(1040, 1071, 32);
add(1105, 1025);
let result = '';
for (let i = 0, l = this.length; i < l; ++i) {
result += symbols[this[i]] || this[i];
}
return result;
};
let str = 'съешь ещё этих мягких французских булок, да выпей чаю';
console.log(str.toUpperCase());
function a(data) {
b().then(() => {
send(data);
});
}
async function a(data) {
await b();
send(data);
}
let phones = ['111-11-11', '555-55-55', '999-99-99'];
$('.phone').on('input', function() {
for (let i = 0, l = phones.length; i < l; ++i) {
if ($(this).val() === phones[i]) {
$(this).val('');
break;
}
}
});
var InventoryCalculate = await this.getCalculateInventory(Offer, details);
regex[1].replace(/<(.+?)>/g, (s, r) => {
return r === 'br' ? s : '<' + r + '>';
});
if (a == null && b == null) {
function ActiveXObject() {
// ...
return Object.assign(() => {
// ...
}, this);
}
Object.entries(data.reduce((acc, curr) => {
for (let key in curr) {
acc[key] = acc[key] || {values: [curr[key]], count: 0};
if (acc[key].values.includes(curr[key])) {
acc[key].count++;
} else {
acc[key].values.push(curr[key]);
}
}
return acc;
}, {})).reduce((acc, [key, {count}]) => ((acc[key] = count), acc), {});
data.reduce((acc, curr) => {
for (let key in curr) {
let item = acc.find((item) => item.key === key);
if (!item) {
item = {key, values: [curr[key]], count: 0};
acc.push(item);
}
if (item.values.includes(curr[key])) {
item.count++;
} else {
item.values.push(curr[key]);
}
}
return acc;
}, []).reduce((acc, {key, count}) => ((acc[key] = count), acc), {});
let phrases = ['банан', 'яблоко', 'апельсин', 'киви'];
phrases[Math.floor(Math.random() * phrases.length)]; // рандомный элемент
function Validator(criterias) {
let items = criterias.map((item) => ({enabled: true, ...item}));
this.toggleValidate = function(name, state) {
let item = items.find((item) => item.name === name);
if (item) {
item.enabled = typeof state === 'undefined' ? !item.enabled : state;
}
}
this.validate = function(value) {
let valid = true;
let errors = new Map();
items.forEach((item) => {
if (item.enabled && !item.check(value)) {
valid = false;
errors.set(item.name, item.message(value));
}
});
return {valid, errors};
}
}