Skip to content

Instantly share code, notes, and snippets.

@cat-in-136
Last active May 21, 2017 04:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cat-in-136/4d8b548c26f812adf46f81031aea6501 to your computer and use it in GitHub Desktop.
Save cat-in-136/4d8b548c26f812adf46f81031aea6501 to your computer and use it in GitHub Desktop.
iis-sensor : show a page notification if served by Microsoft-IIS server
"use strict";
var IIS_SERVER_LIST = new Set();
browser.webRequest.onHeadersReceived.addListener((e) => {
for (let header of e.responseHeaders) {
if ("server" === header.name.toLowerCase()) {
if (header.value.startsWith("Microsoft-IIS/")) {
let url = new URL(e.url);
IIS_SERVER_LIST.add(url.host);
}
break;
}
}
}, {
urls: ["<all_urls>"]
}, ["responseHeaders"]);
browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (tab.url) {
let url = new URL(tab.url);
if (IIS_SERVER_LIST.has(url.host)) {
browser.pageAction.show(tab.id);
} else {
browser.pageAction.hide(tab.id);
}
}
});
{
"description": "IIS web server sensor",
"manifest_version": 2,
"name": "iis-sensor",
"version": "0.0.0",
"homepage_url": "https://twitter.com/diffshare/status/865016052622610432",
"permissions": [
"activeTab",
"tabs",
"webRequest",
"<all_urls>"
],
"page_action": {
"default_icon": "iis.png",
"browser_style": true
},
"background": {
"scripts": ["background.js"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment