You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/01/10 12:14:59 UTC

[GitHub] jacobg edited a comment on issue #372: OverrideUserAgent changes user agent for Cordova view too

jacobg edited a comment on issue #372: OverrideUserAgent changes user agent for Cordova view too
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/372#issuecomment-453075475
 
 
   In case anyone is interested, I wrote a script that patches the plugin in my build, as follows:
   
   `patchInAppBrowser.js`
   ```
   var replace = require("replace");
   var path = require("path");
   
   // Patch for these issues, on top of git master:
   //    https://issues.apache.org/jira/projects/CB/issues/CB-13990
   // Until a new version is published to npm with the fixes
   
   module.exports = function(context) {
   
   	var iosFile = path.resolve(context.opts.projectRoot + "/platforms/ios/Fareclock/Plugins/cordova-plugin-inappbrowser", "CDVUIInAppBrowser.m");
   
   	var filesToPatch = [
   		iosFile,
   		path.resolve(context.opts.projectRoot + "/platforms/android/app/src/main/java/org/apache/cordova/inappbrowser", "InAppBrowser.java")
   	];
   
   	replace({
   	    regex: "\"OverrideUserAgent\"",
   	    replacement: "\"InAppBrowserOverrideUserAgent\"",
   	    paths: filesToPatch,
   	    recursive: false,
   	    silent: true,
   	});
   };
   ```
   
   And in `config.xml`, add this line:
   ```
   <hook src="build/patchInAppBrowser.js" type="after_prepare" />
   ```
   
   Then you set `InAppBrowserOverrideUserAgent` preference in config.xml like this:
   ```
   <preference name="InAppBrowserOverrideUserAgent" value="Mozilla/5.0" />
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org