久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

電子操縱/攔截 WebView 請求和響應

Electron Manipulate/Intercept WebView Requests and Responses(電子操縱/攔截 WebView 請求和響應)
本文介紹了電子操縱/攔截 WebView 請求和響應的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想創建一個使用 webview 來顯示第 3 方內容的 Electron 應用.

I want to create an Electron app that will use webview to display 3rd party content.

我希望能夠攔截來自此 web 視圖的所有請求和響應.有時我想操縱這些內容,有時我想記錄它,有時我什么都不做.

I would like to be able to intercept all requests and responses from this webview. Sometimes I would like to manipulate this content, other times I would like to log it, and other times I’d like to do nothing.

作為響應的一個示例,也許 Web 服務器會使用 TypeScript 代碼進行響應,也許我想獲取該響應,并將其編譯為標準 JavaScript.

As one example for the responses, maybe a web server will respond with TypeScript code, maybe I want to take that response, and compile it to standard JavaScript.

我查看了 此頁面,但看起來只能取消請求和操作標頭.WebRequest API 看起來不適合我的用例的需求,因為它只允許對請求和響應的操作非常細微.

I have looked into this page but it looks like it is only possible to cancel requests, and manipulate the headers. The WebRequest API doesn't look to fit the needs of my use case since it only allows very minor manipulations of requests and responses.

我也考慮過設置一些可以充當代理的網絡服務器,但我對此感到擔憂.我想維護用戶隱私,并且我想確保托管第 3 方內容的 Web 服務器看起來請求來自類似瀏覽器的環境(例如 Electron webview)而不是服務器.我知道我可以使用我發送的標頭等操作請求,但是整個解決方案變得更加復雜,然后我想,但可能是唯一的選擇.

I have also considered setting up some time of web server that can act as a proxy, but I have concerns about that. I want to maintain user privacy, and I want to ensure that to the web servers that host the 3rd party content it looks like the request is coming from a browser like environment (ex. Electron webview) instead of a server. I know I can manipulate requests with the headers I send and such, but this whole solution is getting to be a lot more complicated, then I would like, but might be the only option.

有沒有更好的方法來實現這一點,并且可以更好地控制 Electron webview?

Any better ways to achieve this, and have more control over the Electron webview?

推薦答案

我認為你應該研究一下協議API.它在內部充當代理.假設您希望用戶打開 http://www.google.com 并查看像 youve been conned! 這樣的內容.

I think you should look into The Protocol API. it works as a proxy internally. say you wanna the user open http://www.google.com and see content like you've been conned!.

const { protocol } = require("electron");

const content = new Buffer("you've been conned!");

protocol.interceptBufferProtocol("http", (request, result) => {
  if (request.url === "http://www.google.com")
    return result(content);
  ... // fetch other http protocol content and return to the electron
});

與 WebRequest API 相比,還有很多工作要做.但它比獨立的本地代理要簡單得多.

there's lots of work to do, comparing to the WebRequest API. but it's much simpler than a independent local proxy.

這篇關于電子操縱/攔截 WebView 請求和響應的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 在线免费国产 | 日韩精品一区二区三区 | 午夜影院网站 | 免费视频二区 | 久久不卡 | 婷婷综合网 | 精品乱码一区二区三四区视频 | 久久性av| 在线成人精品视频 | 成人精品鲁一区一区二区 | 免费看一区二区三区 | 成人黄色三级毛片 | 久久小视频 | 精品国产乱码久久久久久88av | 国产日产久久高清欧美一区 | 久久久久久国产精品mv | 国产精久久久久久久妇剪断 | 在线免费看毛片 | 国产精品久久久久影院色老大 | 亚洲系列第一页 | 九九久久久 | 青青草视频网站 | 国产区精品在线观看 | 少妇黄色 | 男人阁久久| 久久精品视频播放 | 波多野吉衣久久 | 在线观看国产wwwa级羞羞视频 | 欧美精品在线一区二区三区 | 亚洲日韩中文字幕一区 | 精品99爱视频在线观看 | 黄网站免费在线 | 国产精品视频免费看 | 欧美国产精品一区二区三区 | 日日操日日舔 | 国产精品成人一区二区三区吃奶 | 国产欧美一区二区三区在线看 | 亚洲一区电影 | 97av在线| 成人在线免费观看视频 | 天堂男人av |