浏览代码

递归注入iframe

PUGE 2 月之前
父节点
当前提交
c59956960f
共有 9 个文件被更改,包括 591 次插入234 次删除
  1. 0 23
      dist/win-ia32-unpacked/config.json
  2. 0 197
      dist/win-ia32-unpacked/preLoadFile.js
  3. 21 0
      dist/大发/config.json
  4. 1 11
      dist/大发/preload.js
  5. 189 0
      dist/大发/test.html
  6. 189 0
      dist/直播间/test.html
  7. 二进制
      icon.ico
  8. 二进制
      icon2.ico
  9. 191 3
      main.js

+ 0 - 23
dist/win-ia32-unpacked/config.json

@@ -1,23 +0,0 @@
-{
-    "enterURL": "https://m.youtube.com/",
-    "width": 376,
-    "height": 667,
-    "webPreferences": {
-        "webSecurity": false,
-        "nodeIntegration": false,
-        "nativeWindowOpen": false,
-        "preload": "<dir>/preload.js",
-        "worldSafeExecuteJavaScript": true,
-        "enableRemoteModule": false,
-        "safeDialogs": false
-    },
-    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
-    "autoHideMenuBar": true,
-    "redirect":[],
-    "redirectURL":"",
-    "proxy":"",
-    "noCache": false,
-    "interceptor":[
-    ],
-    "preLoadFile": "<dir>/preLoadFile.js"
-}

+ 0 - 197
dist/win-ia32-unpacked/preLoadFile.js

