Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save noahlearner/c08e1bd3161b23804eb8618ee787e759 to your computer and use it in GitHub Desktop.
Save noahlearner/c08e1bd3161b23804eb8618ee787e759 to your computer and use it in GitHub Desktop.
const puppeteer = require('puppeteer-extra')
// add stealth plugin and use defaults (all evasion techniques)
const StealthPlugin = require('puppeteer-extra-plugin-stealth')
puppeteer.use(StealthPlugin())
// Add adblocker plugin to block all ads and trackers (saves bandwidth)
const AdblockerPlugin = require('puppeteer-extra-plugin-adblocker')
puppeteer.use(AdblockerPlugin({
blockTrackers: true
}))
const clients = require('./gscUser');
const URL = require('url');
const request = require('request');
// const moment = require('moment');
var argv = require('yargs')
.usage('Usage: $0 -startDate yyyy-mm-dd -days [num]')
.argv;
function delay(time) {
return new Promise(function(resolve) {
setTimeout(resolve, time)
});
}
try {
(async () => {
for (const client of clients) {
console.log(`\n- Client: ${client.name}`);
const domain = client.property;
const username = client.username;
const password = client.password;
const property = client.property;
const name = client.name;
const browser = await puppeteer.launch({
headless: false
});
const page = await browser.newPage();
puppeteer.use(require('puppeteer-extra-plugin-anonymize-ua')())
await page.setViewport({
width: 1500,
height: 1500,
deviceScaleFactor: 1,
});
await page.goto(`https://accounts.google.com/signin/v2/identifier?&hl=en-US&continue=https%3A%2F%2Fsearch.google.com%2Fsearch-console&flowName=GlifWebSignIn&flowEntry=ServiceLogin`);
await page.waitForSelector('input[type="email"]')
await page.click('input[type="email"]')
await page.keyboard.type(username);
await page.waitForSelector('#identifierNext')
await page.click('#identifierNext')
await page.waitFor(2000);
await page.waitForSelector('input[type="password"]', {
visible: true
})
await page.click('input[type="password"]')
await page.waitFor(500);
//TODO : change to your password
await page.keyboard.type(password);
await page.waitForSelector('#passwordNext')
await page.click('#passwordNext')
//await navigationPromise
//await page.waitForNavigation();
console.log("Logged in like a mofo");
await delay(3000);
await page.goto(`https://search.google.com/search-console?resource_id=${domain}`);
await delay(2000);
await page.waitForSelector('input[jsname=A51lKb]');
await page.click('input[jsname=A51lKb]');
const url = client.url;
await page.keyboard.type(url);
await delay(2000);
await page.click('input[jsname=A51lKb]');
page.keyboard.press('Enter');
await page.waitForNavigation();
await delay(4000);
// cTsG4
await page.waitForSelector('span.cTsG4');
await delay(2000);
await page.click('span.cTsG4');
await delay(4000);
// span[text()="Request indexing"]
}
})()
} catch (err) {
console.error(err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment