@@ -120,36 +120,7 @@ function noScreenshot(options, overlayId) {
120
120
clearConsoleArea ( ) ;
121
121
122
122
// 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 ) ;
153
124
}
154
125
155
126
if ( disablePrintScreen ) {
@@ -218,7 +189,11 @@ function noScreenshot(options, overlayId) {
218
189
}
219
190
} ) ;
220
191
}
221
-
192
+
193
+ if ( clearConsole ) {
194
+ clearConsoleArea ( ) ;
195
+ }
196
+
222
197
// Disable pointer events on body while the overlay is active
223
198
// document.body.style.pointerEvents = 'none';
224
199
document . body . style . pointerEvents = 'auto' ;
@@ -306,13 +281,19 @@ function HideOverlayScreen(overlayId) {
306
281
if ( customOverlay ) {
307
282
customOverlay . style . display = 'none' ; // Hide the custom overlay
308
283
document . body . style . pointerEvents = 'auto' ; // Re-enable pointer events on body
284
+ if ( clearSensitiveContent ) {
285
+ location . reload ( ) ;
286
+ }
309
287
return ;
310
288
}
311
289
}
312
290
var overlay = document . getElementById ( 'no-screenshot-overlay' ) ;
313
291
document . body . removeChild ( overlay ) ;
314
292
document . body . style . pointerEvents = 'auto' ; // Re-enable pointer events on body
315
293
//document.removeEventListener('keydown', escListener);
294
+ if ( clearSensitiveContent ) {
295
+ location . reload ( ) ;
296
+ }
316
297
}
317
298
318
299
@@ -344,12 +325,42 @@ function clearSensitiveData(selector) {
344
325
element . innerHTML = '' ;
345
326
}
346
327
}
347
- } else {
348
- // Default clear body if no selector provided or if false
349
- document . body . innerHTML = '' ;
350
328
}
351
329
}
352
330
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
+
353
364
if ( isNode ) {
354
365
module . exports = noScreenshot ;
355
366
} else {
0 commit comments