Permalink
Browse files

final bugfixes to get it actually stable

version 0.0.5
  • Loading branch information...
1 parent 2218a53 commit 6cb0b10c7ec52d8de75b02f816506051c1ed3b2f @michaelficarra committed Oct 23, 2012
Showing with 18 additions and 36 deletions.
  1. +0 −11 background.html
  2. +2 −14 background.js
  3. +1 −1 manifest.json
  4. +14 −9 popup.js
  5. BIN transmissionDownload.crx
  6. +1 −1 updateInfo.xml
View
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <script type="text/javascript" src="Base64.js"></script>
- <script type="text/javascript" src="util.js"></script>
- <script type="text/javascript" src="background.js"></script>
-</head>
-<body>
-</body>
-</html>
View
@@ -1,26 +1,14 @@
(function(global){
- var supportedUrls =
- [ /^https?:\/\/([^\/]*\.)?torrentz\.(com|eu|me)\/(announce_)?[a-f0-9]{40}/i
- //, /^http:\/\/([^\/]*\.)?bitsnoop.com\/.*\-q[0-9]+\.html$/
- //, /^http:\/\/([^\/]*\.)?kickasstorrents.com\/.*\-t[0-9]+\.html$/
- ];
- var isSupportedUrl = function(url){
- for(var i=0,l=supportedUrls.length; i<l; ++i) {
- if(supportedUrls[i].test(url)) return true;
- }
- return false;
- };
-
var refreshIcon = function(tab){
- chrome.pageAction[isSupportedUrl(tab.url) ? 'show' : 'hide'](tab.id);
+ chrome.pageAction.hide(tab.id);
chrome.tabs.sendRequest(tab.id, {type:'hasMagnet'}, function(response){
if(response) chrome.pageAction.show(tab.id);
});
};
// show icon as page action on tab change
chrome.tabs.onSelectionChanged.addListener(function(tabId) {
- chrome.tabs.get(tabId,refreshIcon);
+ chrome.tabs.get(tabId, refreshIcon);
});
// show icon as page action on page load
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
View
@@ -2,7 +2,7 @@
, "name": "Transmission Torrent Downloader"
, "homepage_url": "https://github.com/michaelficarra/transmissionDownload"
, "update_url": "https://github.com/michaelficarra/transmissionDownload/updateInfo.xml"
-, "version": "0.0.4"
+, "version": "0.0.5"
, "description": "Adds torrent to Transmission through RPC on supported websites"
, "icons":
{ "16" : "icons/transmission.16.alt.png"
View
@@ -84,7 +84,7 @@
}
self.sessionId = sessionId;
info('secured transmission session', sessionId);
- if(typeof callback=='function') callback(sessionId);
+ if(typeof callback=='function') callback.call(self, sessionId);
};
xhr.open('GET', buildUrl(server.protocol, server.host, server.port, server.path), true);
var basicAuth = 'Basic '+Base64.encode(auth.username+':'+auth.password);
@@ -97,16 +97,16 @@
if(!this.sessionId)
return startSession.call(this, function(newSessionId){
if(!newSessionId) return;
- addTorrent(info_hash, callback);
+ addTorrent.call(this, info_hash, callback);
});
var self = this,
auth = this.authentication,
server = this.server,
sessionId = this.sessionId,
sources =
- [ { name: 'torrage.com', url: 'http://torrage.com/torrent/#{info_hash}.torrent' }
+ [ { name: 'zoink.it', url: 'http://zoink.it/torrent/#{info_hash}.torrent' }
, { name: 'torcache.com', url: 'http://torcache.com/torrent/#{info_hash}.torrent' }
- , { name: 'zoink.it', url: 'http://zoink.it/torrent/#{info_hash}.torrent' }
+ , { name: 'torrage.com', url: 'http://torrage.com/torrent/#{info_hash}.torrent' }
, { name: 'torrage.ws', url: 'http://torrage.ws/torrent/#{info_hash}.torrent' }
];
var tryAgain;
@@ -121,11 +121,16 @@
if(xhr.status==409)
return startSession.call(self, function(newSessionId){
if(!newSessionId) return;
- addTorrent(info_hash, callback);
+ addTorrent.call(this, info_hash, callback);
});
if(xhr.status!=200) return tryAgain();
var response = JSON.parse(xhr.responseText);
- if(response.result != 'success') return error(response.result, response);
+ if(response.result != 'success') {
+ removeClass.call($('#retry'), 'hidden');
+ $('#retry').focus();
+ error(response.result, response);
+ return;
+ }
if(typeof callback=='function') callback(response.arguments['torrent-added']);
};
var postData =
@@ -141,7 +146,7 @@
var basicAuth = 'Basic '+Base64.encode(auth.username+':'+auth.password);
if(auth.enabled) xhr.setRequestHeader('Authorization', basicAuth);
xhr.send(JSON.stringify(postData));
- })();
+ }).call(this);
};
var addTrackers = function(torrent, callback){
@@ -230,8 +235,7 @@
var start = function(){
var context = generateOptions();
$('#log').innerHTML = '';
- removeClass.call($('#addTorrent'), 'hidden');
- addClass.call($('#retry'), 'hidden');
+ addClass.call($('#addTorrent'), 'hidden');
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.sendRequest(tab.id, {type:'info_hash'}, function(info_hash){
if(!info_hash) return error('could not determine info_hash', info_hash);
@@ -243,6 +247,7 @@
if(trackers)
info('added ' + trackers.length + ' additional trackers', trackers);
log('done')('done');
+ addClass.call($('#addTorrent'), 'hidden');
if(!success) removeClass.call($('#retry'), 'hidden');
removeClass.call($('#close'), 'hidden');
$(success ? '#close' : '#retry').focus();
View
Binary file not shown.
View
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='kbhlogbpfllkkgignllokdlcnjohoehp'>
- <updatecheck codebase='https://github.com/michaelficarra/transmissionDownload/raw/master/transmissionDownload.crx' version='0.0.4' />
+ <updatecheck codebase='https://github.com/michaelficarra/transmissionDownload/raw/master/transmissionDownload.crx' version='0.0.5' />
</app>
</gupdate>

0 comments on commit 6cb0b10

Please sign in to comment.