@@ -1,197 +0,0 @@
-function getDaysAgo(n) {
-  const timestamp = Date.now() - (n * 24 * 60 * 60 * 1000);
-  const date = new Date(timestamp);
-  
-  const year = date.getFullYear();
-  const month = String(date.getMonth() + 1).padStart(2, '0');
-  const day = String(date.getDate()).padStart(2, '0');
-  
-  return `${year}-${month}-${day}`;
-}
-
-function csvToArray(csvString) {
-  const lines = csvString.split('\n');
-  const result = [];
-  
-  for (let line of lines) {
-    // 跳过空行
-    if (line.trim() === '') continue;
-    
-    // 按逗号分割,并去除每个字段的空白
-    const row = line.split(',').map(field => field.trim());
-    result.push(row);
-  }
-  
-  return result;
-}
-
-function arrayToCSV(array) {
-  return array.map(row => 
-    row.map(field => String(field)).join(',')
-  ).join('\n');
-}
-
-
-function creatToday(fileList) {
-  for (let index = 1; index < fileList.length - 1; index++) {
-    fileList[index][2] = fileList[index][5]
-    fileList[index][3] = fileList[index][6]
-    fileList[index][4] = fileList[index][7]
-    fileList[index][5] = ""
-    fileList[index][6] = ""
-    fileList[index][7] = ""
-    fileList[index][8] = ""
-    fileList[index][9] = ""
-    fileList[index][10] = ""
-  }
-  const fileData = {
-    filename: getDaysAgo(0) + '.csv',
-    content: arrayToCSV(fileList),
-    encoding: "gb2312"
-  };
-
-  // 调用保存方法
-  window.electronAPI.saveFile(fileData).then(result => {
-    if (result.success) {
-      console.log('文件保存成功:', result.path);
-    } else {
-      console.error('文件保存失败:', result.error);
-    }
-  });
-}
-
-
-function saveFile(adtaArr, next) {
-  // 保存数据
-  const fileData = {
-    filename: getDaysAgo(0) + '.csv',
-    content: arrayToCSV(adtaArr),
-    encoding: "gb2312"
-  };
-
-  // 调用保存方法
-  window.electronAPI.saveFile(fileData).then(result => {
-    if (result.success) {
-      console.log('文件保存成功:', result.path);
-      setTimeout(() => {
-        if (next) checkData(adtaArr, next)
-      }, 1000);
-    } else {
-      console.error('文件保存失败:', result.error);
-    }
-  });
-}
-
-function cutString (original, before, after, index) {
-  index = index || 0;
-  if (typeof index === "number") {
-    const P = original.indexOf(before, index);
-    if (P > -1) {
-      if (after) {
-        const f = original.indexOf(after, P + before.length);
-        return (f>-1)? original.slice(P + before.toString().length, f):console.error("Tool [在文本中找不到 参数三 "+after+"]");
-      } else {
-        return original.slice(P + before.toString().length);
-      }
-    } else {
-      console.error("Tool [在文本中找不到 参数一 " + before + "]");
-      return
-    }
-  } else {
-    console.error("Tool [sizeTransition:" + index + "不是一个整数!]");
-  }
-}
-
-function checkData (adtaArr) {
-  for (let index = 0; index < adtaArr.length; index++) {
-    const element = adtaArr[index];
-    console.log(element)
-    if (element[1].includes('https://') && element[5] === '') {
-      console.log(element[1])
-      if (location.href.slice(0, 40) == element[1].slice(0, 40)) {
-        setTimeout(() => {
-          document.querySelector('.yt-truncated-text__absolute-button').click()
-          setTimeout(() => {
-            let pdInfo = document.querySelector('.style-scope.ytd-about-channel-renderer').innerText
-            let bfsl = parseInt(cutString(pdInfo,'视频\n\n\t', '次观看'))
-            let spsl = parseInt(cutString(pdInfo,'订阅者\n\n\t', '个视频'))
-            let dyrs = parseInt(cutString(pdInfo,'注册\n\n\t', '位订阅者'))
-            bfsl = bfsl ? bfsl : 0
-            spsl = spsl ? spsl : 0
-            dyrs = dyrs ? dyrs : 0
-            console.log(bfsl, spsl, dyrs)
-            adtaArr[index][5] = bfsl
-            adtaArr[index][6] = spsl
-            adtaArr[index][7] = dyrs
-            adtaArr[index][8] = bfsl - parseInt(adtaArr[index][2])
-            adtaArr[index][9] = spsl - parseInt(adtaArr[index][3])
-            adtaArr[index][10] = dyrs - parseInt(adtaArr[index][4])
-            saveFile(adtaArr, true)
-          }, 3000);
-        }, 2000);
-      } else {
-        location.href = element[1]
-      }
-      
-      return
-    }
-  }
-  // 汇总计算
-  adtaArr[adtaArr.length - 1][2] = 0
-  adtaArr[adtaArr.length - 1][3] = 0
-  adtaArr[adtaArr.length - 1][4] = 0
-  adtaArr[adtaArr.length - 1][5] = 0
-  adtaArr[adtaArr.length - 1][6] = 0
-  adtaArr[adtaArr.length - 1][7] = 0
-  adtaArr[adtaArr.length - 1][8] = 0
-  adtaArr[adtaArr.length - 1][9] = 0
-  adtaArr[adtaArr.length - 1][10] = 0
-  for (let index = 1; index < adtaArr.length - 1; index++) {
-    const element = adtaArr[index];
-    adtaArr[adtaArr.length - 1][2] += parseInt(element[2])
-    adtaArr[adtaArr.length - 1][3] += parseInt(element[3])
-    adtaArr[adtaArr.length - 1][4] += parseInt(element[4])
-    adtaArr[adtaArr.length - 1][5] += parseInt(element[5])
-    adtaArr[adtaArr.length - 1][6] += parseInt(element[6])
-    adtaArr[adtaArr.length - 1][7] += parseInt(element[7])
-    adtaArr[adtaArr.length - 1][8] += parseInt(element[8])
-    adtaArr[adtaArr.length - 1][9] += parseInt(element[9])
-    adtaArr[adtaArr.length - 1][10] += parseInt(element[10])
-  }
-  saveFile(adtaArr, false)
-  alert('所有项目已经检查完!')
-}
-
-
-// 调用保存方法
-window.electronAPI.readFile({filename: getDaysAgo(0) + '.csv', encoding: "gb2312"}).then(result => {
-  if (result.success) {
-    console.log(result.content);
-    // 如果内容是空的,则读取昨天的
-    if (result.content == '') {
-      window.electronAPI.readFile({filename: getDaysAgo(1) + '.csv', encoding: "gb2312"}).then(result2 => {
-        if (result2.success) {
-          console.log(result2.content);
-          // 如果内容是空的,则读取昨天的
-          if (result2.content == '') {
-            alert('缺少昨天的数据!')
-          } else {
-            let fileData = csvToArray(result2.content)
-            creatToday(fileData)
-            console.log(fileData)
-            checkData(fileData)
-          }
-        } else {
-          console.error('文件读取失败:', result2.error);
-        }
-      });
-    } else {
-      // 读取加载文件
-      let fileData = csvToArray(result.content)
-      console.log(fileData)
-      checkData(fileData)
-    }
-  } else {
-    console.error('文件读取失败:', result.error);
-  }
-});

