i am new to electron js and i created a simple app that opens whatsapp web.
First it works perfectly but i dont have chromium at that time. Then i use electron forge so i created a new app with the same code and i have chromium this time.
But the output varies
link for the code is here => https://github.com/gowtham758550/WA-opener
Is chrome needed or chromium is ok for running a electron app
i am a beginner help me to solve this
You need to change the user-agent.
A user-agent is just a string that Whatsapp uses to detect what OS and browser you're coming from. Currently the user-agent looks like this:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) wa-opener/1.0.0 Chrome/89.0.4389.90 Electron/12.0.2 Safari/537.36
Notice how Electron adds wa-opener/1.0.0?
Taking wa-opener/1.0.0 out of the user-agent fixes it.
We can change the user-agent with this code:
var session = require('electron').session;
session.defaultSession.webRequest.onBeforeSendHeaders(function (detailsObj, callbackFunc) {
detailsObj.requestHeaders['User-Agent'] = detailsObj.requestHeaders['User-Agent'].replace(/wa-opener\/[.0-9]+ /, '');
callbackFunc({requestHeaders: detailsObj.requestHeaders});
});
That'll take wa-opener/1.0.0 out of the user-agent and voila!
Related
I have created a custom browser with a webview tag.
When i navigate in google.it (or google.com), sometimes appears a message with say that chrome is obsolete.
My app versions are :
Node.js 8.9.3
Chromium 61.0.3163.100
Electron 2.0.2
attached an image of the alert (sorry but it is in Italian)
Is It possible to remove this warning?
Thanks
Jempis
the warning
EDIT
I found a workaround for remove the warning:
i set the option
useragent
a different of chrome, for example
"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:58.0) Gecko/20100101 Firefox/58.0"
And the warning doesn't appear
Electron is not intended as Browser, it's for using web technology in desktop apps. Due to that, it does not always use the newest Chrome engine version.
The warning is shown by Google (the website). You could modify the user agent header to pretend a newer Chome engine version or an other Browser, see https://electronjs.org/docs/api/webview-tag.
<webview src="https://www.github.com/" useragent="Mozilla/5.0 (Windows NT 10.0; WOW64; rv:58.0) Gecko/20100101 Firefox/58.0"></webview>
However, that won't fix the problem of delayed security updates.
I am downloading webpage and storing it through may app; so that I can access it offline through my app. I am loading that webpage (.html) in UIWebView. I am playing audio or video on click. If that webpage contains video then it plays fine on all devices (iPhones, and iPads). But when I access a webpage which has audio in it; then that audio is played successfully on iPhone; but on iPad (on device and simulator as well) it does not play audio file in UIWebView. How can I do this ?
NSString *userAgentString = #"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36";
NSDictionary *dictionnary = [[NSDictionary alloc] initWithObjectsAndKeys:userAgentString,#"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionnary];
Add This Code While you load request to your web view..
It will be better if you add your code.
Update:
Try the below code:
webView.scalesPageToFit = YES;
Add this !
If ur web view frame is whole screen.
Then Try the below code:
webView.frame=self.view.bounds;
#Vicky_Vignesh your answer was partially right (Anyways thanks for providing foundation). You need to provide device type and OS version with UserAgent string. I have done this way:
NSString *userAgentString = #"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1";
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:userAgentString,#"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
I have a page in my app that displays a WKWebView. It looks great on iPhone, but doesn't look so good on iPad.
On iPad, the page is too big and gets cut off, so you have to scroll horizontally. That doesn't look good, and it doesn't work well since this is in a page view controller. I want everything to fit on the page. Is there a way to load the iPhone version of the page, even on iPad? Or is there another solution I can use?
To load iPhone version of site on iPad, you need to change user agent of your web view. First, you need to find appropriate user agent value. Go to www.whatismyuseragent.net from your iPhone. After that, change WKWebView user agent:
webView.customUserAgent = #"Mozilla/5.0 (iPhone; CPU iPhone OS 8_0_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12A366 Safari/600.1.4";
Of course, in real world you will only need to replace occurrences of "iPad" with "iPhone" in your user agent. Something like:
[webView evaluateJavaScript:#"navigator.userAgent" completionHandler:^(id __nullable userAgent, NSError * __nullable error) {
webView.customUserAgent = [userAgent stringByReplacingOccurrencesOfString:#"iPad" withString:#"iPhone"];
// Start actual site loading.
}
Obviously, you need to do that before loading actual web page.
Is it possible to download an app from Apple app store programmatically without using iTunes?
I have tried Wireshark to catch packets while downloading an app in iTunes from my iPhone. In the trace, I've got a HTTP packet which revealed the URL of the app I downloaded.
That is: http://a558.phobos.apple.com/us/r1000/049/Purple/v4/d1/8f/93/d18f931b-f90c-6830-236f-1be569e3c9ee/mzps4099439710744129538.D2.dpkg.ipa
However, when I used Wget to download from this URL, it turned out to be 403 Forbidden.
The reason why I asked for help is that there are some "smart routers" which claimed to accelerate downloading from the app store, and I want to download some apps to test the real downloading speed and verify it. However, I do not want to click every download from the iTunes. I have my own Apple account and I will only download free apps.
Don't forget other headers like 'user-agent' and cookie:
wget --header='User-Agent: iTunes/12.1.1 (Windows; Microsoft Windows 7 x64 Business Edition Service Pack 1 (Build 7601); x64) AppleWebKit/7600.1017.9000.2' --header='Accept: /' --header='Cookie: downloadKey=expires=1426914268~access=/us/r1000/131/Purple3/v4/f8/f8/c5/f8f8c50a-90fc-f62f-af89-796bf89111c6/gbp3951770696681909972.D2.pd.ipa*~md5=11e28a91dbf5454de97148d90fce5386' 'http://a1834.phobos.apple.com/us/r1000/131/Purple3/v4/f8/f8/c5/f8f8c50a-90fc-f62f-af89-796bf89111c6/gbp3951770696681909972.D2.pd.ipa'
I'm trying to create an offline version of a test web app.
This far it had been working perfectly on Chrome and Firefox where I do most of my tests. Meaning I can go to the page, the console is all good, and then when I unplug my ethernet cable (I'm hardcore like that) I can see still all of my page content in browser and in chrome://appcache-internals
Problems arise when I try to test it on the iPad, I go to my webpage, but then when going into Airplane mode it refuses to access the page saying I need an internet connection. So I decided to test on Safari (mac) which is the closest I have, and I do see an error in the console on the cache.manifest mime-type : Application Cache manifest had an incorrect MIME type: text/plain.
Problem is, I do have a .htaccess and it does specify AddType text/cache-manifest appcache manifest, but no. Even when I use a web sniffer on my cache.manifest file it comes out as text/plain, which I think might be the reason it's not getting read on the iPad/Safari.
Anyone can help me on this thing ? I'm completely stuck right now.
add to your manifest file NETWORK and FALLBACK blocks so it will look like this:
CACHE MANIFEST
# Version 1.0
NETWORK:
*
CACHE:
index.html
FALLBACK:
Check if you have Private Browsing enabled in Safari on your iPad:
Settings -> Safari -> Private Browsing
If it is enabled, disable it. When Private Browsing is enabled all cookies and other caching is disabled.
I had a similar problem. My app worked fine with internet disconnected both on Safari and Firefox running on the iMac and even on the iPhone in airplane mode. But when I tried to load it on the iPad in Airplane mode it just wouldn't work. When I turned off Private Browsing it worked! Still got the notice about turning off Aerplane Mode though. But it was possible to browse the App.