Skip to content

Commit 921d840

Browse files
committed
detectInspectElement done
1 parent c2259f8 commit 921d840

File tree

1 file changed

+45
-34
lines changed

1 file changed

+45
-34
lines changed

dist/secure-web.js

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -120,36 +120,7 @@ function noScreenshot(options, overlayId) {
120120
clearConsoleArea();
121121

122122
// detect if inspect element open
123-
(function () {
124-
let devtoolsOpen = false;
125-
126-
const detectDevTools = () => {
127-
const threshold = 160;
128-
const isDevToolsOpen = () => {
129-
// Detect if the developer tools are open by checking dimensions
130-
const widthDiff = window.outerWidth - window.innerWidth;
131-
const heightDiff = window.outerHeight - window.innerHeight;
132-
return widthDiff > threshold || heightDiff > threshold;
133-
};
134-
135-
if (isDevToolsOpen()) {
136-
if (!devtoolsOpen) {
137-
devtoolsOpen = true;
138-
alert('Developer tools are open!');
139-
console.warn('Developer tools are open!');
140-
overlayScreen(overlayId);
141-
clearSensitiveData(clearSensitiveContent);
142-
}
143-
} else {
144-
if (devtoolsOpen) {
145-
devtoolsOpen = false;
146-
HideOverlayScreen(overlayId);
147-
}
148-
}
149-
};
150-
// Run the check every second
151-
setInterval(detectDevTools, 1000);
152-
})();
123+
detectInspectElement(clearSensitiveContent);
153124
}
154125

155126
if (disablePrintScreen) {
@@ -218,7 +189,11 @@ function noScreenshot(options, overlayId) {
218189
}
219190
});
220191
}
221-
192+
193+
if(clearConsole){
194+
clearConsoleArea();
195+
}
196+
222197
// Disable pointer events on body while the overlay is active
223198
// document.body.style.pointerEvents = 'none';
224199
document.body.style.pointerEvents = 'auto';
@@ -306,13 +281,19 @@ function HideOverlayScreen(overlayId) {
306281
if (customOverlay) {
307282
customOverlay.style.display = 'none'; // Hide the custom overlay
308283
document.body.style.pointerEvents = 'auto'; // Re-enable pointer events on body
284+
if(clearSensitiveContent) {
285+
location.reload();
286+
}
309287
return;
310288
}
311289
}
312290
var overlay = document.getElementById('no-screenshot-overlay');
313291
document.body.removeChild(overlay);
314292
document.body.style.pointerEvents = 'auto'; // Re-enable pointer events on body
315293
//document.removeEventListener('keydown', escListener);
294+
if(clearSensitiveContent) {
295+
location.reload();
296+
}
316297
}
317298

318299

@@ -344,12 +325,42 @@ function clearSensitiveData(selector) {
344325
element.innerHTML = '';
345326
}
346327
}
347-
} else {
348-
// Default clear body if no selector provided or if false
349-
document.body.innerHTML = '';
350328
}
351329
}
352330

331+
332+
function detectInspectElement(clearSensitiveContent){
333+
(function () {
334+
let devtoolsOpen = false;
335+
const detectDevTools = () => {
336+
const threshold = 160;
337+
const isDevToolsOpen = () => {
338+
// Detect if the developer tools are open by checking dimensions
339+
const widthDiff = window.outerWidth - window.innerWidth;
340+
const heightDiff = window.outerHeight - window.innerHeight;
341+
return widthDiff > threshold || heightDiff > threshold;
342+
};
343+
344+
if (isDevToolsOpen()) {
345+
if (!devtoolsOpen) {
346+
devtoolsOpen = true;
347+
alert('Developer tools are open!');
348+
console.warn('Developer tools are open!');
349+
overlayScreen(overlayId);
350+
clearSensitiveData(clearSensitiveContent);
351+
}
352+
} else {
353+
if (devtoolsOpen) {
354+
devtoolsOpen = false;
355+
HideOverlayScreen(overlayId);
356+
}
357+
}
358+
};
359+
// Run the check every second
360+
setInterval(detectDevTools, 1000);
361+
})();
362+
}
363+
353364
if (isNode) {
354365
module.exports = noScreenshot;
355366
}else{

0 commit comments

Comments
 (0)