forked from borfast/arrispwgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bookmarklet.js
32 lines (26 loc) · 1.35 KB
/
bookmarklet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* This is the uncondensed version of the Javascript code used for the
* bookmarklet link, so it can have some comments.
*/
(function() {
// The fragment where we'll append the script tag, and which in turn will be appended to the <head> of our page.
var fragment = document.createDocumentFragment();
// The script element that loads the password generator script.
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://raw.github.com/borfast/arrispwgen/master/arrispwgen.js';
// Just a reference to the <head> element.
var head = document.getElementsByTagName('head')[0];
// Wait for the script file to load before trying to call the function.
var done = false;
script.onload = script.onreadystatechange = function() {
if( !done && ( !this.readyState || this.readyState === 'loaded' || this.readyState === 'complete') ) {
done = true;
var today = (new Date()).getTime();
window.prompt('Arris modem password for today is shown below. Use Ctrl+C to copy, Enter or Esc to dismiss.', ArrisPwGen(today)[today]);
}
};
// Add the prepared <script> element to the fragment, and add the fragment to the <head>.
fragment.appendChild(script);
head.appendChild(fragment);
})(); // Immediately execute the anonymous function.