I am a big fan and regular user of RescueTime, the time tracking application.
The service requires you to install a small program that runs in the background and keeps track of which programs and pages have focus at any given time.
Additionally, it lets you "Get Focused", which redirects all sites in a blacklist to their homepage, no matter which开发者_开发技巧 browser I use. That is, I see the homepage I visit, and am then redirected shortly after.
How is this block/redirect work? it seems to be browser independent, and I don't see any changes to my proxy settings, so it's not intercepting traffic that way.
Additionally, it is cross platform, and it looks like the client for both Mac OS and Windows works the same way.
Any ideas as to how this functionality is implemented?
For OSX:
What I found, they use Apple Script.
My assumption is they have an script running periodically, which gets which app is the one in the front. If it's a browser, they get the URL thru Apple Script again.
Example
# Google Chrome
tell application "Google Chrome" to return URL of active tab of front window
tell application "Google Chrome" to return title of active tab of front window
About get focused, I do not have the premium version. But, what I have seen is: it loads the website then, it redirects you. So, I presume they get the URL, then they determine if it should be blocked (looking the URL host into a list of invalid websites), then they redirect you... using Apple Script again.
精彩评论