Skip to content

Instantly share code, notes, and snippets.

@mihow
Created January 7, 2019 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mihow/1b16e5060951f2218d4cb1d58c780ef1 to your computer and use it in GitHub Desktop.
Save mihow/1b16e5060951f2218d4cb1d58c780ef1 to your computer and use it in GitHub Desktop.
Change watch settings in Github to release-only in bulk
// By jonashaag https://github.com/isaacs/github/issues/410#issuecomment-442248565
const child_process = require('child_process')
const puppeteer = require('puppeteer')
const devices = require('puppeteer/DeviceDescriptors')
const iPhone = devices['iPhone 6']
const USER = 'youruser'
const PW = 'xxxxxx'
// Get starred repos
let page = 1
let urls = []
while (1) {
const cmd = `curl -s "https://api.github.com/users/${USER}/starred?per_page=100&page=${page}"`
res = JSON.parse(child_process.execSync(cmd))
if (!res.length) break
for (let r in res) {
urls.push(r.html_url)
}
page++
}
// Update to release-only
(async () => {
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.emulate(iPhone)
await page.goto('https://github.com/login')
await page.type('[name=login]', USER)
await page.type('[name=password]', PW)
await page.click('[type=submit]')
setTimeout(async () => {
for (let url of urls) {
console.log(url)
await page.goto(url)
if (await page.$('[value=included].selected')) {
await page.click('[value=release_only]')
}
}
await browser.close()
}, 1000)
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment