Skip to content

Commit

Permalink
First step at saving a user's artwork history. Saving artwork IDs to …
Browse files Browse the repository at this point in the history
…a cookie [#14]
  • Loading branch information
nikhiltri committed May 29, 2019
1 parent 1c59b26 commit 59de86f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"newtab": "newtab.html"
},
"permissions": [
"activeTab"
"cookies",
"activeTab",
"*://newtab.artic.edu/"
]
}
19 changes: 19 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@ function getArtworkData() {
var downloadUrl = 'https://www.artic.edu/iiif/2/' + imageID + '/full/3000,/0/default.jpg'
document.getElementById("download-link").setAttribute('href', downloadUrl);
document.getElementById("download-link").setAttribute('download', titlePrint + '.jpg');

if (chrome) {
cookie = chrome.cookies.get({
url: "http://newtab.artic.edu",
name: "tabHistory"
}, function (cookie) {
ids = cookie ? JSON.parse(cookie.value) : [];
console.log(ids);
ids.push("" + myObj.data[0].id);
chrome.cookies.set({
url: "http://newtab.artic.edu",
name: "tabHistory",
value: JSON.stringify(ids),
});
});
}
else {
// Support for other browsers
}
}
};

Expand Down

0 comments on commit 59de86f

Please sign in to comment.