From 9398df91c23d06150d4a6cfadeb99adc99b594a0 Mon Sep 17 00:00:00 2001 From: chenzhongsheng Date: Fri, 22 Dec 2023 10:00:07 +0800 Subject: [PATCH] feat: rewriteHTML config --- README.cn.md | 3 ++- README.md | 3 ++- scripts/version.en.md | 6 ++++++ scripts/version.md | 6 ++++++ src/type.d.ts | 1 + src/utils/close-window.ts | 13 ++++++++++--- src/utils/config.ts | 1 + 7 files changed, 28 insertions(+), 5 deletions(-) diff --git a/README.cn.md b/README.cn.md index 4503af8..41903c6 100644 --- a/README.cn.md +++ b/README.cn.md @@ -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 { diff --git a/README.md b/README.md index 3fb1997..0c4659f 100644 --- a/README.md +++ b/README.md @@ -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 { diff --git a/scripts/version.en.md b/scripts/version.en.md index 6c5b8e4..0ce3036 100644 --- a/scripts/version.en.md +++ b/scripts/version.en.md @@ -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 diff --git a/scripts/version.md b/scripts/version.md index a040d67..cea0eaf 100644 --- a/scripts/version.md +++ b/scripts/version.md @@ -5,6 +5,12 @@ --> # Version Log: +## 0.3.7 + +1. 修复移动端浏览器长按不弹出复制等按钮 +2. 增加 rewriteHTML 配置 +3. 移除 closeWindow 中的 clearDDInterval 调用 + ## 0.3.6 1. fix google lighthouse 新版本没有放行 diff --git a/src/type.d.ts b/src/type.d.ts index 3683183..560111c 100644 --- a/src/type.d.ts +++ b/src/type.d.ts @@ -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 { diff --git a/src/utils/close-window.ts b/src/utils/close-window.ts index ee7e134..ccdf859 100644 --- a/src/utils/close-window.ts +++ b/src/utils/close-window.ts @@ -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; diff --git a/src/utils/config.ts b/src/utils/config.ts index 5b1996b..cd97dc8 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -26,6 +26,7 @@ export const config: IConfig = { ignore: null, disableIframeParents: true, seo: true, + rewriteHTML: '', }; const MultiTypeKeys = ['detectors', 'ondevtoolclose', 'ignore'];