convert chrome. to browser. Issue #165 #166 (#262)

* convert chrome. to browser. Issue #165

* fix browser-polyfill

* convert chrome.* to browser.* (#166)

* convert chrome.* to browser.*

* change chrome to browser

* change the callback-style to promise-style

* change the callback-style to promise-style
This commit is contained in:
Maxim Zalata
2017-09-12 01:23:41 +03:00
committed by wbamberg
parent 8daa8b29c2
commit f369ddc642
5 changed files with 7 additions and 7 deletions

View File

@@ -10,4 +10,4 @@ All it does is:
It shows: It shows:
* how to use chrome.commands to register keyboard shortcuts for your extension. * how to use browser.commands to register keyboard shortcuts for your extension.

View File

@@ -12,4 +12,4 @@ var Background = {
} }
}; };
chrome.runtime.onMessage.addListener(Background.receiveMessage); browser.runtime.onMessage.addListener(Background.receiveMessage);

View File

@@ -3,7 +3,7 @@
if($game.innerText !== 'ping'){ if($game.innerText !== 'ping'){
$game.innerText = 'ping'; $game.innerText = 'ping';
} else{ } else{
chrome.runtime.sendMessage({action: 'ping'},function(response) { browser.runtime.sendMessage({action: 'ping'}).then((response) => {
$game.innerText = response; $game.innerText = response;
}); });
} }

View File

@@ -11,7 +11,7 @@ class Popup extends React.Component {
componentDidMount() { componentDidMount() {
// Get the active tab and store it in component state. // Get the active tab and store it in component state.
chrome.tabs.query({active: true}, tabs => { browser.tabs.query({active: true}).then(tabs => {
this.setState({activeTab: tabs[0]}); this.setState({activeTab: tabs[0]});
}); });
} }

View File

@@ -164,12 +164,12 @@ document.addEventListener("click", (e) => {
else if (e.target.classList.contains('switch-tabs')) { else if (e.target.classList.contains('switch-tabs')) {
var tabId = +e.target.getAttribute('href'); var tabId = +e.target.getAttribute('href');
chrome.tabs.query({ browser.tabs.query({
currentWindow: true currentWindow: true
}, (tabs) => { }).then((tabs) => {
for (var tab of tabs) { for (var tab of tabs) {
if (tab.id === tabId) { if (tab.id === tabId) {
chrome.tabs.update(tabId, { browser.tabs.update(tabId, {
active: true active: true
}); });
} }