Last active
October 18, 2021 12:25
-
-
Save DylanDelobel/72cd24e8f48a15e987d901eda83c85a3 to your computer and use it in GitHub Desktop.
AutoCreatorPatient.user.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name AutoCreatorPatient | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description try to take over the world! | |
// @author @DylanDelobel | |
// @match https://dev.alaxione.fr/point-vision/* | |
// @icon https://www.google.com/s2/favicons?domain=alaxione.fr | |
// @require https://cdnjs.cloudflare.com/ajax/libs/Faker/3.0.1/faker.min.js | |
// @require https://code.jquery.com/jquery-3.4.1.min.js | |
// @grant none | |
// @run-at document-idle | |
// ==/UserScript== | |
(function () { | |
window.addEventListener('change', function () { | |
setTimeout(function () { | |
console.log('loaded...'); | |
// Function to set Value to React Input | |
function setNativeValue(element, value) { | |
let lastValue = element.value; | |
element.value = value; | |
let event = new Event("input", {target: element, bubbles: true}); | |
// React 15 | |
event.simulated = true; | |
// React 16 | |
let tracker = element._valueTracker; | |
if (tracker) { | |
tracker.setValue(lastValue); | |
} | |
element.dispatchEvent(event); | |
} | |
// Faker options | |
faker.locale = 'fr'; | |
let btnGenerate = $("div:contains('Nouveau sur Point Vision ?')")[8]; | |
if (!$('#generateFaker').length) { | |
$(btnGenerate).append(`<div class="euiFormRow register-btn"><div class="euiFormRow__fieldWrapper"><button id="generateFaker" class="euiButton euiButton--primary button-custom btn-custom primary" type="button"><span class="euiButtonContent euiButton__content"><span class="euiButton__text">Generate</span></span></button></div></div>`) | |
} | |
$('#generateFaker').on('click', function () { | |
console.log('GENERATING'); | |
setNativeValue($('*[placeholder="Nom de famille"]').get(0), faker.name.lastName()); | |
setNativeValue($('*[placeholder="Prénom*"]').get(0), faker.name.firstName()); | |
setNativeValue($('*[placeholder="Date de naissance"]').get(0), "10/10/1980") | |
setNativeValue($('.PhoneInputInput').get(0), faker.phone.phoneNumber()); | |
let mail = faker.internet.email(); | |
setNativeValue($('*[placeholder="Adresse e-mail"]').get(0), mail) | |
setNativeValue($('*[placeholder="Confirmer votre adresse e-mail"]').get(0), mail) | |
$('#sign_cgu').prop('checked', true); | |
}); | |
}, 1000); | |
}, false); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment