Advertisement
Guest User

createForm Function - DevMaxDE

a guest
Nov 13th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. function createForm(url, username, password, response) {
  2. if(!url || !username || !password) {
  3. console.error("URL, Nutzername und Passwort müssen angegeben sein!");
  4. return;
  5. }
  6. $.ajax({
  7. url: "",
  8. method: "POST",
  9. data: { url: url }
  10. }).done(function(data) {
  11. try {
  12. if(data.length > 0)
  13. for(form of $(data).find("form").get()) {
  14. var i = 0, mail = false, u, p;
  15. for(input of $(form).find("input").get()) {
  16. var type = input.getAttribute("type");
  17. if(type == undefined || !input.hasAttribute("name")) continue;
  18. if(type.includes("text") || type.includes("mail")) {
  19. if(mail) continue;
  20. mail = input.getAttribute("name").includes("mail");
  21. if(mail || u == undefined)
  22. u = input;
  23. } else if(type == "password")
  24. p = input;
  25. }
  26. if(u == undefined || p == undefined) continue;
  27. var newform = document.createElement("form"), user = document.createElement("input"), pass = document.createElement("input");
  28. newform.setAttribute("action", url); newform.setAttribute("method", "post");
  29. user.setAttribute("type", "hidden"); user.setAttribute("name", u.getAttribute("name")); user.setAttribute("value", username);
  30. pass.setAttribute("type", "hidden"); pass.setAttribute("name", p.getAttribute("name")); pass.setAttribute("value", password);
  31. newform.append(user, pass);
  32. if(response != undefined)
  33. response.call(newform, newform);
  34. return;
  35. }
  36. } catch(e) { }
  37. if(response != undefined)
  38. response.call();
  39. });
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement