-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcvscorp.js
More file actions
43 lines (37 loc) · 1.35 KB
/
cvscorp.js
File metadata and controls
43 lines (37 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// ==UserScript==
// @name CVS Username Autofill (MutationObserver)
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Autofills the username field on the CVS website login page using MutationObserver
// @author You
// @match https://www.cvs.com/account-login/benefits/*
// @grant none
// ==/UserScript==
(function () {
'use strict';
const email = 'email';
// Function to fill the username field
function autofillUsername() {
const usernameField = document.querySelector('input[type="text"]');
if (usernameField) {
usernameField.value = email;
usernameField.dispatchEvent(new Event('input', { bubbles: true }));
usernameField.dispatchEvent(new Event('change', { bubbles: true }));
usernameField.focus();
usernameField.blur();
//observer.disconnect();
}
}
// Create a MutationObserver instance
const observer = new MutationObserver(function (mutationsList, observer) {
for (const mutation of mutationsList) {
autofillUsername();
}
});
// Start observing the document body (or a more specific container if known)
const targetNode = document.body;
const config = { childList: true, subtree: true };
observer.observe(targetNode, config);
// Initial check in case the element is already present on page load
autofillUsername();
})();