puppeteer-extra-plugin-timezone
Version:
A puppeteer-extra plugin to automatically emulate the appropriate timezones using IP reflection services.
24 lines • 824 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTimezone = void 0;
const constants_1 = require("./constants");
const schemas_1 = require("./schemas");
/**
* Gets the timezone of a page from Luminati.
*
* @throws When timezone is not returned.
* @param {Page} page
* @return {Promise<string>}
*/
async function getTimezone(page) {
await page.goto(constants_1.IP_REFLECTION_URL);
const content = await page.evaluate(() => { var _a; return ((_a = document.querySelector("body")) === null || _a === void 0 ? void 0 : _a.textContent) || ""; });
const info = schemas_1.LumResponseSchema.parse(JSON.parse(content));
return {
ip: info.ip,
tz: info.geo.tz,
ctx: info
};
}
exports.getTimezone = getTimezone;
//# sourceMappingURL=provider.js.map