Skip to content

Instantly share code, notes, and snippets.

@mariolopjr
Last active November 3, 2015 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariolopjr/c93eab74fe417d7ead43 to your computer and use it in GitHub Desktop.
Save mariolopjr/c93eab74fe417d7ead43 to your computer and use it in GitHub Desktop.
Form Filler
//
// Form Filler
// Please remember to replace default values below with the actual username/password/db/etc.
// Based upon Chris Coyier's Implementation: https://css-tricks.com/prefilling-forms-custom-bookmarklet/
// Only supports Joomla! Installation form
// TODO: Figure a better way to have the script "wait" for Joomla! install
//
(function(win, doc, $) {
'use strict';
// Don't run script if jQuery isn't loaded
if (typeof win.jQuery === 'undefined') {
console.log("jQuery not loaded");
return;
}
// I like Chris's randomize function. Lets use it here.
var _rand = function(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
};
var FormFiller = {
// Create Data Object will required fields
FormData: function() {
sitename = 'test' + _rand(1,999);
username = 'admin';
password = 'pass';
email = 'admin@local';
databaseType = 'mysqli';
hostName = 'localhost';
dbUsername = 'root';
dbPassword = 'pass';
dbName = 'joomtests1';
dbPrefix = this.sitename + '_';
backup = 'remove';
};
// Fill Joomla! Install Form
ji: function() {
// Disable Joomla's annoying processing alert
window.alert = function() { };
var data = this.FormData();
$('#jform_site_name').val(data.sitename);
$('#jform_admin_email').val(data.email);
$('#jform_admin_user').val(data.username);
$('#jform_admin_password').val(data.password);
$('#jform_admin_password2').val(data.password);
Install.submitform();
var sleep1 = window.setTimeout(function() {
$('#jform_db_type').val(data.databaseType);
$('#jform_db_host').val(data.hostName);
$('#jform_db_user').val(data.dbUsername);
$('#jform_db_pass').val(data.dbPassword);
$('#jform_db_name').val(data.dbName);
$('#jform_db_prefix').val(data.dbPrefix);
$('#jform_db_old').val(data.backup);
Install.submitform();
}, 2000);
var sleep2 = window.setTimeout(function() {
Install.submitform();
}, 5000);
// TODO: delet folder, then click admin, then fill admin login to login
// Install.removeFolder(this);
};
// Joomla! Login To Administrator portal
jli: function() {
window.location.href=document.location.origin+'administrator';
};
}
}(window, window.document, window.jQuery));
javascript:(function(d) {
var body = d.getElementsByTagName('body')[0],
script = d.createElement('script');
script.src = 'https://gist.githubusercontent.com/mariolopjr/c93eab74fe417d7ead43/raw/_form-filler.js';
body.appendChild(script);
}(window.document));
javascript:(function(d){var body=d.getElementsByTagName('body')[0],script=d.createElement('script');script.src='https://gist.githubusercontent.com/mariolopjr/c93eab74fe417d7ead43/raw/_form-filler.js';body.appendChild(script);}(window.document));
// ==UserScript==
// @name Form Filler Functions
// @namespace com.iibits.enableFormFillerFunctions
// @description Using Greasemonkey, load Form Filler JS into any .local page!
// @include http://*.local/*
// @include https://*.local/*
// @version 1
// @grant none
// ==/UserScript==
(function(d) {
var body = d.getElementsByTagName('body')[0],
script = d.createElement('script');
script.src = 'https://gist.githubusercontent.com/mariolopjr/c93eab74fe417d7ead43/raw/_form-filler.js';
body.appendChild(script);
}(window.document));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment