1
0
Fork 0

show last modified date in popup

This commit is contained in:
Lukas Winkler 2017-09-20 15:52:40 +02:00
parent 4d6d63bf19
commit e7c94a0f8b
3 changed files with 17 additions and 4 deletions

View file

@ -3,7 +3,7 @@ function handleMessage(request, sender, sendResponse) {
if (request.typo3) {
chrome.storage.local.get(request.url, function (result) {
var data = result[request.url];
if (!data || Date.now() - data.updated > 1000 * 60) {
if (!data || Date.now() - data.updated > 1000 * 60 * 60 * 24) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function () {
var found;
@ -15,7 +15,11 @@ function handleMessage(request, sender, sendResponse) {
chrome.browserAction.disable(tabId);
}
var data = {};
data[request.url] = {found: found, modified: false, updated: Date.now()};
data[request.url] = {
found: found,
modified: xmlHttp.getResponseHeader('Last-Modified'),
updated: Date.now()
};
chrome.storage.local.set(data);
};
xmlHttp.open("GET", request.url + "/typo3conf/ext/mask/ext_icon.gif", true);

View file

@ -2,9 +2,10 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<title>Mask Detector</title>
</head>
<body>
<div id="lastModified" style="width: 200px"></div>
<script src="popup.js"></script>
</body>
</html>

8
popup.js Normal file
View file

@ -0,0 +1,8 @@
chrome.tabs.query({active: true}, function (tabs) {
var url = new URL(tabs[0].url);
var key = url.protocol + "//" + url.host;
chrome.storage.local.get(key, function (result) {
document.getElementById("lastModified").innerText = result[key].modified;
});
});