I have made an extension that will track what manga a person reads on a manga site and list what chapter they last read for it in their favorites page. And I've recently come up with a useful feature to make the extension a little bit better. I would like to give the user the option to be able to track only manga that they have Favorited on the site. So as they are reading, the extension will constantly check in the background if it is in their favorites and if so then save it and if not don't save it.
The website has a favorites page that holds a list of all of the manga a person has Favorited. I would like to be able to constantly grab the names of each manga listed on that page in the background hidden from the user.
So my question is, is there any way to grab the html of a specific page in the background and constantly grab specific data such as text of certain elements to save to an array, without the user having to actually be on the favorites page?
Edit: Solution
var barray = [];
function getbm(callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(data) {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var data = xhr.responseText;
callback(data);
} else {
callback(null);
}
}
}
var url = 'http://mangafox.me/bookmark/index.php?status=all';
xhr.open('GET', url, true);
xhr.send();
};
function res(data) {
var parsed = $.parseHTML(data);
parsed = $('<div />').append(parsed);
parsed.find('h2.title').each(function(){
var bmanga = $(this).children('a.title').text();
barray.push({"manga": bmanga});
});
chrome.storage.local.set({'bData': barray})
};
getbm(res);