Skip to content

Instantly share code, notes, and snippets.

@testingbot
Created September 28, 2012 09:49
Show Gist options
  • Save testingbot/3798926 to your computer and use it in GitHub Desktop.
Save testingbot/3798926 to your computer and use it in GitHub Desktop.
fetch all links, store in cookie, fetch them again
/* Store */
var elements = this.getDocument().getElementsByTagName('a');
var links = [];
for (var i = 0; i < elements.length; i++) {
links.push(elements[i].href);
}
this.browserbot.createCookie("links", JSON.stringify(links));
/* Fetch */
var links = this.browserbot.getCookieByName("links");
if (links) {
links = JSON.parse(links);
var newLink = links.shift();
this.browserbot.createCookie("links", JSON.stringify(links));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment