Skip to content

Instantly share code, notes, and snippets.

@Makeshift
Created November 29, 2016 01:14
Show Gist options
  • Save Makeshift/34ed1df004b94b12d298b0c6e6830f79 to your computer and use it in GitHub Desktop.
Save Makeshift/34ed1df004b94b12d298b0c6e6830f79 to your computer and use it in GitHub Desktop.
Cycles through routerpasswords.com and puts all the data into persistent storage which can be grabbed later
// ==UserScript==
// @name RouterPassword Cycler
// @version 0.1
// @description Cycles through all of RouterPasswords.com's routers and sticks the info into persistent storage
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @author You
// @match http://routerpasswords.com/
// @grant none
// ==/UserScript==
//Note this will only work once. If you want it to work again, run this command in your Chrome dev console: localStorage.setItem("RPSetup", false);
//Also note: May create duplicates. I removed them afterwards.
(function() {
$(document).ready(function() {
if (!localStorage.getItem("RPSetup")) {
localStorage.setItem("RPNum", document.getElementsByClassName("form-control")[0].childNodes.length); //Sets number of routers we need to go through
localStorage.setItem("RPLoc", 1); //Sets how far we are
localStorage.setItem("RPData", `[{"manufacturer":"template","model":"template","protocol":"template","username":"template","password":"template"}]`); //Initiate storage
localStorage.setItem("RPSetup", true); //Skip setup next load
}
var table = document.getElementsByClassName("table"); //Grab data
if (table.length > 0) { //If table exists
console.log("Found table, adding");
table = table[0].rows;
for (var i = 1; i < table.length; i++) { //Run through table, skip headers
var temparray = JSON.parse(localStorage.getItem("RPData")); //Grab data from persistent storage
temparray.push({ //Add new data
manufacturer: table[i].cells[0].innerText,
model: table[i].cells[1].innerText,
protocol: table[i].cells[2].innerText,
username: table[i].cells[3].innerText,
password: table[i].cells[4].innerText
});
console.log("Array at size: " + temparray.length);
localStorage.setItem("RPData", JSON.stringify(temparray)); //Update persistent storage
}
}
setTimeout(function() {
//Go to next, update location
var curr = Number(localStorage.getItem("RPLoc"));
console.log(curr + " of " + localStorage.getItem("RPNum"));
document.getElementsByClassName("form-control")[0].childNodes[curr].selected = "true"; //Select next in list
localStorage.setItem("RPLoc", ++curr); //Update new location
setTimeout(function() {
if (curr <= Number(localStorage.getItem("RPNum"))) { //If we're not done yet (Shouldn't get here, should error out above)
document.getElementsByClassName("btn btn-primary btn-lg")[0].click(); //Click the next button
}
}, 100);
}, 200);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment