Skip to content

Commit

Permalink
Load list of unsplash images when starting background page.
Browse files Browse the repository at this point in the history
  • Loading branch information
mscavnicky committed Mar 6, 2016
1 parent efede13 commit fe114dd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
var options = defaultOptions;
// Hash of times in milliseconds when particular domain was blocked.
var unblockTimes = {};
// The list of preloaded unsplash image links
var imageList = [];

function loadImageList() {
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (request.readyState == 4 && request.status == 200) {
imageList = JSON.parse(request.response);
}
};
request.open("GET", "https://unsplash.it/list", true);
request.send();
}

// Determine whether specific hostname is currently blocked. Domain is blocked
// if it is in the blocklist and was not recently unblocked.
Expand Down Expand Up @@ -42,6 +55,8 @@ function parsedBlocklist(blocklist) {
});
}

loadImageList();

// Load the options from storage.
chrome.storage.sync.get(options, function(items) {
_.mapObject(items, function (value, key) {
Expand Down

0 comments on commit fe114dd

Please sign in to comment.