Nekrocuck
This commit is contained in:
52
static/js/autofill.js
Normal file
52
static/js/autofill.js
Normal file
@@ -0,0 +1,52 @@
|
||||
$(function () {
|
||||
let name = get_cookie("name");
|
||||
let password = get_cookie("password");
|
||||
let email = get_cookie("email");
|
||||
|
||||
if (password === "") {
|
||||
password = generate_password();
|
||||
set_cookie("password", password);
|
||||
}
|
||||
|
||||
$('input[name="post_name"]').attr("value", name);
|
||||
$('input[name="post_password"]').attr("value", password);
|
||||
$('input[name="email"]').attr("value", email);
|
||||
|
||||
function generate_password() {
|
||||
let chars =
|
||||
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
let password_length = 8;
|
||||
let password = "";
|
||||
|
||||
for (let i = 0; i <= password_length; i++) {
|
||||
let random_number = Math.floor(Math.random() * chars.length);
|
||||
password += chars.substring(random_number, random_number + 1);
|
||||
}
|
||||
|
||||
return password;
|
||||
}
|
||||
|
||||
function get_cookie(cname) {
|
||||
let name = cname + "=";
|
||||
let decodedCookie = decodeURIComponent(document.cookie);
|
||||
let ca = decodedCookie.split(";");
|
||||
|
||||
for (let i = 0; i < ca.length; i++) {
|
||||
let c = ca[i];
|
||||
|
||||
while (c.charAt(0) == " ") {
|
||||
c = c.substring(1);
|
||||
}
|
||||
|
||||
if (c.indexOf(name) == 0) {
|
||||
return c.substring(name.length, c.length);
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function set_cookie(cname, cvalue) {
|
||||
document.cookie = `${cname}=${cvalue};path=/`;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user