commit 4d6d63bf19ad4d439ba32a84f49d9bdd9f4fd43b Author: Lukas Winkler Date: Wed Sep 20 15:33:18 2017 +0200 first working version diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/background.js b/background.js new file mode 100644 index 0000000..a6f8fcd --- /dev/null +++ b/background.js @@ -0,0 +1,38 @@ +function handleMessage(request, sender, sendResponse) { + 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) { + var xmlHttp = new XMLHttpRequest(); + xmlHttp.onreadystatechange = function () { + var found; + if (xmlHttp.readyState === 4 && xmlHttp.status === 200) { + found = true; + chrome.browserAction.enable(tabId); + } else { + found = false; + chrome.browserAction.disable(tabId); + } + var data = {}; + data[request.url] = {found: found, modified: false, updated: Date.now()}; + chrome.storage.local.set(data); + }; + xmlHttp.open("GET", request.url + "/typo3conf/ext/mask/ext_icon.gif", true); + xmlHttp.send(); + } else { + if (data.found) { + chrome.browserAction.enable(tabId); + console.info("found"); + } else { + chrome.browserAction.disable(tabId); + } + } + }); + } + else { + chrome.browserAction.disable(tabId); + } +} + +chrome.runtime.onMessage.addListener(handleMessage); diff --git a/contentscript.js b/contentscript.js new file mode 100644 index 0000000..e777ffc --- /dev/null +++ b/contentscript.js @@ -0,0 +1,4 @@ +chrome.runtime.sendMessage({ + typo3: document.head.innerHTML.indexOf("This website is powered by TYPO3") !== -1, + url: window.location.protocol + "//" + window.location.host +}); diff --git a/logo.128.png b/logo.128.png new file mode 100644 index 0000000..9b27688 Binary files /dev/null and b/logo.128.png differ diff --git a/logo.svg b/logo.svg new file mode 100644 index 0000000..808d894 --- /dev/null +++ b/logo.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..b6897da --- /dev/null +++ b/manifest.json @@ -0,0 +1,35 @@ +{ + "manifest_version": 2, + "name": "Mask Detector", + "short_name": "mask-detector", + "version": "0.0.1", + "author": "Lukas Winkler", + "description": "find sites using the mask Typo3 extension", + "icons": { + "128": "logo.128.png" + }, + "browser_action": { + "default_icon": { + "128": "logo.128.png" + }, + "default_popup": "popup.html" + }, + "content_scripts": [ + { + "matches": [""], + "js": ["contentscript.js"] + } + ], + + "permissions": [ + "storage", + "http://*/", + "https://*/", + "tabs" + ], + "background": { + "scripts": [ + "background.js" + ] + } +} \ No newline at end of file diff --git a/popup.html b/popup.html new file mode 100644 index 0000000..566549b --- /dev/null +++ b/popup.html @@ -0,0 +1,10 @@ + + + + + Title + + + + + \ No newline at end of file