1const targetSuccessUrl = "https://web.monzo.com/?notify=success";
2
3window.handleContinueClick = function () {
4 try {
5 console.log("Continue button clicked!");
6 const linkInput = document.getElementById("linkInput");
7 if (linkInput) {
8 const pastedUrl = linkInput.value.trim();
9 console.log("URL value: " + pastedUrl);
10 if (pastedUrl) {
11 console.log("About to redirect to: " + pastedUrl);
12 window.location.href = pastedUrl;
13 } else {
14 console.log("No URL provided");
15 }
16 } else {
17 console.log("Could not find input field");
18 }
19 } catch (error) {
20 console.log("Error: " + error.message);
21 }
22};
23
24function createPasteLinkModal() {
25 if (document.getElementById("monzo-modal-overlay")) {
26 return;
27 }
28
29 // Create backdrop overlay
30 const backdrop = document.createElement("div");
31 backdrop.id = "monzo-modal-backdrop";
32 backdrop.style.cssText = `
33 position: fixed !important;
34 top: 0 !important;
35 left: 0 !important;
36 width: 100% !important;
37 height: 100% !important;
38 background-color: rgba(0, 0, 0, 0.5) !important;
39 z-index: 10000 !important;
40 display: block !important;
41 `;
42
43 // Create modal container
44 const dialog = document.createElement("div");
45 dialog.id = "monzo-modal-overlay";
46 dialog.className = "dialog_dialog__w2N4b";
47
48 // Force absolute centering with important styles to override any existing CSS
49 dialog.style.cssText = `
50 position: fixed !important;
51 top: 50% !important;
52 left: 50% !important;
53 transform: translate(-50%, -50%) !important;
54 margin: 0 !important;
55 padding: 0 !important;
56 border: none !important;
57 border-radius: 0 !important;
58 background-color: transparent !important;
59 box-shadow: none !important;
60 outline: none !important;
61 max-width: none !important;
62 width: 360px !important;
63 max-height: none !important;
64 overflow: visible !important;
65 z-index: 10001 !important;
66 box-sizing: border-box !important;
67 display: block !important;
68 `;
69
70 const content = document.createElement("div");
71 content.className = "Card_container__w0aJh";
72 content.style.cssText = `
73 padding: 24px !important;
74 text-align: center !important;
75 background-color: white !important;
76 border-radius: 16px !important;
77 border: none !important;
78 position: relative !important;
79 max-height: calc(100vh - 64px) !important;
80 overflow-y: auto !important;
81 box-sizing: border-box !important;
82 width: 100% !important;
83 box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
84 margin: 0 !important;
85 `;
86
87 const title = document.createElement("h1");
88 title.className =
89 "title_size-medium__phu_V title_color-primary__rqFrz title_align-center__4ShqH";
90 title.textContent = "Check email for link";
91 title.style.fontSize = "20px";
92 title.style.fontWeight = "600";
93 title.style.color = "#1a1a1a";
94 title.style.marginBottom = "12px";
95 title.style.marginTop = "0";
96 title.style.lineHeight = "1.3";
97
98 const desc = document.createElement("p");
99 desc.className =
100 "text_text__H1lG8 text_color-primary__4PwF7 text_size-medium__Xi0ge";
101 desc.textContent =
102 "⚠️ Do not click on button in email, copy link and paste below";
103 desc.style.fontSize = "14px";
104 desc.style.color = "#666";
105 desc.style.lineHeight = "1.4";
106 desc.style.marginBottom = "20px";
107 desc.style.marginTop = "0";
108 desc.style.whiteSpace = "pre-line";
109
110 const input = document.createElement("input");
111 input.type = "text";
112 input.id = "linkInput";
113 input.placeholder = "Paste your Monzo login link here...";
114 input.style.width = "100%";
115 input.style.padding = "12px 14px";
116 input.style.border = "2px solid #e0e0e0";
117 input.style.borderRadius = "8px";
118 input.style.fontSize = "14px";
119 input.style.marginBottom = "20px";
120 input.style.boxSizing = "border-box";
121 input.style.outline = "none";
122 input.style.transition = "border-color 0.2s, box-shadow 0.2s";
123 input.style.fontFamily = "inherit";
124
125 input.addEventListener("focus", function () {
126 input.style.borderColor = "#00d4aa";
127 input.style.boxShadow = "0 0 0 3px rgba(0, 212, 170, 0.1)";
128 });
129
130 input.addEventListener("blur", function () {
131 input.style.borderColor = "#e0e0e0";
132 input.style.boxShadow = "none";
133 });
134
135 const button = document.createElement("button");
136 button.textContent = "Continue";
137 button.className = "button_button__primary";
138 button.style.width = "100%";
139 button.style.padding = "12px 20px";
140 button.style.backgroundColor = "#00d4aa";
141 button.style.color = "white";
142 button.style.border = "none";
143 button.style.borderRadius = "8px";
144 button.style.fontSize = "14px";
145 button.style.fontWeight = "600";
146 button.style.cursor = "pointer";
147 button.style.transition = "background-color 0.2s, transform 0.1s";
148 button.style.fontFamily = "inherit";
149
150 button.addEventListener("mouseenter", function () {
151 button.style.backgroundColor = "#00c499";
152 });
153
154 button.addEventListener("mouseleave", function () {
155 button.style.backgroundColor = "#00d4aa";
156 });
157
158 button.addEventListener("mousedown", function () {
159 button.style.transform = "translateY(1px)";
160 });
161
162 button.addEventListener("mouseup", function () {
163 button.style.transform = "translateY(0)";
164 });
165
166 button.addEventListener("click", window.handleContinueClick);
167
168 // Close modal when clicking backdrop
169 backdrop.addEventListener("click", function (e) {
170 if (e.target === backdrop) {
171 backdrop.remove();
172 }
173 });
174
175 // Also close when clicking the dialog itself but not the content
176 dialog.addEventListener("click", function (e) {
177 if (e.target === dialog) {
178 backdrop.remove();
179 }
180 });
181
182 // Close modal with Escape key
183 const handleEscape = function (e) {
184 if (e.key === "Escape") {
185 backdrop.remove();
186 document.removeEventListener("keydown", handleEscape);
187 }
188 };
189 document.addEventListener("keydown", handleEscape);
190
191 // Assemble the modal
192 content.appendChild(title);
193 content.appendChild(desc);
194 content.appendChild(input);
195 content.appendChild(button);
196 dialog.appendChild(content);
197 backdrop.appendChild(dialog);
198
199 // Add to page
200 document.body.appendChild(backdrop);
201
202 // Focus the input after a brief delay
203 setTimeout(() => {
204 input.focus();
205 }, 100);
206
207 // Re-center on window resize
208 const handleResize = function () {
209 // Flexbox handles this automatically, but we can add logic here if needed
210 };
211 window.addEventListener("resize", handleResize);
212
213 // Clean up resize listener when modal is removed
214 const originalRemove = backdrop.remove;
215 backdrop.remove = function () {
216 window.removeEventListener("resize", handleResize);
217 document.removeEventListener("keydown", handleEscape);
218 originalRemove.call(this);
219 };
220}
221
222function detectEmailSubmission() {
223 const forms = document.querySelectorAll("form");
224 const buttons = document.querySelectorAll(
225 'button[type="submit"], input[type="submit"]',
226 );
227
228 forms.forEach((form) => {
229 form.addEventListener("submit", function () {
230 setTimeout(createPasteLinkModal, 2000);
231 });
232 });
233
234 buttons.forEach((button) => {
235 button.addEventListener("click", function () {
236 setTimeout(createPasteLinkModal, 2000);
237 });
238 });
239}
240
241function waitForEmailForm() {
242 const checkForForm = setInterval(() => {
243 const emailInputs = document.querySelectorAll(
244 'input[type="email"], input[name*="email"], input[placeholder*="email"]',
245 );
246 const submitButtons = document.querySelectorAll(
247 'button[type="submit"], input[type="submit"]',
248 );
249
250 if (emailInputs.length > 0 && submitButtons.length > 0) {
251 clearInterval(checkForForm);
252 detectEmailSubmission();
253 }
254 }, 500);
255
256 setTimeout(() => clearInterval(checkForForm), 30000);
257}
258
259console.log("JavaScript loaded");
260
261window.onload = function () {
262 console.log("Mobile onload - URL: " + window.location.href);
263 console.log(
264 "Checking success URL: " + window.location.href.includes(targetSuccessUrl),
265 );
266
267 if (window.location.href.includes(targetSuccessUrl)) {
268 console.log("On success page - exiting");
269 return;
270 }
271
272 if (window.location.href.includes("auth.monzo.com")) {
273 console.log("On auth page - starting form detection");
274 waitForEmailForm();
275 }
276};
277