1
0
Fork 0

also support tv and show typo3 version

This commit is contained in:
Lukas Winkler 2017-09-22 11:08:12 +02:00
parent aacbefe730
commit 04bcbde06d
13 changed files with 163 additions and 96 deletions

View file

@ -1,71 +1,92 @@
function enabled(tabId) {
function displayData(data, tabId, typo3) {
var icon;
if (typo3) {
chrome.pageAction.show(tabId);
chrome.pageAction.setIcon({
tabId: tabId,
path: {
"128": "logo.128.png"
if (data.mask.found) {
icon = "icon";
} else if (data.tv.found) {
icon = "icon-tv";
} else if (typo3) {
icon = "icon-typo3";
} else {
icon = "icon-disabled";
}
})
}
function disabled(tabId) {
} else {
chrome.pageAction.hide(tabId);
icon = "icon-disabled";
}
chrome.pageAction.setIcon({
tabId: tabId,
path: {
"128": "logo-disabled.128.png"
}
})
}
function typo3(tabId) {
chrome.pageAction.show(tabId);
chrome.pageAction.setIcon({
tabId: tabId,
path: {
"128": "logo-typo3.128.png"
"128": "img/" + icon + ".128.png"
}
})
}
function handleMessage(request, sender, sendResponse) {
function handleMessage(request, sender) {
console.log("recieved message");
var tabId = sender.tab.id;
if (request.typo3) {
chrome.storage.local.get(request.url, function (result) {
var data = result[request.url];
if (!data || Date.now() - data.updated > 1000 * 60 * 60 * 24) {
data = {};
var xmlHttp = new XMLHttpRequest();
data.mask = {};
xmlHttp.onreadystatechange = function () {
var found;
if (xmlHttp.readyState === 4) {
if (xmlHttp.status === 200) {
found = true;
enabled(tabId);
} else {
found = false;
typo3(tabId);
data.mask.found = xmlHttp.status === 200;
data.mask.modified = xmlHttp.getResponseHeader('Last-Modified');
var tvHttp = new XMLHttpRequest();
data.tv = {};
tvHttp.onreadystatechange = function () {
if (tvHttp.readyState === 4) {
data.tv.found = tvHttp.status === 200;
data.tv.modified = tvHttp.getResponseHeader('Last-Modified');
var cl = new XMLHttpRequest();
cl.onreadystatechange = function () {
if (cl.readyState === 4) {
if (cl.status === 200) {
var changelog = cl.responseText.split('\n', 1)[0];
const regex = /(\d\.)+(\d+)/;
var match = regex.exec(changelog);
data.t3version = match[0];
}
console.log("saving data");
data.updated = Date.now();
displayData(data, tabId, true);
var storage = {};
storage[request.url] = data;
chrome.storage.local.set(storage);
}
};
cl.open("GET", request.url + "/typo3_src/ChangeLog", true);
console.log("request changelog");
cl.send();
}
};
tvHttp.open("GET", request.url + "/typo3conf/ext/templavoila/ext_icon.gif", true);
console.log("request tv icon");
tvHttp.send();
}
}
var data = {};
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);
console.log("request mask icon");
xmlHttp.send();
} else {
if (data.found) {
enabled(tabId);
} else {
typo3(tabId);
}
else {
displayData(data, tabId, true)
}
});
}
else {
disabled(tabId);
displayData(false, tabId, false)
}
}

View file

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
img/icon-tv.128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

75
img/icon-tv.svg Normal file
View file

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
inkscape:export-filename="/home/lukas/mask-detector/img/icon-tv.128.png"
inkscape:export-xdpi="78.769234"
inkscape:export-ydpi="78.769234"
version="1.1"
id="Ebene_1"
x="0px"
y="0px"
width="156px"
height="156px"
viewBox="0 0 156 156"
enable-background="new 0 0 156 156"
xml:space="preserve"
sodipodi:docname="icon-tv.svg"
inkscape:version="0.92.1 r15371"><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="2560"
inkscape:window-height="1381"
id="namedview14"
showgrid="false"
inkscape:zoom="4.2857017"
inkscape:cx="-4.6341215"
inkscape:cy="70.331276"
inkscape:window-x="0"
inkscape:window-y="30"
inkscape:window-maximized="1"
inkscape:current-layer="Ebene_1"
inkscape:snap-page="true"
inkscape:snap-bbox="true"
inkscape:bbox-paths="true"
inkscape:bbox-nodes="true"
inkscape:snap-bbox-midpoints="true"
inkscape:snap-bbox-edge-midpoints="true"
inkscape:snap-intersection-paths="true"
inkscape:object-paths="true"
inkscape:snap-smooth-nodes="true"
inkscape:snap-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-text-baseline="true"
inkscape:snap-center="true" /><metadata
id="metadata18"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
id="defs16"><linearGradient
osb:paint="solid"
id="linearGradient4500"><stop
id="stop4498"
offset="0"
style="stop-color:#d4372f;stop-opacity:1;" /></linearGradient></defs><image
y="11.14286"
x="0"
id="image4539"
xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAASCAYAAAC0EpUuAAAABHNCSVQICAgIfAhkiAAAAYdJREFU OI3VlD9IAmEYh5+LIgkE/2HQpIuDQRANCY4dQdAQRkuDGGZwDjmnBEVFcxA5BYEQBA5tQtBsSwQh Di4u4pQg0uDp8DXonXeleLr1g+Pue7+X537ve+998F8kjUtQkklht9sngs5aSTq+iFuCNdsNUpFT a1ArsIKao/idA9YBEOOu85u0cHmd+np7d0vk67ei1qmY9sJpn5BlWcz0Xybxt796LK7ESGUU02bI s0mz3SCuxFhdWSOc9rGYaAytxOgQgA1ZFrVORZRaRZNbzWm+fitcXqcotYoiUrWbnI5UIBAAwGFz c3hwpMdfL8sAZKPPpDIKBTWnuxoLNSqa2cHldfZgd3fcZx/4+HxnYb9pypsICpjc3lxlSWUU/N2g oWETQh02t8ktwPLeEtW5sv6ZpWmcOmxufRJ+T8QopxLDxwuAt68X3V047TP3ctryQ55N/f509oK/ G+yVrtnpy9JvqjkEeFRPANifvx4ADRJWoRroT0wdnm8J2koMDglNkmH9+/kHLTWZnXvvepEAAAAA SUVORK5CYII= "
preserveAspectRatio="none"
height="133.71428"
width="156" /></svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
img/icon-typo3.128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

@ -22,7 +22,7 @@
viewBox="0 0 156 156"
enable-background="new 0 0 156 156"
xml:space="preserve"
sodipodi:docname="logo-typo3.svg"
sodipodi:docname="icon-typo3.svg"
inkscape:version="0.92.1 r15371"><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
@ -37,7 +37,7 @@
id="namedview14"
showgrid="false"
inkscape:zoom="3.0304487"
inkscape:cx="39.060074"
inkscape:cx="-40.961079"
inkscape:cy="51.178855"
inkscape:window-x="0"
inkscape:window-y="30"
@ -58,37 +58,14 @@
inkscape:snap-center="true" /><metadata
id="metadata18"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
id="defs16"><linearGradient
osb:paint="solid"
id="linearGradient4500"><stop
id="stop4498"
offset="0"
style="stop-color:#d4372f;stop-opacity:1;" /></linearGradient></defs><g
id="g5466"
transform="matrix(0.58753569,0,0,0.58753569,0,-0.00247479)"><g
id="Ebene_5"
style="opacity:1;fill:#818181;fill-opacity:1"><rect
y="-0.0060000001"
width="156"
height="156.006"
id="rect2"
style="opacity:1;fill:#818181;fill-opacity:1"
x="0" /></g><g
id="g5458"><path
d="m 78.832,65.861 c -42.577,0 -65.75,-22.59 -66,6 1.163,30.728 21.47,28.14 29,26 7.157,-2.033 31.357,-9.361 31.357,-9.361 2.418,-0.967 5.561,-1.209 8.611,-0.125 8.367,2.971 20.537,8.066 29.863,10.176 15.066,3.117 29.117,-2.301 30.17,-26.695 1.258,-29.149 -20.424,-5.995 -63.001,-5.995 z"
id="path5"
inkscape:connector-curvature="0"
style="fill:#ffffff" /><path
d="m 55.448,81.583 c -10.5,4.498 -20.952,3.875 -21.113,3.758 -7.063,-5.137 -6.995,-13.083 -6.995,-13.083 0.164,0 32.771,4.275 35.103,4.923 0.449,0.125 -2.462,2.461 -6.995,4.402 z"
id="path7"
inkscape:connector-curvature="0"
style="opacity:1;fill:#818181;fill-opacity:1" /><path
d="m 120.249,85.21 c 0,0 -9.066,1.166 -21.762,-4.275 -1.471,-0.631 -6.9,-3.883 -6.08,-4.051 0.104,-0.021 34.709,-4.541 34.727,-4.755 0,-0.001 1.24,6.063 -6.885,13.081 z"
id="path9"
inkscape:connector-curvature="0"
style="opacity:1;fill:#818181;fill-opacity:1" /></g></g><g
transform="matrix(1.0130529,0,0,1.0130529,1.6888545,1.6627988)"
transform="matrix(1.542693,0,0,1.542693,-79.996084,-79.027133)"
id="g5413"><path
d="m 128.03114,120.91486 c -1.50125,0.4425 -2.6975,0.595 -4.2625,0.595 -12.84,0 -31.7,-44.87 -31.7,-59.80375 0,-5.50125 1.30625,-7.335 3.1425,-8.90625 -15.7175,1.8325 -34.58,7.5975 -40.6075,14.9325 -1.30875,1.835 -2.095,4.71625 -2.095,8.3825 0,23.3175 24.8875,76.23375 42.44125,76.23375 8.12,0 21.81625,-13.36 33.08125,-31.43375"
id="path5775"

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="156px" height="156px" viewBox="0 0 156 156" enable-background="new 0 0 156 156" xml:space="preserve">
<g id="Ebene_5">
<rect y="-0.006" fill="#D4372F" width="156" height="156.006"/>
</g>
<g>
<path fill="#FFFFFF" d="M78.832,65.861c-42.577,0-65.75-22.59-66,6c1.163,30.728,21.47,28.14,29,26
c7.157-2.033,31.357-9.361,31.357-9.361c2.418-0.967,5.561-1.209,8.611-0.125c8.367,2.971,20.537,8.066,29.863,10.176
c15.066,3.117,29.117-2.301,30.17-26.695C143.091,42.707,121.409,65.861,78.832,65.861z"/>
<path fill="#D4372F" d="M55.448,81.583c-10.5,4.498-20.952,3.875-21.113,3.758c-7.063-5.137-6.995-13.083-6.995-13.083
c0.164,0,32.771,4.275,35.103,4.923C62.892,77.306,59.981,79.642,55.448,81.583z"/>
<path fill="#D4372F" d="M120.249,85.21c0,0-9.066,1.166-21.762-4.275c-1.471-0.631-6.9-3.883-6.08-4.051
c0.104-0.021,34.709-4.541,34.727-4.755C127.134,72.128,128.374,78.192,120.249,85.21z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -6,11 +6,11 @@
"author": "Lukas Winkler",
"description": "find websites using the mask Typo3 extension",
"icons": {
"128": "logo.128.png"
"128": "img/icon.128.png"
},
"page_action": {
"default_icon": {
"128": "logo-disabled.128.png"
"128": "img/icon-disabled.128.png"
},
"default_popup": "popup.html"
},

View file

@ -5,6 +5,7 @@
<title>Mask Detector</title>
</head>
<body>
<div id="typo3Version"></div>
<div id="lastModified" style="width: 200px"></div>
<script src="popup.js"></script>
</body>

View file

@ -2,8 +2,19 @@ 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) {
var text;
if (result[key]) {
document.getElementById("lastModified").innerText = result[key].modified;
if (result[key].mask.modified) {
text = result[key].mask.modified;
} else if (result[key].tv.modified) {
text = result[key].tv.modified
}
}
if (text) {
document.getElementById("lastModified").innerText = text;
}
if (result[key].t3version) {
document.getElementById("typo3Version").innerText = result[key].t3version;
}
});
});