nwgat / remote-torrent-adder

Automatically exported from code.google.com/p/remote-torrent-adder
0 stars 0 forks source link

On some link catch filters Chrome prompts to download .torrent and also adds to WebUI at the same time #57

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of Chrome are you using? On what operating system?
 24.0.1312.52 on Win7 x64 SP1
What client (version?) are you connecting to? Are you using SSL?
uTorrent 2.0.4. No SSL.
What steps will reproduce the problem?
1. Add link catching filter \/forum\/dl\.php\?t=\d+
2. Go to matching tracker and click torrent link, it will prompt for save 
location for the torrent file and also add the torrent to WebUI at same time
3. The default filters work fine on other trackers, but the 
\/forum\/dl\.php\?t=\d+ filter is not working right.

What is the expected output? What do you see instead?

I was expecting to just add to WebUI, not also prompt to save torrent file at 
the same time.

Original issue reported on code.google.com by mi...@angelclaw.ro on 12 Jan 2013 at 2:56

GoogleCodeExporter commented 9 years ago
hey there,
filter looks good, i did a quick test and it works as expected for me (adds to 
webui, doesn't download). maybe the problem is an unexpected webserver 
configuration.

go install this extension: 
https://chrome.google.com/webstore/detail/dev-http-client/aejoelaoggembcahagimdi
liamlcdmfm?hl=en

then open it up (there's an icon in the new tab page) and do a GET request on 
the url you would be clicking for the problem to occur. then paste me the raw 
response headers (middle left of the page).

Original comment by jul...@gmail.com on 12 Jan 2013 at 3:28

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi,

Here you go:

Pragma: no-cache
Date: Sat, 12 Jan 2013 16:24:38 GMT
Last-Modified: Sat, 12 Jan 2013 16:24:38 GMT
Server: nginx
Transfer-Encoding: chunked
Content-Type: application/x-bittorrent; name="t1551576.torrent"
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Content-Disposition: attachment; filename="t1551576.torrent"
Connection: keep-alive
Expires: Mon, 26 Jul 1997 05:00:00 GMT

Original comment by mi...@angelclaw.ro on 12 Jan 2013 at 4:26

GoogleCodeExporter commented 9 years ago
Also example of working tracker with my added filter 
\/download\.php\?id=\d+&type=torrent

Date: Sat, 12 Jan 2013 16:23:40 GMT
Content-Disposition: attachment; filename="filenamegoeshere.torrent"
Server: nginx/1.0.15
Connection: keep-alive
X-Powered-By: PHP/5.3.17-1~dotdeb.0
Transfer-Encoding: chunked
Content-Type: application/x-bittorrent

Original comment by mi...@angelclaw.ro on 12 Jan 2013 at 4:27

GoogleCodeExporter commented 9 years ago
what's the http return code? in the dev http client extension, it's directly 
below the "RESPONSE" title, usually a number and short string like "200 OK" or 
"302 Found".

this is sadly mostly fishing, i don't really have a good idea what could be 
causing your problem. can you divulge the link? it's easier to debug errors 
when you're working on the real thing.

Original comment by jul...@gmail.com on 12 Jan 2013 at 4:36

GoogleCodeExporter commented 9 years ago
200 OK :)
It's some russian tracker with adult content :D
I will mail you the link, it's free signup but it has no english.

Original comment by mi...@angelclaw.ro on 12 Jan 2013 at 4:51

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Tell me if you need anything else or if you haven't received my email yet.

Original comment by mi...@angelclaw.ro on 12 Jan 2013 at 5:01

GoogleCodeExporter commented 9 years ago
alright, i see what's happening... they've solved the whole downloading of a 
torrent thing in a bit of a funky way:
a click on the link sets a cookie, then releasing the click actually submits a 
form (and not just "executes" the link-click) that has the action-value of the 
link, thereby downloading the torrent file.
this is all done via javascript manipulation, so since the runtime of the 
content script of the extension right now is forced to occur *before* the 
runtime of the site's resources (images, scripts), the site's script just 
writes another click-event over the one created by the extension.

give me a few minutes and i'll see if i can find a quick fix for that.

Original comment by jul...@gmail.com on 12 Jan 2013 at 5:27

GoogleCodeExporter commented 9 years ago
Take any of your time..

Original comment by mi...@angelclaw.ro on 12 Jan 2013 at 8:28

GoogleCodeExporter commented 9 years ago
despite what are now a good two hours of work, i've not been able to figure out 
a fix for this.

it seems that chrome extensions run into a race condition accessing the event 
handlers registered by website scripts, in particular i can't seem to 
access/delete events registered by the website from my extension. this may have 
any of two causes:
- the website's script registers an event handler AFTER the extension does, 
thus preventing the deletion of previous event handlers AND the event gets to 
the website's event handler before it reaches the extension's, thus preventing 
me from stopping propagation of the event itself.
- the website's script creates event handlers in the DOM nodes that are in a 
different namespace than the extension's. this shouldn't be the case, as i can 
prevent basic bubbling from within the script, but i'm not 100% sure.

i even tried writing a userscript (JS script that can be used like a light 
extension in chrome, see userscripts.org or google "greasemonkey"), but that 
wouldn't make it work either.

what does work is doing this manually in the developer console (ctrl+shift+j) 
after the website has loaded:

var x = document.querySelectorAll(".dl-stub");
$(x[0]).data("events").click = null;
$(x[1]).data("events").click = null;

that'll prevent local downloading of the torrent file, but adding to the webui 
works fine.

as such, this is a website-specific problem that i unfortunately can't do 
anything about. if anyone does stumble upon a way of solving this issue, let me 
know and i'll be happy to incorporate it into RTA, but until then, i'm setting 
this to WontFix. sorry again.

Original comment by jul...@gmail.com on 12 Jan 2013 at 9:05

GoogleCodeExporter commented 9 years ago
Not a big deal, but it's just pitty.
Like i said, right clicking works as intended. It's enough for such an isolated 
situation. Doesn't deserve extra attention if it's such a pain to find a 
workaround.
Thanks, you deserve 5 stars for the fast response and support.

Original comment by mi...@angelclaw.ro on 12 Jan 2013 at 9:40