mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-17 14:59:12 +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:
|
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'){
|
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;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
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() {
|
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]});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user