Combining two functions

9 views
Skip to first unread message

Slavko Kocjancic

unread,
Mar 27, 2013, 1:10:06 PM3/27/13
to greasemon...@googlegroups.com
Hello...

I try to write GM script.
On the start I wan't to save all href's to local server and that works...

//Send all url's to server
var allLinks, thisLink;
allLinks = document.evaluate('//a[@href]',document, null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < allLinks.snapshotLength; i++) {
  thisLink = allLinks.snapshotItem(i);
  GM_xmlhttpRequest({
    method: 'POST',
    url: 'http://127.0.0.1/vaje/test.php',
    headers: {'Content-type': 'application/x-www-form-urlencoded'},
    data: 'par='+thisLink,
    onload: function(responseDetails) {}
  });
};


I wan't to automaticaly click the url with Next > text (url is java script tag)
This work's too

//click to next page.
var TargetLink              = $("a:contains('Next >')");
if (TargetLink  &&  TargetLink.length) window.location.href    = TargetLink[0].href;

Now the problem is that program separated works without problem, but cant figure out how to combine both. So that links are saved and click is done after that.
If both part's are present then neither works!

Help

Slavko.

Reply all
Reply to author
Forward
0 new messages