mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 06:18:35 +02:00
* 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:
@@ -10,4 +10,4 @@ All it does is:
|
||||
|
||||
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.
|
||||
|
||||
@@ -12,4 +12,4 @@ var Background = {
|
||||
}
|
||||
};
|
||||
|
||||
chrome.runtime.onMessage.addListener(Background.receiveMessage);
|
||||
browser.runtime.onMessage.addListener(Background.receiveMessage);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
if($game.innerText !== 'ping'){
|
||||
$game.innerText = 'ping';
|
||||
} else{
|
||||
chrome.runtime.sendMessage({action: 'ping'},function(response) {
|
||||
browser.runtime.sendMessage({action: 'ping'}).then((response) => {
|
||||
$game.innerText = response;
|
||||
});
|
||||
}
|
||||
|
||||
2
react-es6-popup/src/popup.js
vendored
2
react-es6-popup/src/popup.js
vendored
@@ -11,7 +11,7 @@ class Popup extends React.Component {
|
||||
|
||||
componentDidMount() {
|
||||
// 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]});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -164,12 +164,12 @@ document.addEventListener("click", (e) => {
|
||||
else if (e.target.classList.contains('switch-tabs')) {
|
||||
var tabId = +e.target.getAttribute('href');
|
||||
|
||||
chrome.tabs.query({
|
||||
browser.tabs.query({
|
||||
currentWindow: true
|
||||
}, (tabs) => {
|
||||
}).then((tabs) => {
|
||||
for (var tab of tabs) {
|
||||
if (tab.id === tabId) {
|
||||
chrome.tabs.update(tabId, {
|
||||
browser.tabs.update(tabId, {
|
||||
active: true
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user