+ 21 - 0
dist/大发/config.json

@@ -0,0 +1,21 @@
+{
+    "enterURL": "https://laotiehenbang.com/sc",
+    "width": 1200,
+    "height": 800,
+    "webPreferences": {
+        "webSecurity": false,
+        "contextIsolation": false,
+        "nodeIntegration": false,
+        "allowRunningInsecureContent": true,
+        "plugins": true,
+        "scrollBounce": true,
+        "webviewTag": true,
+        "nativeWindowOpen": true
+    },
+    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
+    "autoHideMenuBar": true,
+    "redirect":[],
+    "redirectURL":"",
+    "proxy":"",
+    "noCache": false
+}

+ 1 - 11
dist/win-ia32-unpacked/preload.js → dist/大发/preload.js

@@ -1,13 +1,6 @@
 const { contextBridge, ipcRenderer } = require('electron');
 
 
-
-// window.open = (url)=>{console.log(url)}
-window.lastText = ''
-window.lastText2 = ''
-
-
-
 contextBridge.exposeInMainWorld('electronAPI', {
   openWindow: (msg) => ipcRenderer.invoke('openWindow', msg),
   closeAllWindow: (msg) => ipcRenderer.send('closeAllWindow', msg),
@@ -25,9 +18,6 @@ contextBridge.exposeInMainWorld('electronAPI', {
   readdir: (msg) => ipcRenderer.send('readdir', msg),
   download: (msg) => ipcRenderer.send('download', msg),
   broadcast: (msg) => ipcRenderer.send('broadcast-message', msg),
-  saveFile: (msg) => ipcRenderer.invoke('saveFile', msg),
-  readFile: (msg) => ipcRenderer.invoke('readFile', msg),
-  onBroadcast: (callback) => ipcRenderer.on('message-broadcast', (event, data) => callback(data))
+  onBroadcast: (callback) => ipcRenderer.on('message-broadcast', (event, data) => callback(data)),
 });
 
-

+ 189 - 0
dist/大发/test.html

@@ -0,0 +1,189 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>简单音频音量监测</title>
+    <style>
+        body {
+            font-family: Arial, sans-serif;
+            max-width: 600px;
+            margin: 50px auto;
+            padding: 20px;
+            text-align: center;
+            background-color: #f5f5f5;
+        }
+        .container {
+            background: white;
+            padding: 20px;
+            border-radius: 10px;
+            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
+        }
+        h1 {
+            color: #333;
+        }
+        .volume-display {
+            margin: 20px 0;
+            font-size: 24px;
+            font-weight: bold;
+            color: #2c3e50;
+        }
+        .volume-bar {
+            width: 100%;
+            height: 30px;
+            background: #ecf0f1;
+            border-radius: 15px;
+            margin: 20px 0;
+            overflow: hidden;
+        }
+        .volume-level {
+            height: 100%;
+            background: linear-gradient(90deg, #2ecc71, #f1c40f, #e74c3c);
+            width: 0%;
+            transition: width 0.1s;
+        }
+        button {
+            background: #3498db;
+            color: white;
+            border: none;
+            padding: 10px 20px;
+            font-size: 16px;
+            border-radius: 5px;
+            cursor: pointer;
+            margin: 5px;
+        }
+        button:hover {
+            background: #2980b9;
+        }
+        button:disabled {
+            background: #bdc3c7;
+            cursor: not-allowed;
+        }
+        .status {
+            margin-top: 15px;
+            font-size: 14px;
+            color: #7f8c8d;
+        }
+    </style>
+</head>
+<body>
+    <div class="container">
+        <h1>音频音量监测</h1>
+        <audio id="audioF" src="https://cunchu.site/work/storage/soundSynthesis/1749269905file.wav"></audio>
+        
+        <div class="volume-display" id="volumeValue">-∞ dB</div>
+        <div class="volume-bar">
+            <div class="volume-level" id="volumeLevel"></div>
+        </div>
+        
+        <button id="playBtn">播放</button>
+        <button id="pauseBtn" disabled>暂停</button>
+        
+        <div class="status" id="status">准备就绪</div>
+    </div>
+
+    <script>
+        // 获取DOM元素
+        const audio = document.getElementById("audioF");
+        const playBtn = document.getElementById("playBtn");
+        const pauseBtn = document.getElementById("pauseBtn");
+        const volumeValue = document.getElementById("volumeValue");
+        const volumeLevel = document.getElementById("volumeLevel");
+        const status = document.getElementById("status");
+        
+        // 音频分析变量
+        let audioContext, analyser, dataArray;
+        
+        // 初始化音频分析
+        function initAudioAnalysis() {
+            audioContext = new (window.AudioContext || window.webkitAudioContext)();
+            analyser = audioContext.createAnalyser();
+            analyser.fftSize = 256;
+            
+            const source = audioContext.createMediaElementSource(audio);
+            source.connect(analyser);
+            analyser.connect(audioContext.destination);
+            
+            dataArray = new Uint8Array(analyser.frequencyBinCount);
+        }
+        
+        // 分析音频音量
+        function analyzeVolume() {
+            if (!analyser) return;
+            
+            analyser.getByteFrequencyData(dataArray);
+            
+            // 计算平均音量
+            let sum = 0;
+            for (let i = 0; i < dataArray.length; i++) {
+                sum += dataArray[i];
+            }
+            const average = sum / dataArray.length;
+            
+            // 转换为分贝 (0-255 映射到 -100dB 到 0dB)
+            const db = average > 0 ? 20 * Math.log10(average / 255) + 100 - 100 : -100;
+            
+            // 更新音量显示
+            updateVolumeDisplay(db);
+            
+            // 继续分析
+            if (!audio.paused) {
+                requestAnimationFrame(analyzeVolume);
+            }
+        }
+        
+        // 更新音量显示
+        function updateVolumeDisplay(db) {
+            // 限制db范围在-100到0之间
+            const clampedDb = Math.max(-100, Math.min(0, db));
+            const displayDb = clampedDb.toFixed(1);
+            
+            volumeValue.textContent = `${displayDb} dB`;
+            
+            // 更新音量条 (将-100到0映射到0%到100%)
+            const volumePercent = ((clampedDb + 100) / 100) * 100;
+            volumeLevel.style.width = `${volumePercent}%`;
+            
+            // 更新状态
+            if (clampedDb > -50) {
+                status.textContent = "检测到声音";
+                status.style.color = "#27ae60";
+            } else {
+                status.textContent = "静音";
+                status.style.color = "#e74c3c";
+            }
+        }
+        
+        // 播放按钮事件
+        playBtn.addEventListener("click", function() {
+            audio.play();
+            playBtn.disabled = true;
+            pauseBtn.disabled = false;
+            status.textContent = "播放中...";
+            
+            // 初始化音频分析
+            if (!audioContext) {
+                initAudioAnalysis();
+            }
+            
+            // 开始分析音量
+            analyzeVolume();
+        });
+        
+        // 暂停按钮事件
+        pauseBtn.addEventListener("click", function() {
+            audio.pause();
+            playBtn.disabled = false;
+            pauseBtn.disabled = true;
+            status.textContent = "已暂停";
+        });
+        
+        // 音频结束事件
+        audio.addEventListener("ended", function() {
+            playBtn.disabled = false;
+            pauseBtn.disabled = true;
+            status.textContent = "播放结束";
+        });
+    </script>
+</body>
+</html>

+ 189 - 0
dist/直播间/test.html

@@ -0,0 +1,189 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>简单音频音量监测</title>
+    <style>
+        body {
+            font-family: Arial, sans-serif;
+            max-width: 600px;
+            margin: 50px auto;
+            padding: 20px;
+            text-align: center;
+            background-color: #f5f5f5;
+        }
+        .container {
+            background: white;
+            padding: 20px;
+            border-radius: 10px;
+            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
+        }
+        h1 {
+            color: #333;
+        }
+        .volume-display {
+            margin: 20px 0;
+            font-size: 24px;
+            font-weight: bold;
+            color: #2c3e50;
+        }
+        .volume-bar {
+            width: 100%;
+            height: 30px;
+            background: #ecf0f1;
+            border-radius: 15px;
+            margin: 20px 0;
+            overflow: hidden;
+        }
+        .volume-level {
+            height: 100%;
+            background: linear-gradient(90deg, #2ecc71, #f1c40f, #e74c3c);
+            width: 0%;
+            transition: width 0.1s;
+        }
+        button {
+            background: #3498db;
+            color: white;
+            border: none;
+            padding: 10px 20px;
+            font-size: 16px;
+            border-radius: 5px;
+            cursor: pointer;
+            margin: 5px;
+        }
+        button:hover {
+            background: #2980b9;
+        }
+        button:disabled {
+            background: #bdc3c7;
+            cursor: not-allowed;
+        }
+        .status {
+            margin-top: 15px;
+            font-size: 14px;
+            color: #7f8c8d;
+        }
+    </style>
+</head>
+<body>
+    <div class="container">
+        <h1>音频音量监测</h1>
+        <audio id="audioF" src="https://cunchu.site/work/storage/soundSynthesis/1749269905file.wav"></audio>
+        
+        <div class="volume-display" id="volumeValue">-∞ dB</div>
+        <div class="volume-bar">
+            <div class="volume-level" id="volumeLevel"></div>
+        </div>
+        
+        <button id="playBtn">播放</button>
+        <button id="pauseBtn" disabled>暂停</button>
+        
+        <div class="status" id="status">准备就绪</div>
+    </div>
+
+    <script>
+        // 获取DOM元素
+        const audio = document.getElementById("audioF");
+        const playBtn = document.getElementById("playBtn");
+        const pauseBtn = document.getElementById("pauseBtn");
+        const volumeValue = document.getElementById("volumeValue");
+        const volumeLevel = document.getElementById("volumeLevel");
+        const status = document.getElementById("status");
+        
+        // 音频分析变量
+        let audioContext, analyser, dataArray;
+        
+        // 初始化音频分析
+        function initAudioAnalysis() {
+            audioContext = new (window.AudioContext || window.webkitAudioContext)();
+            analyser = audioContext.createAnalyser();
+            analyser.fftSize = 256;
+            
+            const source = audioContext.createMediaElementSource(audio);
+            source.connect(analyser);
+            analyser.connect(audioContext.destination);
+            
+            dataArray = new Uint8Array(analyser.frequencyBinCount);
+        }
+        
+        // 分析音频音量
+        function analyzeVolume() {
+            if (!analyser) return;
+            
+            analyser.getByteFrequencyData(dataArray);
+            
+            // 计算平均音量
+            let sum = 0;
+            for (let i = 0; i < dataArray.length; i++) {
+                sum += dataArray[i];
+            }
+            const average = sum / dataArray.length;
+            
+            // 转换为分贝 (0-255 映射到 -100dB 到 0dB)
+            const db = average > 0 ? 20 * Math.log10(average / 255) + 100 - 100 : -100;
+            
+            // 更新音量显示
+            updateVolumeDisplay(db);
+            
+            // 继续分析
+            if (!audio.paused) {
+                requestAnimationFrame(analyzeVolume);
+            }
+        }
+        
+        // 更新音量显示
+        function updateVolumeDisplay(db) {
+            // 限制db范围在-100到0之间
+            const clampedDb = Math.max(-100, Math.min(0, db));
+            const displayDb = clampedDb.toFixed(1);
+            
+            volumeValue.textContent = `${displayDb} dB`;
+            
+            // 更新音量条 (将-100到0映射到0%到100%)
+            const volumePercent = ((clampedDb + 100) / 100) * 100;
+            volumeLevel.style.width = `${volumePercent}%`;
+            
+            // 更新状态
+            if (clampedDb > -50) {
+                status.textContent = "检测到声音";
+                status.style.color = "#27ae60";
+            } else {
+                status.textContent = "静音";
+                status.style.color = "#e74c3c";
+            }
+        }
+        
+        // 播放按钮事件
+        playBtn.addEventListener("click", function() {
+            audio.play();
+            playBtn.disabled = true;
+            pauseBtn.disabled = false;
+            status.textContent = "播放中...";
+            
+            // 初始化音频分析
+            if (!audioContext) {
+                initAudioAnalysis();
+            }
+            
+            // 开始分析音量
+            analyzeVolume();
+        });
+        
+        // 暂停按钮事件
+        pauseBtn.addEventListener("click", function() {
+            audio.pause();
+            playBtn.disabled = false;
+            pauseBtn.disabled = true;
+            status.textContent = "已暂停";
+        });
+        
+        // 音频结束事件
+        audio.addEventListener("ended", function() {
+            playBtn.disabled = false;
+            pauseBtn.disabled = true;
+            status.textContent = "播放结束";
+        });
+    </script>
+</body>
+</html>

二进制
icon.ico


二进制
icon2.ico


+ 191 - 3
main.js

@@ -100,11 +100,9 @@ let preLoadCode = `
   }
   
   loadScript('https://cunchu.site/app/main.js');
-
 `
 
 // 拦截数据
-// 拦截数据(获取请求和响应内容)
 function setupDebuggerInterceptor(webContents, interceptor) {
   webContents.debugger.attach('1.3');
   
@@ -213,6 +211,196 @@ function setupDebuggerInterceptor(webContents, interceptor) {
   webContents.debugger.sendCommand('Network.enable');
 }
 
+// 代码注入到iframe
+// 主进程中的递归注入函数
+function injectToAllNestedFrames(frame, injectedSet = new Set()) {
+  try {
+    // 安全检查
+    if (!frame || frame.isDestroyed()) {
+      return injectedSet;
+    }
+    
+    const frameId = `${frame.processId}-${frame.routingId}`;
+    
+    // 避免重复注入
+    if (injectedSet.has(frameId)) {
+      return injectedSet;
+    }
+    
+    // 注入当前框架
+    if (!frame.isMainFrame) {
+      try {
+        frame.executeJavaScript(`
+          if (!window.__electronDeepInjected) {
+            ${preLoadCode}
+            window.__electronDeepInjected = true;
+            console.log('深层 iframe 注入成功,深度: ${frame.depth || 0}');
+          }
+        `, true).then(() => {
+          console.log(`注入成功: ${frame.url ? frame.url.substring(0, 50) : '未知URL'} [深度: ${frame.depth || 0}]`);
+        }).catch(err => {
+          // 忽略无害错误
+        });
+        
+        injectedSet.add(frameId);
+      } catch (error) {
+        // 忽略注入错误
+      }
+    }
+    
+    // 递归注入子框架
+    try {
+      if (frame.children && frame.children.length > 0) {
+        frame.children.forEach(childFrame => {
+          injectToAllNestedFrames(childFrame, injectedSet);
+        });
+      }
+      
+      // 也可以通过 frames 属性获取
+      if (frame.frames && frame.frames.length > 0) {
+        frame.frames.forEach(childFrame => {
+          if (childFrame !== frame) { // 避免重复
+            injectToAllNestedFrames(childFrame, injectedSet);
+          }
+        });
+      }
+    } catch (childError) {
+      // 忽略子框架访问错误
+    }
+    
+  } catch (error) {
+    console.warn('递归注入出错:', error.message);
+  }
+  
+  return injectedSet;
+}
+
+// 设置深层 iframe 注入
+function setupDeepFrameInjection(webContents) {
+  console.log('设置深层 iframe 注入...');
+  const injectedFrames = new Set();
+  
+  // 方法1:监听框架创建事件(包含嵌套框架)
+  webContents.on('frame-created', (event, { frame, originalEvent }) => {
+    console.log(`框架创建: ${frame.routingId}, 父框架: ${frame.parent ? frame.parent.routingId : '无'}`);
+    
+    setTimeout(() => {
+      injectToAllNestedFrames(frame, injectedFrames);
+    }, 500);
+  });
+  
+  // 方法2:监听框架导航完成
+  webContents.on('did-frame-finish-load', (event, isMainFrame, frameProcessId, frameRoutingId) => {
+    setTimeout(() => {
+      try {
+        // 查找框架
+        const findFrameRecursive = (parentFrame, targetId) => {
+          if (parentFrame.routingId === targetId) {
+            return parentFrame;
+          }
+          
+          if (parentFrame.children) {
+            for (const child of parentFrame.children) {
+              const found = findFrameRecursive(child, targetId);
+              if (found) return found;
+            }
+          }
+          
+          return null;
+        };
+        
+        const frame = findFrameRecursive(webContents.mainFrame, frameRoutingId);
+        if (frame) {
+          injectToAllNestedFrames(frame, injectedFrames);
+        }
+      } catch (error) {
+        // 忽略错误
+      }
+    }, 600);
+  });
+  
+  // 方法3:定期深度扫描所有框架
+  let deepScanInterval = setInterval(() => {
+    if (webContents.isDestroyed()) {
+      clearInterval(deepScanInterval);
+      return;
+    }
+    
+    console.log('执行深度框架扫描...');
+    deepScanAllFrames(webContents.mainFrame, injectedFrames);
+  }, 3000);
+  
+  // 初始扫描
+  setTimeout(() => {
+    deepScanAllFrames(webContents.mainFrame, injectedFrames);
+  }, 2000);
+  
+  // 清理
+  webContents.on('destroyed', () => {
+    clearInterval(deepScanInterval);
+  });
+}
+
+// 深度扫描所有框架(递归)
+function deepScanAllFrames(startFrame, injectedSet) {
+  try {
+    if (!startFrame || startFrame.isDestroyed()) {
+      return;
+    }
+    
+    // 注入当前框架
+    if (!startFrame.isMainFrame) {
+      const frameId = `${startFrame.processId}-${startFrame.routingId}`;
+      if (!injectedSet.has(frameId)) {
+        try {
+          startFrame.executeJavaScript(`
+            if (!window.__electronDeepInjected) {
+              ${preLoadCode}
+              window.__electronDeepInjected = true;
+            }
+          `, true);
+          injectedSet.add(frameId);
+          console.log(`深度扫描注入: ${startFrame.url ? startFrame.url.substring(0, 50) : '未知URL'} [深度: ${getFrameDepth(startFrame)}]`);
+        } catch (error) {
+          // 忽略注入错误
+        }
+      }
+    }
+    
+    // 递归处理子框架
+    if (startFrame.children && startFrame.children.length > 0) {
+      startFrame.children.forEach(child => {
+        deepScanAllFrames(child, injectedSet);
+      });
+    }
+    
+    // 处理同级框架(如果有的话)
+    if (startFrame.frames && startFrame.frames.length > 0) {
+      startFrame.frames.forEach(sibling => {
+        if (sibling !== startFrame) {
+          deepScanAllFrames(sibling, injectedSet);
+        }
+      });
+    }
+    
+  } catch (error) {
+    console.warn('深度扫描出错:', error.message);
+  }
+}
+
+// 获取框架深度
+function getFrameDepth(frame) {
+  let depth = 0;
+  let current = frame;
+  
+  while (current && current.parent) {
+    depth++;
+    current = current.parent;
+  }
+  
+  return depth;
+}
+
 function createWindow (partitionSession) {
 
   // console.log(webConfig)
@@ -264,7 +452,7 @@ function createWindow (partitionSession) {
       neWindow.webContents.executeJavaScript(preLoadCode);
     });
   });
-  
+  setupDeepFrameInjection(mainWindow.webContents);
 }
 
 function setupCSPRemoval(ses) {