Feeds:
Posts
Comments

Archive for the ‘Google Chrome’ Category

I wrote a Chrome extension called Chrome Nanny. Sometime back, Google took it down as it was against their branding guidelines … So I have created another extension with the same code but with the name : Nanny for Google Chrome. You can find the extension at https://chrome.google.com/webstore/detail/cljcgchbnolheggdgaeclffeagnnmhno .

 

All new development will take place in this extension . I am still thinking about how to create a migration plan for Chrome Nanny users. I will post as I have more information . I will also update older blogs to point to the new url. Please spread the word !

Read Full Post »

I released a new version of Chrome Nanny that incorporated few requested features. They are:

 

1. Validate regular expressions when they are entered in blockset.

2. More robust error handling inside the extension.

3. Always allow access to Chrome extension links even if you block *.*

4. Disallow *.* from White list.

5. Do not strip www/http from the blocksite. So a block url of www.ft.com will not block www.microsoft.com unless the url is ft.com.

6. Multiple internal changes that will allow implementation of other Chrome Nanny features faster.

 

Let me know how this version works !

Read Full Post »

I just published a new version of Chrome Nanny that implements a frequently requested feature – the ability to go into focus mode also called as lockdown.

If you have used LeechBlock, you must be familiar with lockdown. If not, this feature allows you to immediately block a set of blocksets for the next “n” minutes. This is useful if you do not want to muck with the existing blockset settings.

A new tab called ‘Lock Down’ is added. This contains two blocks. The ‘Configure Lockdown’  block allows you to setup a new lockdown. This lists all the blocksets in Chrome Nanny and you can select a subset of the blocksets to lock down. You also have a dropdown giving the time of the lockdown.

When a lockdown is active, then the details of that lockdown is displayed in the “LockDown Information” block. During that time all the urls in the selected blocksets will be blocked. You will not be able to edit or delete those blocksets either. Only one lockdown can be active at a time.

I will be updating the Chrome Nanny roadmap page soon with the latest set of features and priorities.

Read Full Post »

A new version of Chrome Nanny (0.98) is released today. The following are the highlights :

1. Chrome Nanny got the first external patch 🙂 The patch was from Hannes Hofmann who added a leechblockish page to Chrome Nanny.  I liked it so much that I made it the default for new installations. Thanks Hannes !

2. There is now an option to hide the blocked sites. This was one of the popular requests and it is finally done. A new field “Show blocked URLs in Popup” is added which when set to no will not show the blocked URLs when Chrome Nanny icon is clicked.

3. Chrome Nanny now allows redirect to about:* pages. So this means you can set redirect to about:blank and other pages.

4. Other minor UI tweaks : changing display of hours in popup, fixed jquery UI arrow issue in the calendar at statistics tab.

 

URLs :

Installation : Chrome Nanny’s extension page.

Updated Instructions : Instructions For Chrome Nanny – A Leech Block like extension for Chrome .

RoadMap : Chrome Nanny Roadmap .

 

Check out the extension and tell me your experience ! You can comment in either the extension web page or the instructions page.  Future features planned are in Roadmap page.

Read Full Post »

[Update Nov 15 2011] : Chrome Nanny is now Nanny for Google Chrome. It also has a new home. The link to Google Chrome extension gallery is https://chrome.google.com/webstore/detail/cljcgchbnolheggdgaeclffeagnnmhno . Please spread the word !

 Chrome Nanny is a leech block like extension for Chrome. I developed it as I started using Chrome extensively and there was no leech block like extension for it. It has been kinda successful beyond my expectations – Almost 2000 people are using it ! I have been for the last couple of months with my masters and did not add any features. Now that I am free I thought, I will add a page which will show the features that are in the works and also provide a way to request new features.

I plan to make this page a single location where you can see the features that are being developed and also to request/discuss new features. Till the end of August 2010, I plan to have a weekly development cycle and after that probably once in two weeks – assuming there are some features to develop.

If you are interested in sending your patches , please email me to saravananDOTthirumuruganathanATgmailDOTcom.  The latest code can always be got from the repository here .

 

[Last Update] Update Jul 24 2011

Suggestions

One of the pain points is the initial setup. Chrome Nanny starts enforcing blocking behavior immediately after blocksets are created. If you make a mistake and you want to fix it, you have to enter the challenge text. Is there a heuristic that prevents challenge till the entire initial setup is done? ie I want to balance usability with the Chrome Nanny’s default behavior for productivity.

 

