Stanley Shilov

Ubiquity Rapidshare Extension

Posted on Saturday, July 4th, 2009 under Coding, General

If you use Ubiquity, this simple extension makes it easy to grab and open any number of Rapidshare links:

CmdUtils.CreateCommand({
name: "rapidshare",
  preview: function(pblock){
    var selection=context.focusedWindow.getSelection();
    selection=selection.toString();
    selection=selection.match(/http:\/\/rapidshare[^\s]*/gi);
    var links='';
    for(var i=0; i<selection.length; i++){
      links=links+selection[i]+"<br />";
    }
    pblock.innerHTML=links;
  },
  execute: function(){
    var selection=context.focusedWindow.getSelection();
    selection=selection.toString();
    selection=selection.match(/http:\/\/rapidshare[^\s]*/gi);
    if(selection!=null){
      var links=selection.length;
      for(var i=0; i<links; i++) Utils.openUrlInBrowser(selection[i]);
    }
  }
})

The code examines the selected block of text, extracts URLs which resemble Rapidshare links and opens each link in a new tab.

To use: select the block of text, ctrl + alt to open ubiquity, then start typing “rapidshare”

PS: The code can be easily modified to work with other sites, simply replace any mention of “rapidshare” with the applicable site.

Tags: , , ,

You can leave a response, or trackback from your own site.

Leave a Reply



« »
© 2010 Stanley Shilov   |   Blog   |   Contact

divide et impera

Stanley Shilov