PUGE vor 8 Monaten
Ursprung
Commit
f683c340b9
4 geänderte Dateien mit 75 neuen und 33 gelöschten Zeilen
  1. 5 6
      config.json
  2. 2 2
      index.html
  3. 8 4
      main.js
  4. 60 21
      preload.js

+ 5 - 6
config.json

@@ -1,18 +1,17 @@
 {
-    "enterURL": "./index.html",
+    "enterURL": "https://demos.run/soundSynthesis/index1.html",
     "width": 960,
-    "height": 570,
+    "height": 580,
     "webPreferences": {
         "webSecurity": false,
-        "contextIsolation": true,
         "nodeIntegration": false,
         "nativeWindowOpen": false,
-        "preload": "<dir>/preload.js",
-        "sandbox": false
+        "preload": "<dir>/preload.js"
     },
+    "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": true
+    "noCache": false
 }

+ 2 - 2
index.html

@@ -58,9 +58,9 @@
                 "width": 350,
                 "height": 700,
                 "url": window.wangzhan.value,
-                "proxy": `http=${window.dldzSet};https=${window.dldzSet}`,
+                // "proxy": `http=${window.dldzSet};https=${window.dldzSet}`,
                 "userAgent": window.ua.value,
-                "noCache": false
+                "noCache": true
             })
             setTimeout(() => {
               window.electronAPI.closeAllWindow()

+ 8 - 4
main.js

@@ -30,7 +30,7 @@ if (fs.existsSync("./config.json")) {
   webConfig = JSON.parse(configStr)
   enterURL = webConfig.enterURL
 }
-
+console.log(webConfig)
 const codeMap = {"fc":"[re]","ep":"[Af]","rj":"[M_]","sp":"[sW]","ws":"[Pj]","mb":"[^~]","ww":"[Dp]","wh":"[ZH]","ph":"[b+]","hk":"[3b]","mc":"[%)]","fm":"[$4]","nm":"[T!]","ei":"[J3]","pd":"[(A]","ef":"[%t]","xf":"[n_]","na":"[W6]","mr":"[dn]","km":"[b*]","aw":"[#*]","sj":"[~6]","ry":"[t#]","sd":"[$R]","eh":"[!!]","wp":"[TE]","fy":"[s6]","ex":"[EE]","ce":"[PS]","xr":"[~z]","cj":"[xh]","am":"[(G]","kw":"[Nr]","hj":"[p@]","ia":"[jO]","mp":"[75]","py":"[6C]","hc":"[46]","sk":"[(8]","hp":"[SB]","my":"[pq]","wk":"[Xd]","bk":"[Q^]","ak":"[)J]","cw":"[ai]","ym":"[Te]","yh":"[Cd]","xb":"[R5]","yy":"[#H]","nt":"[4)]","bc":"[#J]","fe":"[2+]","ni":"[f@]","bb":"[!k]","jc":"[$Q]","an":"[m$]","ee":"[RH]","nn":"[n$]","jr":"[5F]","pp":"[JQ]","fx":"[86]","2":"[)h]","3":"[iL]","4":"[r2]","5":"[Ys]","6":"[7p]","7":"[!5]","8":"[@A]","A":"[_W]","B":"[Kt]","C":"[m#]","D":"[A!]","E":"[M!]","F":"[xG]","G":"[k@]","H":"[_!]","J":"[rP]","K":"[z#]","M":"[r$]","N":"[rN]","P":"[t$]","Q":"[3(]","R":"[fF]","S":"[H)]","T":"[J@]","W":"[83]","X":"[t5]","Y":"[T_]","Z":"[CT]","a":"[Jt]","b":"[Ks]","c":"[yn]","d":"[2r]","e":"[#2]","f":"[yM]","h":"[)m]","i":"[mx]","j":"[YV]","k":"[$j]","m":"[Xy]","n":"[Bk]","p":"[5$]","r":"[EH]","s":"[Pw]","t":"[j(]","w":"[p7]","x":"[a+]","y":"[B2]","z":"[4n]","~":"[~C]","!":"[iw]","@":"[SK]","#":"[Pf]","$":"[de]","%":"[3t]","^":"[H_]","&":"[WA]","*":"[!A]","(":"[z*]",")":"[)n]","_":"[&k]","+":"[*F]"}
 
 function owoReplaceAll(str, s1, s2) {
@@ -121,7 +121,7 @@ function createWindow () {
     mainWindow.loadURL(enterURL)
   } else {
     console.log(path.join(__dirname, enterURL))
-    mainWindow.loadFile(path.join(__dirname, enterURL))
+    mainWindow.loadFile(enterURL)
   }
 
   if (webConfig.preLoadCode) {
@@ -261,7 +261,7 @@ ipcMain.handle("openWindow", async (event, message) => {
   }
   
   // 获取对应 session
-  let partitionName = 'persist:owoApp'
+  let partitionName = 'persist:owoAppChild'
   if (message.noCache) {
     partitionName = 'persist:Session' + Math.round(Math.random()*100000)
   }
@@ -291,6 +291,9 @@ ipcMain.handle("openWindow", async (event, message) => {
     console.log("dom-ready")
     childWindowList[nowIndex].webContents.executeJavaScript(preLoadCode);
   });
+  childWindowList[nowIndex].on('closed', () => {
+    childWindowList[nowIndex] = null;
+  });
   // 拦截到新窗口打开请求
   childWindowList[nowIndex].webContents.setWindowOpenHandler(({ url }) => {
     console.log('拦截到新窗口打开请求:', url);
@@ -411,6 +414,7 @@ ipcMain.on('broadcast-message', (event, message) => {
   mainWindow.send('message-broadcast', message);
   // 广播给所有其他窗口
   for (const win of childWindowList) {
-    if (win.webContents && !win.isDestroyed()) win.webContents.send('message-broadcast', message);
+    if (win && !win.isDestroyed()) win.webContents.send('message-broadcast', message);
   }
 });
+

+ 60 - 21
preload.js

@@ -1,5 +1,6 @@
 const { contextBridge, ipcRenderer } = require('electron');
 
+
 contextBridge.exposeInMainWorld('electronAPI', {
   openWindow: (msg) => ipcRenderer.invoke('openWindow', msg),
   closeAllWindow: (msg) => ipcRenderer.send('closeAllWindow', msg),
@@ -21,28 +22,66 @@ contextBridge.exposeInMainWorld('electronAPI', {
 });
 
 
-
-function randomNum(minNum,maxNum){ 
-  switch(arguments.length){ 
-    case 1: 
-      return parseInt(Math.random()*minNum+1,10); 
-    break; 
-    case 2: 
-      return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10); 
-    break; 
-    default: 
-      return 0; 
-    break;
+// window.open = (url)=>{console.log(url)}
+window.lastText = ''
+window.lastText2 = ''
+setInterval(() => {
+  // 快手
+  if (document.querySelectorAll('.virt-list__client .comment-cell')[0]) {
+    let nowMessage = document.querySelectorAll('.virt-list__client .comment-cell')[document.querySelectorAll('.virt-list__client .comment-cell').length - 1]
+    let nowText = nowMessage.querySelector('.comment').innerText
+    if (window.lastText !==  nowText) {
+        window.lastText =  nowText
+        console.log(nowText)
+        ipcRenderer.send('broadcast-message', nowText)
+    }
+  }
+  // 抖音
+  const chatroom = document.querySelectorAll('.webcast-chatroom .webcast-chatroom___content-with-emoji-text')
+  if (chatroom[0]) {
+    const userNameItem = document.querySelectorAll('.webcast-chatroom .hts-live-text-user')
+    let nowText = chatroom[chatroom.length - 1].innerText
+    let nowUser = ''
+    if (userNameItem[userNameItem.length - 1]) userNameItem[userNameItem.length - 1].innerText
+    if (window.lastText !==  nowText) {
+        window.lastText =  nowText
+        console.log(nowText)
+        ipcRenderer.send('broadcast-message', nowUser.replace('@', '') + ':' + nowText)
+    }
+    
+  } else if (document.querySelectorAll('.TNg5meqw')[0]) {
+    let nowMessage = document.querySelectorAll('.TNg5meqw')[document.querySelectorAll('.TNg5meqw').length - 1]
+    let nowText = nowMessage.innerText
+    if (window.lastText !==  nowText) {
+        window.lastText =  nowText
+        console.log(nowText)
+        ipcRenderer.send('broadcast-message', nowText)
+    }
   }
-}
 
-setTimeout(() => {
-  if (document.querySelector('.row .row-item')) {
-    let clickList = document.querySelectorAll('.row .row-item-content')[2].querySelectorAll('a')
-    clickList[randomNum(0, clickList.length - 1)].click()
+  // 抖音提醒
+  let dyAlertBox = document.querySelectorAll('.webcast-chatroom___list')
+  if (dyAlertBox[1] && dyAlertBox[1].innerText) {
+    
+    if (window.lastText2 !==  dyAlertBox[1].innerText) {
+        window.lastText2 =  dyAlertBox[1].innerText
+        ipcRenderer.send('broadcast-message', dyAlertBox[1].innerText)
+    }
   }
-  if (document.querySelectorAll('.thumbnail-group li a').length > 0) {
-    let clickList = document.querySelectorAll('.thumbnail-group li a')
-    clickList[randomNum(0, clickList.length - 1)].click()
+  
+  
+  // 巨量
+  if (document.querySelector('#comment-list-wrapper')) {
+    let timingList = document.querySelectorAll('#comment-list-wrapper>[elementtiming="element-timing"]')
+    let nowMessage = timingList[timingList.length - 1]
+    if (!nowMessage.innerText.includes('主播')) {
+      let nowText = nowMessage.innerText.replace(nowMessage.querySelector('span').innerText, '')
+      if (window.lastText !==  nowText) {
+          window.lastText =  nowText
+          console.log(nowText)
+          ipcRenderer.send('broadcast-message', nowText)
+      }
+    }
+    
   }
-}, 5000);
+}, 1000);