Features : In the next release

Vlad,Mathias : It is too easy to add a Whitelisted URL to the list. It can be done anytime, even when “You should be working”
I suggest to add the same check: if(chrome.extension.getBackgroundPage().BackGroundManager.checkIfBlockSetShudBeBlockedNOW(blockSetName)) challengeUser(blockSetName,’E’); to the function addUrlToWhiteList()

Jason : Perhaps it should be clear that the blacklisted sites are automatically tracked? Or perhaps the whitelist should just be a list of sites to track in addition (since isn’t the blacklist supposed to act like a whitelist too?)

Catherine : I have a suggestion, though. It would be nice if you had a feature that blocks ALL websites except those that the user specifies or puts in the whitelist–like the “Nuclear Mode” in StayFocusd.

Saravanan : Add purge option to Stats

Scott Allen : The main feature I miss, though, is a quick/easy way to block a site. What would it take to have a "block this" bookmarklet? Right now, I have to go through 3-4 mouse clicks, and then either copy/paste the URL or type it in. I’d like a one-click "Block domain" and maybe another "Block URL" one. After all, the whole point is to improve productivity, right? 🙂
Discussion : When you click on the Chrome Nanny’s icon page, it will have an option to block the domain/url. Clicking on it will take you to the options page. Also have a link to go to options page directly and for lock down.

Saravanan
Stricter time validation .
Mustafa :
Add the option to hide the blocked sites but show the allowed remaining time for the other ones. 2 reasons behind it:
-Everytime I see that blocked list I wanna disable the add-on and visit the sites. -I want to be able to see how many minutes do I have left for the restricted sites.

Anonymous : Add an option to password protect viewing Chrome Nanny options

Features : In the near future

Marko, Rajiv, anonymous : I would only echo what has already been brought up, that when you first start Chrome, it will let you see a site that you have blocked.  For example, I have blocked Facebook for certain hours during the day, but even during those hours, when you first start Chrome, Facebook pops up and you can see it until you click somewhere on the screen.  Then the Chrome Nanny block page shows up.  Still love it!  Just maybe a little hole to fix 🙂

Jim,Ben and many others :    Have a block behavior similar to leechblock.  I know leechblock as the option of limiting my facebook usage to 30 minutes ONLY on saturdays, and to block it every other day of the week . Is there a way to add that onto this extension? I really need it to help me out, because even 15 minutes everyday is too much for me at this point.

David T : It would be cool to be able to block a site based on the number of visits. I spend way too much time checking gmail to see if there are any new messages. Even though I’m only briefly at the website because there are no messages, it’s interruptive when I should be focusing. It would be cool to limit gmail to 2 or 3 visits per day, but be able to stay there and write emails if I’ve actually received something.

        
Tianyi Cui :        I propose a feature to use a custom JavaScript function to determine whether a website should be blocked.

        The parameters of the user-input function are an URL and some statistics about this URL (e.g. The logged time intervals of that domain in previous 24 hrs). I’m not sure how much statistics should be calculated and provided to balance configurability, performance and the time to implementation. I’ll think about it later and we can discuss. The statistics should be calculated only if needed (i.e. the parameter is a function) since probably most time we only need the URL and current time. The return values of the JS function can be either “Block”, “Don’t Block” and “Pass” (i.e. let the default rules to determine).

        This is an advanced feature which can be extremely useful for programmers (I bet a significant part of users are), as they can easily implement the feature they want by themselves, and the customized rules as JS function can be easily backed up, version controlled, and shared as it’s just plain text.

        I would like try to implement this feature by myself since I’m an experienced programmer. I don’t know JS very much and haven’t implemented browser extensions before. But it’s a great experience to hack and learn.

        Please comment on this idea and tell me which part of the source code I should read and modify and any suggestion on the implementation. 
         
Tianyi Cui :
        The challenge test should be prompted after user clicked “Save URL” (not after user clicked “Edit”) if and only if the edit could make a previously blocked URL not blocked any more (e.g. user is deleting URLs or reduced Block Time). When user is just adding URLs or increase Block Time or edit Tags, she should not be forced to the challenge test.
               
Brian :
        From: http://xkcd.com/862/

        “After years of trying various methods, I broke this habit by pitting my impatience against my laziness. I decoupled the action and the neurological reward by setting up a simple 30-second delay I had to wait through, in which I couldn’t do anything else, before any new page or chat client would load (and only allowed one to run at once). The urge to check all those sites magically vanished–and my productive computer use was unaffected.”

        I wonder if such a feature could be added to Chrome Nanny? Instead of blocking pages, make them load slowly?
 
Greg :
        A suggestion: When I’m on a site that is being timed, the Chrome Nanny icon should change — ideally it should be very dramatic (like all bright red) so I will notice that I am using up my time.  That would be a good warning not to stay on the site too long.  (This would also help when I leave a tab in the background that is eating up my time.)
thanks!

 

Bevans : Could you give us a way to change when a new "day" begins? Right now, it’s set at midnight of course, but I sometimes work until 1 or 2 AM, and if I’m using a site at midnight I begin using up the next day’s time. I’d like to be able to set it to reset the timers at 3 or 4 AM instead of midnight.

Lukasz : Personally I like the "StayFocused" behaviour in this regard where you get icon that changes from blue to red if the current site is on the list and then counter once there is less than a minute left. It’s clear indication I’m on a site I shouldn’t and that the time is ticking 😉

Saravanan : Implement notifications feature. (http://blog.chromium.org/2010/05/desktop-notifications-now-available-to.html)
Discussion : Notifications are a cute little feature. It would be nice to warn users that they have only for eg : say 5 minutes left. (Should this be made configurable ? )

sarah : Suggestion: If I block, for instance, http://www.example.com, your extension also blocks http://www.differentexample.com, presumably because you strip it to "example\.com" and add a wildcard up front to ".*example\.com" This is really bad – you’re blocking a completely separate domain, when you probably just wanted to block "same.example.com" You could try using a url parser library to get the actual domain name. Thanks for an awesome extension!
Discussion : Good observation ! The current behavior was intentional so that user enters only "google" to block all of google’s websites.  One possible compromise is to check if the block url resembles URL closely – If so block only the URL. If it is a substring/regexp, use the default behavior.

Ryan : add idle state task to roadmap – refer : http://code.google.com/chrome/extensions/trunk/idle.html

Patrick,Allen : i think that websites should be able to appear in multiple block sets so that they can be blocked at different times on different days (eg. I want to block a website in a specific time period during the week, but in a different one on the weekends.) leechblock, on firefox, provides this option
Discussion : Another change that might result in major design changes. Depending upon the demand, will make the decision.

Firefly,Adam,Michael :     Is it possible to implement the export / import feature from Leechblock? I have an extensive list of sites (about 150) that I use in firefox. I use this list across machines and I’d like to be able to use it in chrome nanny.
Discussion : If there is additional demand , will develop this feature.

Tom : Is there a way to set the time limit to only be active during specified time ranges? For example, from 6am-9pm I’d like the 30min time limit to be active when I visit a blocked site, but after 9pm I’d like the blocking to become inactive and be able to visit the site as long as I want. If I could request a feature, that would be it.

Scott :     a) Could use natural text parser for time of day. (i.e., just enter 8am-5pm) b) If you have a long list of URLs in a blocklist without any word wrap breaking characters, it will make the block set box in the block sets tab really really wide so you have to scroll to see the "Edit" button.

KelAt :
    It’s not a big deal, but my suggestion would be for either of two changes to be made. Maybe I was already clear about this, or maybe I wasn’t:
– Right now, if I have a window with multiple tabs being blocked. Each one, however says “You can click here to access the page once the site is no longer blocked.” but it gives the same link on each page. It would be good if each page could keep the correct link to go back to the page that was blocked.
– It would be even better if the blocked page could just be restored / refreshed automatically after the block period has ended, so that when I return to the browser, I’m not confronted with lots of "blocked" tabs that I have to just close out of or refresh automatically.

Haitrieu :
    How could I sync this extension setting and statistics between home computer and my company computer?
Seth,Volker
    one other thing. how about allowing javascript in the redirect URL – so, for instance, I could send anything that’s blocked to instapaper before it goes and read it later?
