Skip to content

Instantly share code, notes, and snippets.

@seth10
Created August 28, 2016 19:52
Show Gist options
  • Save seth10/870c5eb792f6ddde1e2db6db22ab7690 to your computer and use it in GitHub Desktop.
Save seth10/870c5eb792f6ddde1e2db6db22ab7690 to your computer and use it in GitHub Desktop.
Use the current chapter number in the callback with let to keep the value at that time
for(var n = 1; n <= fic_info['max_chapters']; n++) {
let n_ = n;
getChapter(fic_info['url']+n, function(page) {
(chrome.extension.getBackgroundPage()).addChapter(page, n_, fic_info['max_chapters']);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment