Last active
December 16, 2023 22:59
-
-
Save deoxykev/1086bda32c1f293ba1a77ef603df6a2f to your computer and use it in GitHub Desktop.
Download all wireguard configs for ProtonVPN (paste in dev console for https://account.protonvpn.com/downloads)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let DELAY_MS = 60000 | |
function download(filename, text) { | |
var element = document.createElement('a'); | |
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); | |
element.setAttribute('download', filename); | |
element.style.display = 'none'; | |
document.body.appendChild(element); | |
element.click(); | |
document.body.removeChild(element); | |
} | |
function hasConfig(name) { | |
//if (dlConfigs.includes(name)) return true | |
let config = [...document.querySelectorAll("textarea")] | |
.filter(x => x.value.startsWith("[Interface]") && x.value.match(`# ${name}\n`) && x.value.includes("PrivateKey = *****")) | |
return (config.length != 0) | |
} | |
function shuffleArray(array) { | |
for (var i = array.length - 1; i > 0; i--) { | |
var j = Math.floor(Math.random() * (i + 1)); | |
var temp = array[i]; | |
array[i] = array[j]; | |
array[j] = temp; | |
} | |
} | |
(async () => { | |
let rows = [...document.querySelectorAll("div.p-4 > table.simple-table--has-actions > tbody > tr")] | |
.filter(r => r.querySelector("button").innerHTML == "Create") | |
.map(r => { | |
let cols = [...r.querySelectorAll("td")] | |
return { | |
name: cols[0].innerHTML, | |
city: cols[1].textContent, | |
btn: cols[3].querySelector("button"), | |
} | |
}) | |
shuffleArray(rows) | |
//.reverse() | |
for (row of rows) { | |
try { | |
await grabConfig(row) | |
} catch (e) { | |
console.log(`[-] failed to grab ${row.name} - ${row.city}`) | |
console.log(e) | |
} | |
} | |
})(); | |
async function grabConfig(row) { | |
if (hasConfig(row.name)) { | |
console.log(`[>] SKIPPING ${row.name} - ${row.city}`) | |
return | |
} | |
if (row.name.includes("-FREE#")) { | |
console.log(`[>] SKIPPING ${row.name} - ${row.city}`) | |
return | |
} | |
console.log(`[+] grabbing ${row.name} - ${row.city}`) | |
let config = "" | |
let filename = row.name.replaceAll("#", "-") | |
let cityname = row.city.replaceAll(" ", "-").trim() | |
filename = `wg-${filename}-${cityname}.conf` | |
document.getElementById("certificate-device-name").value = filename | |
row.btn.click() | |
while (true) { | |
config = [...document.querySelectorAll("textarea")] | |
.filter(x => x.value.startsWith("[Interface]") && x.value.match(`# ${row.name}\n`) && !x.value.includes("PrivateKey = *****") ) | |
if (config.length == 0) { | |
await new Promise(r => setTimeout(r, 1000)); | |
continue | |
} | |
config = config[0].value | |
if (config && config != "") break | |
} | |
let closeBtn = document.querySelector("div.modal-two > dialog > form > div.modal-two-header").querySelector("button") | |
closeBtn.click() | |
console.log(config) | |
config = `# ProtonVPN -> ${row.city}\n${config}` | |
download(filename, config) | |
await new Promise(r => setTimeout(r, DELAY_MS)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment