A small example:

1
2
3
4
5
6
7
$('a.gallery').fancybox({
        onComplete: function() {
        	$("#fancybox-img").bind("contextmenu",function(e){
			e.preventDefault();
		});
   	}
});
 

While browsing at Forrst I saw this nice piece of CSS.

a[href^="http://"] {
        color: blue;
}
 
a[href^="mailto:"] {
        color: red;
}
 
a[href$=".pdf"] {
        color: green;
}

Styling links depending on their formats.

ajcates said:
For the sake of usability and consistency instead of changing the color on links based on their format I often times use this technique instead to add on little file icons.

 

Create a content script and use the following piece of code:

//Create a request listener
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) { 
	//Check if the requested method equals getSelection
	if (request.method == "getSelection") 
		//Send back the selected text.
		sendResponse({data: window.getSelection().toString()}); 
	else 
		//Snub them.
		sendResponse({}); 
});

This will start a request listener. With this you can send a request named getSelect from your browser_action to the content_script.

To send the getSelect request you can use the following piece of code in your browser_action.

function selectedTextPaste() { 
	//Get the current selected tab
        chrome.tabs.getSelected(null, function(tab) { 
		//Send a request to the content script of the tab with as method getSelection
                chrome.tabs.sendRequest(tab.id, {method: "getSelection"}, function(response) { 
                        //do something with response.data 
                }); 
        }); 
}

And thats all you have to do! Now you can do whatever you want with the data the browser_action has received.

© 2011 Joshua Lückers Suffusion theme by Sayontan Sinha