manifest.json
{
"name": "Insert the first part of the PIN and check 'I have read...' checkbox",
"version": "1.0",
"manifest_version": 3,
"action": {},
"content_scripts": [
{
"matches": ["https://apps-idp.novartis.com/*"],
"all_frames": true,
"js": ["content-script.js"]
}
]
}content-script.js
const PIN = '<your pin>';
const loadingElem = document.querySelector('#loading-screen');
if (!loadingElem) {
console.warn('loading div is not found');
} else {
const mConfig = {
attributesList: ["style"],
attributeOldValue: true,
}
const mCallback = (mutationList, observer) => {
const mutationRecord = mutationList.pop();
if (mutationRecord.attributeName === 'style') {
const target = mutationRecord.target;
if (target.style.display === 'none') {
doStuff();
}
}
}
const observer = new MutationObserver(mCallback);
observer.observe(loadingElem, mConfig);
}
const doStuff = () => {
const checkboxInput = document.querySelector('#eula-accept');
if (checkboxInput) {
checkboxInput.click();
} else {
console.error('The checkbox is not found on the page');
}
const psswdInput = document.querySelector('#passwd');
if (psswdInput) {
psswdInput.value = PIN;
psswdInput.focus();
} else {
console.error('The password input is not found');
}
}