diff --git a/README.md b/README.md index 46f2456..b2f153c 100644 --- a/README.md +++ b/README.md @@ -197,5 +197,3 @@ for updates, you can download the identical plugin from this repository's releases page. The latest AMO Plugin will always be identical to the latest github release, except for the version number, which must be incremented for submission to AMO. - -moz-extension://d63582fc-09fc-445a-b8aa-1c888ee2ffc0/toopie.html \ No newline at end of file diff --git a/home.css b/home.css index 5750d7c..fc5bf68 100644 --- a/home.css +++ b/home.css @@ -211,7 +211,6 @@ li { width: 30%; min-width: 30%; background: #dee2e6; - float: left; text-align: center!important; border: 1px solid #dee2e6; border-radius: 2px; diff --git a/home.html b/home.html index ad555c6..0d1cc43 100644 --- a/home.html +++ b/home.html @@ -10,7 +10,7 @@ - +
@@ -120,15 +120,19 @@ diff --git a/manifest.json b/manifest.json index a09a028..8f3838f 100644 --- a/manifest.json +++ b/manifest.json @@ -51,6 +51,7 @@ "scripts": [ "config.js", "i2pcontrol/i2pcontrol.js", + "torrent/torrent.js", "host.js", "privacy.js", "platform.js", @@ -69,11 +70,6 @@ "name": "RouterConsole", "uriTemplate": "http://127.0.0.1:7657/%s" }, - { - "protocol": "ext+dati2p", - "name": "Dat over I2P", - "uriTemplate": "/dat.html#!/%s" - }, { "protocol": "magnet", "name": "I2PTorrent", diff --git a/proxy.js b/proxy.js index 7f76838..cf38201 100644 --- a/proxy.js +++ b/proxy.js @@ -20,7 +20,6 @@ function shouldProxyRequest(requestInfo) { } var handleContextProxyRequest = async function(requestDetails) { - console.log("(proxy)Searching for proxy by context"); try { var handleProxyRequest = function(context) { proxy = { diff --git a/torrent/torrent.js b/torrent/torrent.js index 540529e..eaf36e9 100644 --- a/torrent/torrent.js +++ b/torrent/torrent.js @@ -1,4 +1,5 @@ -var hello = "hello bittorrent"; +var hellot = "hello bittorrent"; +var xTransmissionSessionId = "" function makeid(length) { var result = ""; @@ -11,7 +12,7 @@ function makeid(length) { return result; } -function send( +function torrentsend( message, control_host = "127.0.0.1", control_port = "7657", @@ -20,20 +21,22 @@ function send( async function postData(url = "", data = {}) { // Default options are marked with * let requestBody = JSON.stringify(data); - //console.log("(i2pcontrol)", requestBody, data); + console.log("(torrent-rpc) send", requestBody, data); let opts = { method: "POST", // *GET, POST, PUT, DELETE, etc. mode: "cors", // no-cors, *cors, same-origin cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached credentials: "same-origin", // include, *same-origin, omit headers: { - "Content-Type": "application/json" + "Content-Type": "application/json", + "X-Transmission-Session-Id": xTransmissionSessionId }, redirect: "follow", // manual, *follow, error referrerPolicy: "no-referrer", // no-referrer, *client body: requestBody // body data type must match "Content-Type" header }; const response = await fetch(url, opts); + console.log("(torrent-rpc) response", response) return await response.json(); // parses JSON response into native JavaScript objects } @@ -41,42 +44,48 @@ function send( "http://" + control_host + ":" + control_port + "/" + control_path + "/", message ); +/* return postData( + "http://" + control_host + ":" + control_port + "/" + control_path, + message + );*/ } -function authenticate( +function sessionStats( password = "transmission", control_host = "127.0.0.1", control_port = "7657", control_path = "transmission/rpc" ) { - let store = browser.storage.local.get("rpc_pass"); - if (store != undefined) { - console.log("Stored password found"); - password = store; - } - function auth(got) { var json = new Object(); json["id"] = makeid(6); json["jsonrpc"] = "2.0"; - json["method"] = "Authenticate"; - json["params"] = new Object(); - json["params"]["API"] = 1; - json["params"]["Password"] = password; - return send(json); - } - store.then(auth); + json["method"] = "session-stats"; + //json["params"] = new Object(); + return torrentsend(json, control_host, control_port, control_path); } -async function GetToken( +async function GetTorrentToken( password, control_host = "127.0.0.1", control_port = "7657", control_path = "transmission/rpc" ) { - let me = authenticate(password); - return await me.then(gettoken); + let me = sessionStats(password); + return await me.then(gettorrenttoken); } -function gettoken(authtoken) { +function gettorrenttoken(authtoken) { + console.log(authtoken) return authtoken.result.Token; } + +function TorrentDone(result){ + console.log("(torrent-rpc) recv", result) +} + +function TorrentError(result){ + console.log("(torrent-rpc) recv err", result) +} + +var result = GetTorrentToken() +result.then(TorrentDone, TorrentError) \ No newline at end of file