forked from ShigShag/CAPTCHASecurityInsights
-
Notifications
You must be signed in to change notification settings - Fork 0
/
window.js
30 lines (26 loc) · 1.14 KB
/
window.js
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
(function wrapWindowFunctions() {
// Object to store call counts
const callCounts = {};
for (const prop in window) {
// Ensure the property is actually on the window and not its prototype
if (window.hasOwnProperty(prop)) {
try {
// Check if the property is a function and wrap it
if (typeof window[prop] === 'function') {
const originalFunction = window[prop];
callCounts[prop] = 0; // Initialize counter for this function
window[prop] = function(...args) {
callCounts[prop] += 1;
console.log(`Function ${prop} called ${callCounts[prop]} times with arguments:`, args);
console.log(callCounts);
return originalFunction.apply(this, args);
};
}
} catch (error) {
console.error(`Error wrapping function ${prop}:`, error);
}
}
}
// Optionally expose the callCounts for external use or debugging
window.functionCallCounts = callCounts;
})();