PageSourceSearch

http://www.accountsupport.com/generalAppC/javascripts/mutation-observer.js

js accountsupport.com collected 2026-10-03 22:10:35 UTC 1,766 bytes, 54 lines download raw bytes

1// Function to collect error message from the toast
2function collectToastErrorMessage(errorToast) {
3    const message = $(errorToast).text();
4    const errorMessage = message.trim();
5    if (errorMessage) {
6        $.ajax({
7            url: '/controlpanel/templates/collect_error.cmp',
8            method: 'POST',
9            data: jQuery.param({'message': errorMessage, 'action': 'collect_error'}),
10            success: function(response){
11                console.log('Error message collected successfully');
12            },
13            error: function(){
14                console.log('Error occurred while collecting error message');
15            }
16        });
17    }
18}
19
20// MutationObserver to detect when error toast is added
21const displayedErrors = new Set();
22
23const observer = new MutationObserver(function (mutationsList) {
24    for (const mutation of mutationsList) {
25        const target = mutation.target;
26
27        if (/error/.test(target.className) && !displayedErrors.has(target.innerText)) {
28            collectToastErrorMessage(target);
29            displayedErrors.add(target.innerText);
30        }
31
32        if (mutation.type === "childList" && mutation.addedNodes.length > 0) {
33            mutation.addedNodes.forEach((node) => {
34                if (node.nodeType === 1 && node.classList.contains("toast-error")) {
35                    const errorText = node.innerText || "";
36                    if (!displayedErrors.has(errorText)) {
37                        collectToastErrorMessage(node);
38                        displayedErrors.add(errorText);
39                    }
40                }
41            });
42        }
43    }
44});
45
46const config = {
47    childList: true,
48    subtree: true,
49};
50
51
52const targetNode = document.body;
53
54observer.observe(targetNode, config);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.