Skip to content

Commit 9398df9

Browse files
committed
feat: rewriteHTML config
1 parent 741a600 commit 9398df9

File tree

7 files changed

+28
-5
lines changed

7 files changed

+28
-5
lines changed

README.cn.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ interface IConfig {
224224
disablePaste: boolean; // 是否禁用粘贴 默认为false
225225
ignore?: (string|RegExp)[] | null | (()=>boolean); // 某些情况忽略禁用
226226
disableIframeParents?: boolean; // iframe中是否禁用所有父窗口
227-
timeOutUrl?: // 关闭页面超时跳转的url;
227+
timeOutUrl?: string; // 关闭页面超时跳转的url;
228+
rewriteHTML: string; // 检测到打开之后重写页面
228229
}
229230

230231
enum DetectorType {

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ declare interface IConfig {
221221
disablePaste: boolean; // Whether to disable paste, default is false
222222
ignore?: (string| RegExp)[] | null | (()=>boolean); // Some cases ignore the disablement
223223
disableIframeParents?: boolean; // Whether all parent windows are disabled in the iframe
224-
timeOutUrl?: // Turn off URLs that page timeouts forward towards
224+
timeOutUrl?: string; // Turn off URLs that page timeouts forward towards
225+
rewriteHTML?: string; // Detecting the rewriting page after opening
225226
}
226227

227228
enum DetectorType {

scripts/version.en.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
-->
66
# Version Log:
77

8+
## 0.3.7
9+
10+
1. Fix the movement of the mobile browser long press and not pop up the copy and other buttons
11+
2. Add REWRITEHTML configuration
12+
3. Remove CleardDinterval calls in Closewindow
13+
814
## 0.3.6
915

1016
1. Fix The new version of Google Lighthouse is not released

scripts/version.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
-->
66
# Version Log:
77

8+
## 0.3.7
9+
10+
1. 修复移动端浏览器长按不弹出复制等按钮
11+
2. 增加 rewriteHTML 配置
12+
3. 移除 closeWindow 中的 clearDDInterval 调用
13+
814
## 0.3.6
915

1016
1. fix google lighthouse 新版本没有放行

src/type.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface IConfig {
2626
ignore: (string|RegExp)[] | null | (()=>boolean); // 某些情况忽略禁用
2727
disableIframeParents: boolean; // iframe中是否禁用所有父窗口,默认 true
2828
seo: boolean; // 是否启用对seo进行保护,默认 true
29+
rewriteHTML: string; // 检测到打开之后重写页面
2930
}
3031

3132
export interface IDisableDevtool {

src/utils/close-window.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@
22
* @Author: tackchen
33
* @Date: 2021-12-24 15:14:06
44
* @LastEditors: Please set LastEditors
5-
* @LastEditTime: 2023-06-21 08:00:32
5+
* @LastEditTime: 2023-12-22 09:57:58
66
* @FilePath: /disable-devtool/src/close-window.js
77
* @Description: Coding something
88
*/
99
import {config} from './config';
10-
import {clearDDInterval} from './interval';
10+
// import {clearDDInterval} from './interval';
1111

1212
export function closeWindow () {
13-
clearDDInterval();
13+
// clearDDInterval();
1414
if (config.url) {
1515
window.location.href = config.url;
16+
} else if (config.rewriteHTML) {
17+
try {
18+
document.documentElement.innerHTML = config.rewriteHTML;
19+
} catch (e) {
20+
// for 'TrustedHTML' assignment
21+
document.documentElement.innerText = config.rewriteHTML;
22+
}
1623
} else {
1724
try {
1825
window.opener = null;

src/utils/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const config: IConfig = {
2626
ignore: null,
2727
disableIframeParents: true,
2828
seo: true,
29+
rewriteHTML: '',
2930
};
3031

3132
const MultiTypeKeys = ['detectors', 'ondevtoolclose', 'ignore'];

0 commit comments

Comments
 (0)