Log changes only to tabs whose url
property is matched by "https://developer.mozilla.org/*" or "https://twitter.com/mozdevnet":
const pattern1 = "https://developer.mozilla.org/*";
const pattern2 = "https://twitter.com/mozdevnet";
const filter = {
urls: [pattern1, pattern2]
}
function handleUpdated(tabId, changeInfo, tabInfo) {
console.log(`Updated tab: ${tabId}`);
console.log("Changed attributes: ", changeInfo);
console.log("New tab Info: ", tabInfo);
}
browser.tabs.onUpdated.addListener(handleUpdated, filter);
Log changes only to the pinned
property of tabs (i.e. pin and unpin actions):
const filter = {
properties: ["pinned"]
}
function handleUpdated(tabId, changeInfo, tabInfo) {
console.log(`Updated tab: ${tabId}`);
console.log("Changed attributes: ", changeInfo);
console.log("New tab Info: ", tabInfo);
}
browser.tabs.onUpdated.addListener(handleUpdated, filter);
Combine both the previous filters: log changes only:
- to the
pinned
property of tabs
- whose
url
property is matched by "https://developer.mozilla.org/*" or "https://twitter.com/mozdevnet":
const pattern1 = "https://developer.mozilla.org/*";
const pattern2 = "https://twitter.com/mozdevnet";
const filter = {
urls: [pattern1, pattern2],
properties: ["pinned"]
}
function handleUpdated(tabId, changeInfo, tabInfo) {
console.log(`Updated tab: ${tabId}`);
console.log("Changed attributes: ", changeInfo);
console.log("New tab Info: ", tabInfo);
}
browser.tabs.onUpdated.addListener(
handleUpdated,
filter);
Log changes only:
- to the
pinned
property of tabs
- whose
url
property is matched by "https://developer.mozilla.org/*" or "https://twitter.com/mozdevnet"
- and which are part of the current browser window at the time the update event is fired:
const pattern1 = "https://developer.mozilla.org/*";
const pattern2 = "https://twitter.com/mozdevnet";
const filter = {
urls: [pattern1, pattern2],
properties: ["pinned"],
windowId: browser.windows.WINDOW_ID_CURRENT
}
function handleUpdated(tabId, changeInfo, tabInfo) {
console.log(`Updated tab: ${tabId}`);
console.log("Changed attributes: ", changeInfo);
console.log("New tab Info: ", tabInfo);
}
browser.tabs.onUpdated.addListener(
handleUpdated,
filter);