How to programatically access current website status code in JS (chrome extension)? - javascript

I am building a chrome extension in which I need to collect the status code (200, 404, 401 etc.) of different websites that the user visits.
I am unable to find any library in chrome api to this, how can this be done?

Related

Find HTTP Request Initiator Line In Internet Explorer Developer Tools

I'm getting some odd behavior when my page is loaded in Internet Explorer 11. When my page loads in IE 11 and I watch the Network Tab of the Developer Tools I see a HTTP Get request to the base URL of the page. By base URL I mean the URL without any parameters. This is causing a 500 Internal Server Error to get fired because the Action on the other side of the Request doesn't accept no Parameters. I use Elmah to send me a mail for any unhandled exceptions so whenever a user is using IE I get a ton of Error notifications. This is only happening in IE. Both Firefox and Chrome work as expected. Also, this doesn't seem to break the page in anyway. I only know about this error because of the Emails I'm getting. No User has reported an issue when using IE 11.
Short of searching through every line of Javascript code both 3rd party and my own is there a way in Internet Explorer Developer Tools or even another 3rd party tool that will tell me the exact line (or even js file) that initiated the Http Get Request similar to Chrome's Development Tools?
Here are some images showing the call I'm talking about. The blacked out portion is my API Key.
The original Url being called in the below examples is http://localhost:44301/Grower/Profile/28
The first image is of the Internet Explorer 11 Development Tools with the offending Http Get Request highlighted.
Next is a Fiddler Screenshot of the same request highlighted.
And finally the Chrome Developer Tools showing no such call happening.
I think there's no such a way in IE dev tools to find the initiator line of HTTP request.
But in my research, I find that we can get the file path of the HTTP request initialed using Fiddler. We can find the file path in Inspectors -> Raw -> Referer:
The file path in Referer in Fiddler is exactly the path in Initiator in Network tab in Chrome. So you could try to check the file path using Fiddler.

Capture network access from a javascript web application

I have a web application running in my browser. It is third party obfuscated javascript. It connects to the server with SSL and it fetches data and then displays it in the browser. I want to get programmatic access to the data, but I cannot figure out how it gets it from the server.
I tried to open Chrome Canary Dev Tools, but it does not show any network access (other than loading some html, js code and images). I ran wireshark and it shows lots of network access (all encrypted, so it is useless). What gives? This javascript app seems to be able to fetch data in a sneaky way, so that Chrome Dev Tools doesn't show it.
Any advice how I can reverse engineer this?
EDIT: I think that the data is fetched by redirecting to a download link, or perhaps with window.navigator.msSaveBlob. Anyway, I found it using postman.
I was able to capture the API call using POSTMAN (native Win 6.0.9). I enabled a Proxy on port 5555, and then click the button to trigger the action in the web app.
Because the web is using SSL, I get an error "Your connection is not private". However, I can click Advanced / Continue and call the API anyway, which gets captured by POSTMAN.
Advice: In postman, capture to a new folder (called Proxy data). Try it first using a non-SSL site, such as this one.

Tracking Chrome Console Error - Failed to load resource: net::ERR_CONNECTION_CLOSED

When I visit my own WordPress based website sometimes I am seeing the following error message in Chrome console panel.
Failed to load resource: net::ERR_CONNECTION_CLOSED
Screenshot
As a result the main CSS file is not loading and the website looks messy. Still I can not find the reason but currently I have a very slow internet connection.
However, I want to know whether this is happening for my website visitors as well.
My question is, is there any solution to log this error message displayed in Chrome console panel using Google Analytics or any other error logging tool so that I can analyse how many visitors are seeing the same error?
Thank you.
There are a lot of tools to monitor servers status.
but to install them you need SSH access to your host server - this access is depend on your web-hosting company...
without any more details about your hosting plan i can guess that if you have low and cheap hosting plan - 1 shared CPU and 1 giga RAM - it not good enough for wordpress because wordpress need some moer resources.... and your visitors also see this error somtime - just like you...

Mobile App Authentication/Sencha Touch

I'm trying to write an app using Sencha Touch that ultimately targets iOS and Android. It's supposed to log into the corporate web server and then retrieve and parse some JSON data. It should be very simple. However I'm very new to both Sencha and Javascript, so I'm having a hard time doing this sort of client-side authentication. I can't even seem to make it authenticate from a web browser on my dev machine.
I used this link to help create my login page:
http://miamicoder.com/2012/adding-a-login-screen-to-a-sencha-touch-application/
But when I attempt to log in I seem to get the following error message and a null object:
XMLHttpRequest cannot load https://www.server.com/index.html?=_dc1234567890123
Origin http://localhost:8000 is not allowed by Access-Control-Allow-Origin.
Does anyone have any advice or good resources on getting this app to log in? Any help would be greatly appreciated!
Steve, the "is not allowed" error is returned because your login request violates the browser's same-origin policy (essentially it states that all XhrHttpRequests must go to the same domain the page was initially loaded from).
Some browsers offer ways of disabling this error temporarily (which might be fine for short-term development purposes), but for the long-term you'll either need to host your application in the same domain as your backend server, or look into using CORS or JSONP for your requests.
Your AJAX request violates the Same-Origin-Policy. That's why you are getting the error message. If you are using chrome for debugging u can disable the cross-domain Javascript security by doing the following :
For Windows:
1) Create a shortcut to Chrome on your desktop. Right-click on the shortcut and choose Properties, then switch to “Shortcut” tab.
2) In the “Target” field, append the following: –args –disable-web-security
For Mac, Open a terminal window and run this from command-line:
open ~/Applications/Google\ Chrome.app/ –args –disable-web-security
For Ubuntu, Open a terminal window and run this form command line:
open /usr/bin/ and execute ./google-chrome --disable-web-security
There is extension for chrome that does the work:
‪Allow-Control-Allow-Origin.
If you want to active it when the browser started, you have to press on the icon.

Facebook App is not working in Chrome but well in Firefox

I have just started making Facebook Apps using heroku. I made a test app. I uploaded a page on heroku which uses HTML5, CSS and Javascript. The app is not showing in Google Chrome https://apps.facebook.com/shrytestapp/ but works well in Mozilla Firefox. Also, the page works well when opened in heroku server http://salty-shelf-6707.herokuapp.com/.
When you access the app within Facebook, HTTPS is used to transfer the data, but Chrome has blocked content delivered over normal HTTP as a result and insists that everything be transfered securely whereas Firefox isn't so fussy.
Here's what the Console is showing in Chrome
[blocked] The page at https://salty-shelf-6707.herokuapp.com/
ran insecure content from http://www.google.com/jsapi.
Uncaught ReferenceError: google is not defined
Google's JS API has been blocked and the JavaScript fails to run.
(You also have some not found errors, but that's unrelated)
The app works fine through the http://salty-shelf-6707.herokuapp.com/ as you mentioned, but not through https://salty-shelf-6707.herokuapp.com/
Try using the following instead to load the API
<script type="text/javascript" src="//www.google.com/jsapi"></script>
the // at the start of the src value will make the url protocol-relative or for the correct technical term, scheme-relative.
Paul Irish, the lead developer of HTML5 Boilerplate, has more information about this in a post on his site.

Categories