Skip to content

Instantly share code, notes, and snippets.

@Fusselwurm
Last active December 21, 2015 03:08
Show Gist options
  • Save Fusselwurm/6239687 to your computer and use it in GitHub Desktop.
Save Fusselwurm/6239687 to your computer and use it in GitHub Desktop.
Deleting known hosts in my Fritz!Box 7170 is a PITA. One click per host plus the wait for page reload. This is a script to take the P from ITA :p (untested in this form. todo: wait for DOM structure instead of fixed timeout)
var
pattern = /^PC-192/,
deleteText = 'Löschen',
timeout = 3000;
(function moo() {
var found = Array.prototype.some.call(document.getElementsByTagName('frame')[0].contentDocument.querySelectorAll('button[value="' + deleteText + '"]'), function (e) {
var hostname = e.parentNode.parentNode.firstChild.nextSibling.textContent.trim();
if (hostname.match(pattern)) {
console.log('deleting ' + hostname + '...');
e.onclick();
return true;
}
});
if (found) {
setTimeout(moo, timeout);
} else {
console.log('no further hosts found.')
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment