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 (that is, 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 only when the pinned
property of tabs changes for 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 when the pinned
property of tabs changes for tabs whose url
property is matched by https://developer.mozilla.org/*
or https://twitter.com/mozdevnet
where the tab was part of the current browser window when the update event 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);