Skip to content

Commit

Permalink
fixes #24
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-portmen committed Oct 18, 2017
1 parent 224bc78 commit a879ac6
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 37 deletions.
30 changes: 0 additions & 30 deletions Misc/translation/ro/webstore.txt

This file was deleted.

6 changes: 3 additions & 3 deletions WebExtension/_locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@
"message": "Benutzerdefinierte URL"
},
"optionsSaveButton": {
+ "message": "Speichern"
+ },
"message": "Speichern"
},
"optionsMSG": {
"message": "Einstellungen gespeichert."
},
Expand Down Expand Up @@ -758,7 +758,7 @@
"country_SD": {
"message": "Sudan"
},
"country_SR": {
"country_SR": {
"message": "Suriname"
},
"country_SJ": {
Expand Down
5 changes: 3 additions & 2 deletions WebExtension/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function resolve(tabId) {
}
}

chrome.webRequest.onResponseStarted.addListener(({ip, tabId, url}) => {
var onResponseStarted = ({ip, tabId, url}) => {
if (!ip) {
return;
}
Expand Down Expand Up @@ -170,7 +170,8 @@ chrome.webRequest.onResponseStarted.addListener(({ip, tabId, url}) => {
else {
set({ip}, false, true);
}
}, {
};
chrome.webRequest.onResponseStarted.addListener(onResponseStarted, {
urls: ['<all_urls>'],
types: ['main_frame']
}, []);
Expand Down
30 changes: 30 additions & 0 deletions WebExtension/existing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* globals onResponseStarted */
'use strict';

document.addEventListener('DOMContentLoaded', () => chrome.tabs.query({
url: '*://*/*'
}, tabs => {
if (tabs.length) {
const cache = tabs.reduce((p, c) => {
p[c.url] = c.id;
return p;
}, {});

const init = d => cache[d.url] && onResponseStarted({
ip: d.ip,
tabId: cache[d.url],
url: d.url
});

chrome.webRequest.onResponseStarted.addListener(init, {
urls: ['*://*/*'],
types: ['xmlhttprequest']
}, []);

Promise.all(
tabs.map(t => fetch(t.url).then(r => r.headers.get('content-type')).catch(() => {}))
).then(() => {
chrome.webRequest.onResponseStarted.removeListener(init);
});
}
}));
5 changes: 3 additions & 2 deletions WebExtension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"short_name": "icflags",
"description": "__MSG_appDesc__",
"author": "Andy Portmen",
"version": "0.2.0",
"version": "0.2.1",
"default_locale": "en",
"manifest_version": 2,
"permissions": [
Expand All @@ -28,7 +28,8 @@
"background": {
"scripts": [
"utils.js",
"common.js"
"common.js",
"existing.js"
]
},
"page_action": {},
Expand Down

0 comments on commit a879ac6

Please sign in to comment.