0

I've kinda figured out the basics of how to use GM_xmlhttpRequest and now I have a question.

Is it possible to request just a portion of a webpage? Say I only want a table row from a known table where the img source contains "Rawk" and then make a link to its target link... Is there a way to do that without requesting the whole page (and then figuring out what I'm supposed to do with that?)

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Kat Cox
  • 3,469
  • 2
  • 17
  • 29

1 Answers1

0

No, that's not possible. You will have to make an HTTP request and if the server doesn't support returning only a portion of HTML, there's not much you could do on the client.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • HTTP request, portion of HTML... can you explain this, or direct me to more information please? – Kat Cox Nov 17 '13 at 10:24
  • HTTP Request: http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol, Portion of HTML: Well, not a full blown HTML page with `` but only some part of its body. – Darin Dimitrov Nov 17 '13 at 10:25
  • That wiki page is confusing and gives me no clue about how I would request a portion of the page... maybe though, after I sleep I can track more info down using your clues – Kat Cox Nov 17 '13 at 10:37
  • But why are you looking for a way to request a portion of a page? Did you read my answer and more specifically the first sentence? There's no such concept of getting only a portion of an HTML page with an HTTP request. – Darin Dimitrov Nov 17 '13 at 10:37
  • And what's the difference between GM_xmlhttpRequest and HTTP Request? – Kat Cox Nov 17 '13 at 10:37
  • The difference is that the `GM_xmlhttpRequest` is not subject to some restrictions like the standard XmlHttprequest object. For example in a GM script you could make requests to any domain whereas the standard object is bound to the Same Origin Restriction Policy. – Darin Dimitrov Nov 17 '13 at 10:38
  • I'm looking for a way to get a portion of the page because I'm considering writing a script for a pet game that will add a link to the herd page of a specific critter on the critters page, and everyone's herd urls are different with the only way to identify them being to go to the herds list page... so I was hoping to grab just what I needed without having to load the whole page so there would be less server load – Kat Cox Nov 17 '13 at 10:40
  • As I already explained it is not possible to do that. What you can do instead is to make an HTTP request to get the entire HTML page and then extract the portion you are interested in. For example if you want to get a `
    ` with `id="abc"` you could use the `getElementById('abc')` function.
    – Darin Dimitrov Nov 17 '13 at 10:41
  • Actually, I read your answer as saying some servers might support portions... "if the server doesn't support returning only a portion"... so either I read it wrong, or you phrased it badly lol... looks like I have some research to do tomorrow. – Kat Cox Nov 17 '13 at 10:46