Volker
    Right click might be hard for extensions like Chrome Nanny due to Chrome’s extension architecture. I will add an option in the popup page .
     I like the idea of an option to adding to a new url to existing list without raising the challenge . I will implement it in next iteration.
     I’d like to have the blocked URL in the URL line, so the blocked URL can be bookmarked easily or used by other plugins (like read it later or similiar)
     Max Time: add a option so I can only limiting the time between in a time range e.g. “X minutes every X hours between 0900-1200,1300-1700?
     support for Complex rules
Jonathan:
    Combine the idea of adblock plus’s "list" subscription (they keep a running list of known ad sites) with Chrome Nanny.  But your lists could be news, social networking, , etc.  Then one wouldn’t have to block the whole internet, but just, say, "news".

Tim :
    Add an option to track time spent on links clicked from blocked pages.
Angelo :
    I would like to be able to schedule a ‘break time’ each day, during which I can freely browse my blocked sites without accruing any minutes against my time limit. For example, I give myself 30 minutes a day to use up on browsing my blocked websites, but from noon until 1pm, I can browse as much as I want. Maybe, you could implement this as a "Active Time" setting in the general options, which defines during which times the Chrome Nanny extension is active. I could set up my "Active Time" as:  "930-1200,1300-1700" for example.

Jared :
    Great app, but if there was one added feature, I’d be happier.  In Leechblock, whitelisted URL’s can be added to a particular block set, rather than only in an independent group that supersedes all blocked lists anywhere.  Can you see the advantage in doing it that way?  For example, the scenario that works for me at home is the following: one block site blocks the whole internet 24/7 EXCEPT for a select few sites I allow (email, google maps, wikipedia, etc) that I know not to be the major time drainers.  A second block set blocks EVERYTHING starting at 10 pm so I must get off even email and go to sleep (and this block set supersedes the whitelisted url’s in the previous group).

It took me a while to figure this system out (it’s not necessarily intuitive to consider a hierarchical approach), but it is the best, most customizable way to do it for me.  It’d be great if this feature could be added (could even leave the white lists tab as it is, but just add in the ability to white list within each block list)

Completed Features

This will include the list of features that were discussed previously. I will include the version number and date it was deployed.

Features : Set 1

Completed by August 22. Chrome Nanny version 0.964.

Arnaldo : I see what you are trying to do, but could this popup be a configurable option?
kunigas : Let the password requirement for editing as an option (and also the length of it too), I’m fine without pass, but I find it annoying to type it every time I decide to change the blocking rules (and I do it often in experimental periods).
Discussion :
In the general options, add a drop down to decide how the challenge has to be implemented. Possible values include a) No Challenge b) 32 character c) 64 character and d) 128 characters. By default challenge will be 64 characters. If you increase the challenge size, you will be allowed. If you decrease it, then you will be asked for a challenge . For eg , if you try to reduce a 64 character challenge to 32 characters, you will be asked a 64 character challenge.
If a block set is currently being blocked , then trying to edit / delete will trigger a challenge that is specified in general options.

Saravanan : sort blocksets by name atleast when displaying so that the order is consistent
Discussion : This is more of a usability issue rather than a bug.

Features : Set 2

Completed by September 20. Chrome Nanny version 0.98.

Peter,Lukasz,Scott : Would it be possible to have the option to ‘hide’ the list of blocked sites – so that not everybody who goes on my computer could idly click on the nanny icon and be presented with a list of all the sites I’m not visiting.

Discussion : Allow an option to make the information available in the Chrome Nanny icon optional. Should this be extended to control the list in options menu ?

Yavor : jquery’s datepicker – I cannot see the arrows on the top of the picker – they are blue on blue.
Discussion : This is a UI issue and might confuse some users. So, highlight the arrows in the calendar to change the months more clearly.

anonymous : I think the way it lists the times are kinda weird… if I have 5 more minutes on a site it says 00:05 hours.  At first glance it is kinda confusing.
Discussion : If remaining time for a URL is less than an hour display as "x minutes left" . If greater than an hour display as "x:y hours left" .

Sarah : This extension can render the browser unusable (without running from the command line) if a user blocks their homepage with "close tab" selected as the block method. I suggest defaulting to loading about:blank instead to avoid this problem.
Craig Kingston :  The mode of blocking defaults to closing the tab, which is surprising and confusing.  While I am able to redirect it to some specified URL, it would be nice if a third option or at least a default specified URL was a "default -this pages is blocked- web page" (similar to leech block).

