Jump to content

SAFARI (Mac OSX) Extension


DrakeColdwinter

Recommended Posts

I'm not sure if this would go under mac OS X forum or Web API forums, this is a safari trouble, not a webUI problem, but I don't think the MAC OS X forums are the good place either.

 

Anyway, I would like to make a custom extension in safari to send the torrents and magnets to my WebUI. Now the problem I have is that safari doesn't catch at all the magnet links, it tries to seek for an application to handle, it never goes into catchURL(event), I have done a global.html page to handle the torrent files(code below), it works well. How should I manage the magnet files (My problem is how to catch the magnet links under safari, not how to send them to WebUI) ??

 

safari.application.addEventListener("beforeNavigate", catchURL, true);

 

//Function to catch the navigate event

function catchURL(event){
if(event.url != null)
{
var url = event.url;
var ext = url.substring(url.length-8, url.length);
if (ext.toUpperCase()==".TORRENT")
{
console.log("prevent torrent download");
event.preventDefault();
 
var mytab = safari.application.activeBrowserWindow.openTab("background");
 
var torrentURL ="http://192.168.0.100:8080/gui/?action=add-url&s=" + encodeURI(url) + "&token=[MyTokenCode]";
 
mytab.url = torrentURL;
}
}
}
 
 
Oh, I know my code is very crude :( sorry :(
If there is already an extension or something for safari that works well with Torrent, just point to me, I haven't found any (hence my code and request here)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...