Skip to content

Commit

Permalink
feat: rewriteHTML config
Browse files Browse the repository at this point in the history
  • Loading branch information
theajack3 committed Dec 22, 2023
1 parent 741a600 commit 9398df9
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.cn.md
Expand Up @@ -224,7 +224,8 @@ interface IConfig {
disablePaste: boolean; // 是否禁用粘贴 默认为false
ignore?: (string|RegExp)[] | null | (()=>boolean); // 某些情况忽略禁用
disableIframeParents?: boolean; // iframe中是否禁用所有父窗口
timeOutUrl?: // 关闭页面超时跳转的url;
timeOutUrl?: string; // 关闭页面超时跳转的url;
rewriteHTML: string; // 检测到打开之后重写页面
}

enum DetectorType {
Expand Down
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -221,7 +221,8 @@ declare interface IConfig {
disablePaste: boolean; // Whether to disable paste, default is false
ignore?: (string| RegExp)[] | null | (()=>boolean); // Some cases ignore the disablement
disableIframeParents?: boolean; // Whether all parent windows are disabled in the iframe
timeOutUrl?: // Turn off URLs that page timeouts forward towards
timeOutUrl?: string; // Turn off URLs that page timeouts forward towards
rewriteHTML?: string; // Detecting the rewriting page after opening
}

enum DetectorType {
Expand Down
6 changes: 6 additions & 0 deletions scripts/version.en.md
Expand Up @@ -5,6 +5,12 @@
-->
# Version Log:

## 0.3.7

1. Fix the movement of the mobile browser long press and not pop up the copy and other buttons
2. Add REWRITEHTML configuration
3. Remove CleardDinterval calls in Closewindow

## 0.3.6

1. Fix The new version of Google Lighthouse is not released
Expand Down
6 changes: 6 additions & 0 deletions scripts/version.md
Expand Up @@ -5,6 +5,12 @@
-->
# Version Log:

## 0.3.7

1. 修复移动端浏览器长按不弹出复制等按钮
2. 增加 rewriteHTML 配置
3. 移除 closeWindow 中的 clearDDInterval 调用

## 0.3.6

1. fix google lighthouse 新版本没有放行
Expand Down
1 change: 1 addition & 0 deletions src/type.d.ts
Expand Up @@ -26,6 +26,7 @@ export interface IConfig {
ignore: (string|RegExp)[] | null | (()=>boolean); // 某些情况忽略禁用
disableIframeParents: boolean; // iframe中是否禁用所有父窗口,默认 true
seo: boolean; // 是否启用对seo进行保护,默认 true
rewriteHTML: string; // 检测到打开之后重写页面
}

export interface IDisableDevtool {
Expand Down
13 changes: 10 additions & 3 deletions src/utils/close-window.ts
Expand Up @@ -2,17 +2,24 @@
* @Author: tackchen
* @Date: 2021-12-24 15:14:06
* @LastEditors: Please set LastEditors
* @LastEditTime: 2023-06-21 08:00:32
* @LastEditTime: 2023-12-22 09:57:58
* @FilePath: /disable-devtool/src/close-window.js
* @Description: Coding something
*/
import {config} from './config';
import {clearDDInterval} from './interval';
// import {clearDDInterval} from './interval';

export function closeWindow () {
clearDDInterval();
// clearDDInterval();
if (config.url) {
window.location.href = config.url;
} else if (config.rewriteHTML) {
try {
document.documentElement.innerHTML = config.rewriteHTML;
} catch (e) {
// for 'TrustedHTML' assignment
document.documentElement.innerText = config.rewriteHTML;
}
} else {
try {
window.opener = null;
Expand Down
1 change: 1 addition & 0 deletions src/utils/config.ts
Expand Up @@ -26,6 +26,7 @@ export const config: IConfig = {
ignore: null,
disableIframeParents: true,
seo: true,
rewriteHTML: '',
};

const MultiTypeKeys = ['detectors', 'ondevtoolclose', 'ignore'];
Expand Down

0 comments on commit 9398df9

Please sign in to comment.