Verified Commit 861ba95d authored by Thomas Rientjes's avatar Thomas Rientjes
Browse files

Improve cross-browser compatibility

parent b3931feb
...@@ -94,20 +94,6 @@ chrome.runtime.getPlatformInfo(function (information) { ...@@ -94,20 +94,6 @@ chrome.runtime.getPlatformInfo(function (information) {
main.operatingSystem = information.os; main.operatingSystem = information.os;
}); });
if (typeof chrome.browserAction.setBadgeBackgroundColor !== 'function') { wrappers.setBadgeBackgroundColor({
chrome.browserAction.setBadgeBackgroundColor = function () {};
chrome.browserAction.setBadgeText = function () {};
chrome.browserAction.onClicked.addListener(function () {
chrome.tabs.create({
'url': chrome.extension.getURL('pages/popup/popup.html'),
'active': false
});
});
}
chrome.browserAction.setBadgeBackgroundColor({
'color': [74, 130, 108, 255] 'color': [74, 130, 108, 255]
}); });
...@@ -37,14 +37,14 @@ stateManager.registerInjection = function (tabIdentifier, injection) { ...@@ -37,14 +37,14 @@ stateManager.registerInjection = function (tabIdentifier, injection) {
if (injectionCount > 0) { if (injectionCount > 0) {
chrome.browserAction.setBadgeText({ wrappers.setBadgeText({
'tabId': tabIdentifier, 'tabId': tabIdentifier,
'text': injectionCount.toString() 'text': injectionCount.toString()
}); });
} else { } else {
chrome.browserAction.setBadgeText({ wrappers.setBadgeText({
'tabId': tabIdentifier, 'tabId': tabIdentifier,
'text': '' 'text': ''
}); });
...@@ -114,12 +114,8 @@ stateManager._createTab = function (tab) { ...@@ -114,12 +114,8 @@ stateManager._createTab = function (tab) {
chrome.webRequest.onBeforeRequest.addListener(function (requestDetails) { chrome.webRequest.onBeforeRequest.addListener(function (requestDetails) {
return new Promise((resolve) => { let tab = stateManager.tabs[tabIdentifier].details || {};
return interceptor.handleRequest(requestDetails, tabIdentifier, tab);
browser.tabs.get(tabIdentifier).then(function (tab) {
resolve(interceptor.handleRequest(requestDetails, tabIdentifier, tab));
});
});
}, requestFilters, [WebRequest.BLOCKING]); }, requestFilters, [WebRequest.BLOCKING]);
}; };
...@@ -141,7 +137,7 @@ stateManager._updateTab = function (details) { ...@@ -141,7 +137,7 @@ stateManager._updateTab = function (details) {
if (stateManager.showIconBadge === true) { if (stateManager.showIconBadge === true) {
chrome.browserAction.setBadgeText({ wrappers.setBadgeText({
'tabId': tabIdentifier, 'tabId': tabIdentifier,
'text': '' 'text': ''
}); });
...@@ -203,7 +199,7 @@ stateManager._handleStorageChanged = function (changes) { ...@@ -203,7 +199,7 @@ stateManager._handleStorageChanged = function (changes) {
stateManager._removeIconBadgeFromTab = function (tab) { stateManager._removeIconBadgeFromTab = function (tab) {
chrome.browserAction.setBadgeText({ wrappers.setBadgeText({
'tabId': tab.id, 'tabId': tab.id,
'text': '' 'text': ''
}); });
...@@ -238,6 +234,17 @@ chrome.storage.local.get('showIconBadge', function (items) { ...@@ -238,6 +234,17 @@ chrome.storage.local.get('showIconBadge', function (items) {
chrome.tabs.onCreated.addListener(stateManager._createTab); chrome.tabs.onCreated.addListener(stateManager._createTab);
chrome.tabs.onRemoved.addListener(stateManager._removeTab); chrome.tabs.onRemoved.addListener(stateManager._removeTab);
chrome.webRequest.onBeforeRequest.addListener(function (requestDetails) {
if (requestDetails.tabId !== -1) {
stateManager.tabs[requestDetails.tabId].details = {
'url': requestDetails.url
};
}
}, {'types': ['main_frame'], 'urls': [Address.ANY]});
chrome.webNavigation.onCommitted.addListener(stateManager._updateTab, { chrome.webNavigation.onCommitted.addListener(stateManager._updateTab, {
'url': [{'urlContains': ':'}] 'url': [{'urlContains': ':'}]
}); });
......
...@@ -247,3 +247,14 @@ footer { ...@@ -247,3 +247,14 @@ footer {
font-style: italic; font-style: italic;
font-weight: 400; font-weight: 400;
} }
/**
* Compatibility
*/
@media screen and (-webkit-min-device-pixel-ratio: 0) {
body {
width: 348px;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment