Skip to content
Snippets Groups Projects
Verified Commit 861ba95d authored by Thomas Rientjes's avatar Thomas Rientjes
Browse files

Improve cross-browser compatibility

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