Discussion : I will check if it is possible to redirect to about:blank. If not I will redirect to a new page similar to leechblock’s. This will be the default option for new installations. The current settings will not be modified.

Features : Set 3

Completed by Jan 24 2011. Chrome Nanny version 0.984.

Tim, Saravanan : Allow a more expressive block times. For eg instead of block after 60 minutes in a day allow other options like block after 60 minutes in 4 hour/6 hour/ 12 hours etc. I think Leechblock has this feature. Emulate as closely as possible.
Discussion : These two features might need some major changes in the design of Chrome Nanny but looks like very useful features.

Features : Set 4

Completed by Mar 06 2011. Chrome Nanny version 0.988.

Matt : The ability to go into "focus mode", and block a specific set of websites for a specific  amount of time.
Saravanan : Have a feature similar to Leechblock’s lockdown.
Discussion :
The idea of focus mode and lockdown are very similar – The only difference is that focus mode can involve arbitrary sites not in any of the blocksets. There must be some way to enter a set of websites and ask them to be blocked for the next n minutes. In lockdown, all the sites already in Chrome Nanny block sets are blocked for the next n minutes. In both the cases, the user will be specifying the block time.

Features : Set 5

Completed by Jun 19 2011. Chrome Nanny version 0.989.

Fixed a bug in lockdown.

Features : Set 6

Completed by Jul 24 2011. Chrome Nanny version 0.990.

Galen,Toni,EC,Neil,Corey Helfand : .* blocks, among other things, chrome:extension — this is probably bad behavior. Probably shouldn’t block any urls that purport to use chrome as the scheme. Do not block chrome:* and chrome-extension:// pages.
Eric  : Prevent .*.* from being added to the whitelist.

Robust handling of erroneous regexp – When entering regular expressions in black or whitelist, it is validated. Existing incorrect regular expressions are also handled gracefully.

Prevent *.* from being added to Whitelist

Always allow access to Chrome internal pages even if *.* is blocked. This will allow access to , for eg, Chrome extensions page.

Dont strip www/http from url/blocked url. So www.ft.com will not block www.microsoft.com unless the url is ft.com .

If there is any other features you are interested in, please feel free to share in the comments or in the Chrome Nanny’s extension page !

 

Add to DeliciousAdd to DiggAdd to FaceBookAdd to Google BookmarkAdd to RedditAdd to StumbleUponAdd to TechnoratiAdd to Twitter

Read Full Post »

This is a short post to announce that a new version of Chrome Nanny is released. This version incorporates the much requested feature of “Block Sets” .  It also adds a couple of new minor features, new chart types etc.

URLs :

Installation : Chrome Nanny’s extension page.

Updated Instructions : Instructions For Chrome Nanny – A Leech Block like extension for Chrome .

 

Check out the extension and tell me your experience !

Read Full Post »

I wrote a Chrome extension recently called Chrome Nanny  – For more details see Instructions For Chrome Nanny – A Leech Block like extension for Chrome  . This post is primarily about sharing some the tips I learnt during the process of developing the extension.

Application Logs

One of the most important way to debug the extension is using logs. Sprinkle console.log liberally in your code during development. If you want to view these logs, then go to extensions page (Wrench -> Extensions) , select your extension and click on the appropriate page. Most of the time the primary logic will be in your background html page. Hence you need to select this page in the extensions page to get the developer tools. The last tab there is the console tab which will show your logs. Of course, if the console.log is in some other html page (say options page) , then you want to click on appropriate html file in the extensions page. Each active page of the extension starts its own developer tools window and hence the logs dumped in one is not visible in the other.

Usually, this is the behavior you want. But some times, you may want to redirect all the logs to BackGround html’s console. I don’t recommend it although it is pretty convenient. To achieve this write a wrapper function in your BackGround js which takes a string as input and writes it to console. A sample function might look like this.

writeToConsole : function(stuff)
{
    console.log(stuff);
}

In the code for other html files , you can invoke it . In my case , my BackGround js had an object called BackGroundManager. Hence, I invoke the function as

chrome.extension.getBackgroundPage().BackGroundManager.writeToConsole(someText);

Note that to get access to the BackGround, you need to use getBackgroundPage function. I get BackGroundManager object within it and invoke its writeToConsole function. Of course , it can be much simpler in your code. Once you do this , you can watch all the logs in a single place.

