How to pull URL from open web browser in MATLAB? - matlab

Need to pull URL from current web browser using Matlab. URL is a google maps URL that is constantly changing as the user moves around. Matlab code needs to be able to work in conjunction with the open google Chrome tab and pull the changing URL when the user specifies.
Not sure how to attack this - have tried using the web function but the google maps is running in Chrome, not the default matlab browser.
I’m trying to get away from my current method, which is copying and pasting the url from chrome into matlab every time there is a change.
Thanks in advance!

Related

TWA bases app sometime showing URL and sometime working, even Assetlink.json uploaded properly

I have website (https://www.kriscent.com/product/kart-supermarket/). I created PWA of that after that I uploaded it on Play store by using TWA(Trusted Web Activities), App URL is https://play.google.com/store/apps/details?id=in.kriscent.kartlite.
The URL of website always show in app, So I uploaded the assetlink.json (URL: https://www.kriscent.com/.well-known/assetlinks.json).
After uploading the assetlinks.json, When I run my app, the website URL disappeared but when I switched on other link in the app then the URL shows again.
I don,t know what is happening. Please help me if anybody has idea to resolve this issue.
enter image description here
enter image description here
The problem is that, when navigating to a product detail page, you are using a different origin than the one used to open the Trusted Web Activity and that doesn't have Digital Asset Links setup:
When the application is started, it opens https://www.kriscent.com/, which is correctly validated.
When clicking on a product, the user is take to https://kriscent.com/ (without www), which is a different origin, and is not validated in the Android app.
It is possible to get the Trusted Web Activity to work with multiple origins but, in this case, I'd recommend using a single origin for the initial URL and the navigations, as you will be able to take advantage of using the same service worker, browser storage, etc.

How to debug on Facebook Internal Browser (Mobile)?

I'm developing website with a lot of HTML5 and CSS3 features. I'm also using iframe to embed several content on my website. It works fine if I open it using Chrome/Firefox/Safari mobile browser. However, if I share on facebook (post/page) and I opened it up with Facebook application with Facebook Internal Browser, my website is messed up.
Is there any tools or way to debug on Facebook Browser? Thanks.
This is how you can do the debugging yourself. It's painful, but the only way I've come across so far.
tl;dr Get the Facebook App loading a page on your local server so you can iterate quickly. Then print debug statements directly to the page until you figure out what is going on.
Get a link to a page on your local server that you can access on your mobile device (test in mobile safari that it works). See this to find out your local IP address How do you access a website running on localhost from iPhone browser. It will look something like this
http://192.xxx.1.127:3000/facebook-test
Post that link on your Facebook page (you can make it private so your friends aren't all like WTF?)
Click the posted link in the Facebook mobile App and it will open up in Facebook's mobile browser
Since you don't have a console, you basically need to print debug statements directly to the page so it is visible. Put debug statements all over your code. If your problems are primarily related to CSS, then you can iteratively comment out stuff until you've found the issue(s) or print the relevant CSS attributes using JavaScript. Eg something like (using JQuery)
function debug(str){$('body').append("<br>"+str);}
Quite possibly the most painful part. The Facebook browser caches very aggressively. If you are making changes and nothing has happened, it's because the content is cached. You can sometimes resolve this by updating the URLs, eg /facebook-test-1, /facebook-test-2, or adding dummy parameters eg /facebook-test?dummy=1. But if the changes are in external css or js sheets it sometimes will still cache. To 100% clear the cache, delete the Facebook App from your mobile device and reinstall.
The internal browser the Facebook app uses is essentially a uiWebView. Paul Irish has made a simple iOS app that lets you load any URL into a uiWebView which you then can debug using Safari's Developer Tools.
https://github.com/paulirish/iOS-WebView-App
I found a way how to debug it easier. You will need to install the Ghostlab app (You have a 7-day free trial there, however it's totally worth paying for).
In Ghostlab, add the website address (or a localhost address) you want to debug and start the session.
Ghostlab will generate a link for access.
Copy that link and post it on Facebook (as a private post)
Open the link on mobile and that's it! Ghostlab will identify you once you open that link, and will allow you to debug the page.
For debugging, you will have all the same tools as in the Chrome devtools (how cool is that!). For example, you can tweak CSS and see the changes applied live.
If you want to debug a possible error, you can try to catch it and display it.
Put this at the very top of your code:
window.onerror = function (msg, url, lineNo, columnNo, error) {
var string = msg.toLowerCase();
var substring = "script error";
if (string.indexOf(substring) > -1){
alert('Script Error: See Browser Console for Detail');
} else {
var message = [
'Message: ' + msg,
'URL: ' + url,
'Line: ' + lineNo,
'Column: ' + columnNo,
'Error object: ' + JSON.stringify(error)
].join(' - ');
alert(message);
}
}
(Source: MDN)
This will catch and alert your errors.
Share a link on Facebook (privately), or send yourself a message on Facebook Messenger (easier). To break the cache, create a new URL every time, e.g. by appending a random string to the URL.
Follow the link and see if you can find any errors.
With help of ngrok create temporary http & https adress instead of your ordinary localhost:3000(or other port) and you could run your app on any devices. It is super easy to use.
and as it was written above all other useful information you should write somewhere inside div element (in case of React I recommend to put onClick on that div with force update or other function for getting info, sometimes it helps because JS in FB could be executed erlier than your information appears). Keep in mind that alerts are not reliable, sometimes they are blocked
bonus from ngrok that in console you will see which files was
requested and response code (it will replace lack of network tab)
and about iFrame.If you use it on other domain and you rely on cookies - you should know that facebook in-app browser blocks 3rd party cookies
test on Android and iOS separately because technicaly they use different browsers

Where, exactly channel url is used?

On what browsers or user agents that channel URL is actually used, and what for?
I have no intention of having my site to work on Internet Explorer <= 8 (it is an HTML5 <canvas> game, and I am serving everything else as "application/xhtml+xml").
So, if channel is only useful on that old crap, I can gladly get rid of it...
Related (possibly): Channel URL Facebook
Because the social plugin is cross domain call, it needs a way to communicate. The wrokaround is to include a hidden iframe in the page for that. But, with this workaround, that iframe is loaded every time when page loads and will double the traffic reported. This is why channel url was done. What it does, it load the fb js in that page, and from that moment on, the js is available on your domain.
It will improve your loading times (cache) and will fix the reporting issue (you will see in reports channel page reported separately). But is not necessary for any html5 capable browser.
So, if you are using only HTML5 capable browsers, you are safe to ignore that. I am not sure about ie9, I will try to test it with my app by removing channel url and let you know.
Edit: By removing the channel URL from my app, I start getting double traffic reports from IE9. I think that is a good idea to keep the file there, is is just a simple html file with a single line. Better to be safe than sorry.

Google Static Maps only shows map briefly after viewing it in a different browser tab

I'm building a rails app, and attempting to put multiple Google Static Maps into the view. These maps will always display broken-image placeholders, except it works when I:
-Use firebug to grab the src URL for the map image
-Paste the URL into another browser tab
-Refresh my apps page with the Google static maps
-I can then view a static map for the URL I pasted, but no others, and only for about 1 min.
Any map on the page I repeat this procedure for will then be viewable, for about 1 minute. Then after about 1 min, that map will revert to a broken image placeholder if I refresh the page.
An example URL from my app (without my API Key) is:
http://maps.googleapis.com/maps/api/staticmap?center=Paris%2C+France&zoom=13&size=600x300&maptype=roadmap&sensor=false&markers=color:blue|label:A|Paris%2C+France
Paste (or click) this into your browser, and you see it works. I paste this URL WITH my API key in it into my browser, it works & and my app will show the static map for a limited time, and then after that it will be broken again. If I paste a URL without my API key, this procedure doesn't work. It's like viewing the map in another browser tab somehow caches it momentarily in my browser, and it will then work in my app... but then it will break in a minute. Haven't found any other way to make map images viewable.
Any ideas why this would happen?
EDIT:
This is extremely strange. In an attempt to diagnose this, I did a copy/paste/save of the apps page source containing the broken map images, and put it on a remote server out in the World. In this new totally static page, I got the same result: I see broken placeholder images where the google map pic should be. But after I copy the src URL of the image & paste it in another browser tab, I can go back to the static page, refresh & only that map image appears.
Stranger still (maybe?), it shows up on my localhost app too. It also shows up on a static local copy/paste of the app page source I save as an HTML file.
So, not saying this must be it, but it seems to be a browser caching issue. No matter where the view page is represented, whether local or remote, and no whether it is dynamically generated or static HTML, the original behavior remains the same.
Maybe you are not considering that the referrer is the one who shows the static map. Check these examples:
Static map shown in https://developers.google.com/maps/documentation/static-maps/styling?hl=nl: the referrer is https://developers.google.com
You grab this link (that is already in the url of the URL on bullet 1) https://maps.googleapis.com/maps/api/staticmap?size=512x512&zoom=15&center=Brooklyn&style=feature:road.local%7Celement:geometry%7Ccolor:0x00ff00%7Cweight:1%7Cvisibility:on&style=feature:landscape%7Celement:geometry.fill%7Ccolor:0x000000%7Cvisibility:on&style=feature:administrative%7Celement:labels%7Cweight:3.9%7Cvisibility:on%7Cinverse_lightness:true&style=feature:poi%7Cvisibility:simplified&key=YOUR_API_KEY and you paste it in your browser: the referrer is YOUR PUBLIC IP.
So it's normal if the link does not work in any browser but it works in a determined web page. This happens when the authorized referrer is only the host of the web.
Consider also that you may be hitting the free limits of displays per day.

Link directly to Google Maps transit directions mobile site

If you visit maps.google.com on a mobile device, then press 'Menu', 'Get Directions', and select the 'transit' option, you are taken to a page where you can enter two locations and a date/time, and get directions on public transit. However, the URL is still maps.google.com.
Is there any way to link directly to this page so that I can load it in a UIWebView in my iOS app? Would 'clicking' the buttons in Javascript be (the only/a good) solution?
Try: http://www.google.com/transit
Even clicking the buttons in javascript doesn't seem to be working. The Google Maps code is a little strange- the event listeners aren't assigned directly and I can't get a .click() to work. So what I'll do is have the user enter the two locations in boxes in the app, then load something like http://maps.google.com/maps?f=d&source=s_d&saddr=Coover+Hall&daddr=lied+rec+center in the UIWebView, except I'll add some more specific location information before building the URL, since this is a city-specific app. Not a perfect solution but it gets the job done.
You could create a URL that links to the transit directions with the "dirflg=r" paramater.
Find the other URL parameters here: http://web.archive.org/web/20110714031648/http://mapki.com/wiki/Google_Map_Parameters