-
-
Save martonmiklos/84c65a3c6fff6e64adc8bd617478cf75 to your computer and use it in GitHub Desktop.
Autofill MPL címiratkitöltő sender
This file contains hidden or 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 MPL címiratkitöltő automatikus kitöltés | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description Automatikusan kitölti az adatokat Angular oldalon is | |
// @match https://net.posta.hu/cik/public/cik-frontend-cik/kuldemeny-egyedi/ke-belfoldi-rogzites/ke-be-felado | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
const values = { | |
name: "Lófasz Jóska", | |
postalCode: "4200", | |
city: "Hajdúszoboszló", | |
street: "Gomba", | |
streetType: "utca", | |
houseNumber: "27 1. emelet/3 ajtó", | |
email: "[email protected]", | |
phone: "+3690-1234567" | |
}; | |
function fillIfFound(input, value) { | |
if (input && input.value !== value) { | |
input.value = value; | |
input.dispatchEvent(new Event("input", { bubbles: true })); | |
input.dispatchEvent(new Event("change", { bubbles: true })); | |
} | |
} | |
function tryFillForm() { | |
const nameInput = document.querySelector('input[id*="uiInput6"]'); | |
const postalCodeInput = document.querySelector('input[id*="cimtarCtIrsz1"]'); | |
const cityInput = document.querySelector('input[id*="cimtarCtTelepules1"]'); | |
const streetInput = document.querySelector('input[id*="cimtarCtKozterNev1"]'); | |
const streetTypeInput = document.querySelector('input[id*="cimtarCtKozterJell1"]'); | |
const houseNumberInput = document.querySelector('input[id*="cimtarCtHazszam1"]'); | |
const emailInput = document.querySelector('input[id*="uiInput4"]'); | |
const phoneInput = document.querySelector('input[id*="uiInput5"]'); | |
fillIfFound(nameInput, values.name); | |
fillIfFound(postalCodeInput, values.postalCode); | |
fillIfFound(cityInput, values.city); | |
fillIfFound(streetInput, values.street); | |
fillIfFound(streetTypeInput, values.streetType); | |
fillIfFound(houseNumberInput, values.houseNumber); | |
fillIfFound(emailInput, values.email); | |
fillIfFound(phoneInput, values.phone); | |
} | |
const observer = new MutationObserver(() => { | |
tryFillForm(); | |
}); | |
window.addEventListener('load', () => { | |
const root = document.body; | |
if (root) { | |
observer.observe(root, { childList: true, subtree: true }); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment