const { ProxyAgent } = require('undici');
const proxy = {
'host': 'xxx.xxx.xxx.xxx',
'port': 'xxx',
'username': 'xxx',
'password': '***',
};
const proxyAgent = new ProxyAgent({
uri: `http://${proxy.host}:${proxy.port}`,
token: `Basic ${Buffer.from(`${proxy.username}:${proxy.password}`).toString('base64')}`,
});
(async () => {
const data = await fetch('https://httpbin.org/get', { dispatcher: proxyAgent });
const json = await data.json();
await proxyAgent.close();
console.log(json);
})();
const fs = require('fs').promises
fs.readFile(file, 'utf-8')
const blocks = document.getElementsByClassName('block');
const stats = [];
for(block of blocks) {
const size = block.getElementsByClassName('item').length;
stats.push(size);
}
alert(stats);
const fetch = require('node-fetch');
let names = ['iliakan', 'remy', 'jeresig'];
let requests = names.map(name => fetch(`https://api.github.com/users/${name}`).then(response => response.json()));
(async () => {
const users = await Promise.all(requests);
users.forEach(user => {
console.log(user.name);
})
})();
let bbb = (function () {
start = function() {
console.log('222');
};
})();
start();
function bbb() {
function start() {
console.log('222');
}
return start;
}
const closure = bbb();
closure();
location ~* index\.html {
sub_filter '</body>' '<script src="..."></body>';
sub_filter_once on;
}