Last active
May 21, 2017 04:25
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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