Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to monitor all network traffic in a Safari Extension?

Since the newer versions of Safari (I'm running version 5.2) seem to have removed the "Activity" viewer from the "Window" menu, I would like to write an extension to have this feature back. However, in order to do that I think that I will need to be able to see what URLs are being requested in that window/tab. For Chrome, there is a "webRequest" API that does this, but I can't seem to find what I'm looking for to do this in Safari. Would someone please tell me if this is possible, and if so, where should I look next? Thanks in advance.

So far, the most I've been able to get is using an injected start script like the one below:

function trackRequests() {
    console.log(event.timeStamp + ": " + event.type, event.url, event);
}
document.addEventListener("beforeload", trackRequests, true);

However, this does not provide enough for the features I'll need for this. For example, if a URL is specified without a protocol e.g. "//example.com/file.txt" that is all this handlers sees; it doesn't know what actual protocol was used or if the request was allowed.

It appears that some people on the Apple discussion forums, MacDailyNews, and ArsTechnica have expressed a desire to have this feature back in Safari as well. Here's a link to another discussion on MacRumors.com and another.

like image 477
jacobq Avatar asked Jul 19 '12 19:07

jacobq


People also ask

How can I monitor my whole network traffic?

The best way to check network traffic is with a tool like SolarWinds® Bandwidth Analyzer Pack (BAP). BAP is built to automatically check and compile network traffic insights from devices across your network in a centralized dashboard and alert you to any concerning behavior in your network.

How can I monitor network activity on my Iphone?

Inside the 'App Privacy Report' screen, scroll down and look for the App Network Activity section. Inside this section, you'll see apps that were in contact with domains in the past week. If there are a bunch of apps that accessed domains, you can tap on 'Show All'. Now, the 'App Network Activity' screen will open.

How do I monitor Bandwidth on my Mac?

In the Activity Monitor app on your Mac, choose View > Dock Icon > Show Network Usage.


1 Answers

On windows I would use Fiddler but since you appear to be using a Mac here are some alternatives:

http://alternativeto.net/software/fiddler/?platform=mac

Hope this helps!

Cheers!

like image 71
Jos Avatar answered Nov 07 '22 04:11

Jos