Intercept https requests for a single browser window only - electron

I have two browser windows open, on one window I want to intercept the https request and replace the page content. Currently I'm doing this using using protocol.interceptBufferProtocol and it is working how I want it, but the https requests are being intercepted on the second window and it seems to be causing issues with the page loading.
Is there a way to only intercept requests on a specific window or a way to return the default behavior of the request?
Thanks

Related

Completely replacing a request in a WebExtension

I'm looking to make a web extension for Firefox that stores HTML pages and other resources in local storage and serves them for offline viewing. To do that, I need to intercept requests that the browser makes for the pages and the content in them.
Problem is, I can't figure out how to do that. I've tried several approaches:
The webRequest API doesn't allow fulfilling a request entirely - it can only block or redirect a request, or edit the response after it's been done.
Service Workers can listen to the fetch event, which can do what I want, but calling navigator.serviceWorker.register in an addon page (the moz-extension://<id> domain) results in an error: DOMException: The operation is insecure. Relevant Firefox bug
I could possibly set up the service worker on a self hosted domain with a content script, but then it won't be completely offline.
Is there an API that I missed that can intercept requests from inside a web extension?

How to intercept http/https calls after original WkWebview call?

The iOS application we have has a WkWebview that tries to communicate with our server by calling a https endpoint. The server works similar to a proxy and all calls to our endpoint will then forward the request to the destination site. For example - in our app if we were to set our destination to https://www.google.com the application will translate that to https://server.com/http://www.google.com.
The problem we are trying to solve is the interception of all http/https calls after the original WkWebview call. This includes all resource calls like css and javascript files. We have tried to use a custom scheme handler but since we do not parse the html/css on the server side we cannot add a custom scheme to intercept all http/https calls.
You can add the interception logic inside the webview for example every request store url and current number of calls inside a hidden element , and check it's value periodically by evaluteJavaScript function of the webview for that element

HTTP Redirect on a browser without showing intermediate window

I have two servers someserver.com and anotherserver.com
What I need is when a user clicks on someserver.com he or she will be redirected to anotherserver.com
Currently when I do a redirect programatically on the server (ASP.NET MVC IIS)
what a user see is: 1) someserver.com is loaded 2)anotherserver.com is loaded.
What i want is when a user clicks on someserver.com he sees only anotherserver.com in his browser.
Does http protocol allow it?
Thanks!
There are a bunch of approaches to this but the simplest one of you own the domain is to just use domain forwarding st the dns level. Then it won't involve your web server at all. Otherwise, the browser will always have to load the first site, if only briefly, before loading the second one. You can optimize this by just sending a redirect, which should be barely noticeable. Another option would be client-side JavaScript, but if you know on the client that you want to go to the new URL, you could just use a standard hyperlink to it at that point (so I assume this is not an option).

HTTP Request without touching the browser

I want to send a HTTP request for the server to save a record from the browser. However I'd like the browser to not have to change pages/reload its content (as many of the solutions I've searched for suggested). Right now I'm using a pop up that performs the action then closing itself, but I'm looking for a better solution. Using rails 4.1.1

YouTube embed/API player redirects from HTTP -> HTTPS, API is inaccessible

When I attempt to load an embedded video onto my page, using the following:
<embed src="http://www.youtube.com/v/BzC135ql_wA?version=3&enablejsapi=1"></embed>
the request is automatically redirected from HTTP to HTTPS- as a result the API is inaccessible, because of browser security limitations.
This appears to be related to my Google account, as it doesn't redirect if I try from an incognito window. However, this worries me- some users of my site won't be able to use the page as I intended, and as far as I can see I will have no way of knowing.
Is there any way to force HTTP, or anything else I can do here, short of hosting my own site on HTTPS?
There are a number of browser extensions that automatically translate http:// URLs into https:// for a specific set of domains. I'd imagine that you're using one such extension, which would explain why you don't see that behavior in an Incognito window. I can't tell you which extension you might be using—I know that HTTPS Everywhere is popular on Firefox, but not sure which are commonly used on Chrome—but take a look at chrome://extensions/ for any likely culprits.

Resources