tomsawyer
tomsawyer

Reputation: 105

How to distinguish a link whether it will trigger file downloading or jumping into anywhere else, such as a new URL

I get an idea writing a GreaseMonkey user JavaScript that can detect which is the exactly real download link rather than an advertisement link or something else.

Actually, I find that some real download link is linked to .php. It's tough to detect it I think.

How could I do that, any ideas?

Upvotes: 0

Views: 410

Answers (1)

Aaron Digulla
Aaron Digulla

Reputation: 328574

The only reliable way to do it is to follow the link and check what Content-type you will find in the header of the response. If you can, try to send a HEAD request instead of a GET. That will give you the information you need without actually starting the download.

Upvotes: 2

Related Questions