If you are lazy to type the whole expression then write another helper function which can return the background page. This might look like

function bg()
{
    return chrome.extension.getBackgroundPage();
}

You can invoke your object using bg().BackGroundManager using chaining.

A Catch in Tab Update

Chrome has a function to make a tab go to a different URL – chrome.tabs.update . This function has two arguments : A tab id and an updateProperties object. updateProperties has a property called URL which accepts a valid URL.

A sample invocation looks like this :

    chrome.tabs.update(tabId,{‘url’:urlToGo});

The behavior of this API is this : If the URL does not have a protocol, then it assumes that you are trying to load some file from your extension folder. This is useful , for example, when you want to show your help file in a tab. A common mistake (which I did) is giving the url  as http://www.test.com . Here the url does not have a protocol and hence it tries to open a file called http://www.test.com in my extension folder. The lesson is that , you should always remember to have a protocol in the URL to show unless you want to show a file from your extension.

What this means is :

Does not work :   

chrome.tabs.update(tabId,{‘url’:’www.mit.edu’});

Works :  

chrome.tabs.update(tabId,{‘url’:’http://www.mit.edu’});

Profiling Extension’s CPU And Memory Usage

When I was developing the extension , I did not want it to hog lot of memory. Chrome is best know for its blazing speed and I would not want to spoil that experience. Chrome has lot of tools to analyze the extension memory.

Method 1 :
Use this method, if you want an overall extension memory consumption and you do not really care to drill down deep. The easiest way is to press Shift+Esc keys. You can also click on the icon near the Wrench icon , select Developer option and select Task Manager. This will show how much memory each tab and extensions are using. This will give you an approximate value of the memory consumed by your extension.

Method 2 :
If you want to dig deep and figure out which parts of the extension contribute to the memory, then you are in luck. Chrome has some great tools. Go to the extensions page and select the background html page. This will open the Developer tools for the extension. You can select the "Profiles" tab. By default this will not contain any information.

Click on the black dot on the status bar and continue using the extension as usual. After some time, click the same icon and stop the profiling. For best results , I would suggest you do some set of actions which exercise most of the functionality of your extension. Now you can see the CPU profile of the extension so far. It will show all the functions which take a long time to run. You can use this information to fine tune your function.

If you are more worried about memory, then the Heap profile can help. Click on the icon which looks like an Eye to start heap profiling. This will give you a break down of all the objects which take up memory. I find this information to be too much for me to process and I usually ignore it.

Disable Selecting Of Text

For Chrome Nanny, I needed a way to prevent user from copying and pasting text. The scenario is this : When user wants to perform some operation that is forbidden, then I ask the user to enter some random 64 character code as a way to discourage them. Now I wanted to prevent them from using copy and paste to circumvent the challenge. I searched a lot and at last found a working solution – The best part was that it was entirely based on CSS and did not use Javascript at all. I got the idea from this stackoverflow page  . The idea is to have a css class like this :

.no-select
{
   -moz-user-select: none;
   -khtml-user-select: none;
   -webkit-user-select: none;
   user-select: none;
}

Now add this class to your textbox. This will prevent them from selecting text !

Callback functions

Lot of things happen asynchronously in Chrome. Almost all of Chrome APIs accept a callback function. Also a typical extension registers event listeners for the events it is interested in . The downside is that many of them can fired simultaneously and if you are not careful, you internal data structures can become inconsistent.

A more common problem is to know that callback functions need not be called immediately. A bad code is this :

chrome.tabs.getSelected(windowId,function(tab){
    tabId = tab.id
});

if(tabId == blah)
    doSomeThing();

This assumes that Chrome will set tabId inside the callback function before coming to the if. The correct way is to bring the logic inside the callback function (or atleast not make the incorrect assumption). A common way to fix it is

chrome.tabs.getSelected(windowId,function(tab)
{
    tabId = tab.id
    if(tabId == blah)
        doSomeThing();
});

I will talk about more stuff in the next part !

 

Add to DeliciousAdd to DiggAdd to FaceBookAdd to Google BookmarkAdd to RedditAdd to StumbleUponAdd to TechnoratiAdd to Twitter

If you liked this post , please subscribe to the RSS feed.

Read Full Post »

Older Posts »