Skip to content

Commit

Permalink
Added chromium compatibility workaround.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro-K committed Jun 24, 2018
1 parent c485bce commit b911981
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
43 changes: 30 additions & 13 deletions fx-vstup-ext/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,26 @@ function init_image_data(cb=null)
image.src = "favicon.png";
}

function tabs_query(query_info, func_ok, func_err)
{
if (typeof chrome === 'undefined')
{
return browser.tabs.query(query_info).then(func_ok, func_err);
}
else
{
return browser.tabs.query(query_info, func_ok);
}
}

function main()
{
window.browser = (function () {
return window.msBrowser ||
window.browser ||
window.chrome;
})();

var enabled = false;

// browser.tabs.query({active: true, currentWindow: true, url: "*://*.vstup.info/*"});
Expand All @@ -71,19 +89,18 @@ function main()
// browser.browserAction.setIcon({path: {16: enabled ? "favicon.png" : "favicon-gray.png"}});
// getImageData(x => browser.browserAction.setIcon({imageData: x}));
browser.browserAction.setIcon({imageData: {16: enabled ? gray_icon_data : color_icon_data}});

browser.tabs.query({active: true, currentWindow: true, url: "*://*.vstup.info/*"})
.then(
function (tabs) {
tabs.forEach(function (tab) {
console.log(tab.url);
browser.tabs.sendMessage(tab.id, {command: 3, data: enabled});
});
},
function onError(error) {
console.log(`Error: ${error}`);
}
);

tabs_query({active: true, currentWindow: true, url: "*://*.vstup.info/*"},
function (tabs) {
tabs.forEach(function (tab) {
console.log(tab.url);
browser.tabs.sendMessage(tab.id, {command: 3, data: enabled});
});
},
function onError(error) {
console.log(`Error: ${error}`);
}
);
}

browser.browserAction.onClicked.addListener(vstup_button_click_handler);
Expand Down
6 changes: 6 additions & 0 deletions fx-vstup-ext/src/fx-vstup-ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ function main()
return 0;
}

window.browser = (function () {
return window.msBrowser ||
window.browser ||
window.chrome;
})();

// document.body.querySelectorAll('*').forEach(x => x.style.backgroundColor = '#BB0000');
var el;
el = document.getElementById('myRedBox');
Expand Down

0 comments on commit b911981

Please sign in to comment.