mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 06:18:35 +02:00
Added tabs.onRemoved and tabs.onMoved examples (#118)
This commit is contained in:
committed by
wbamberg
parent
b7048d83df
commit
81c4b3381c
@@ -28,7 +28,6 @@
|
||||
|
||||
<div class="panel-section-separator"></div>
|
||||
|
||||
|
||||
<a href="#" id="tabs-add-zoom">Zoom in</a><br>
|
||||
<a href="#" id="tabs-default-zoom">Reset zoom</a><br>
|
||||
<a href="#" id="tabs-decrease-zoom">Zoom out</a>
|
||||
|
||||
@@ -124,3 +124,21 @@ document.addEventListener("click", function(e) {
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
//onRemoved listener. fired when tab is removed
|
||||
chrome.tabs.onRemoved.addListener(function(tabId, removeInfo){
|
||||
console.log(`The tab with id: ${tabId}, is closing`);
|
||||
|
||||
if(removeInfo.isWindowClosing) {
|
||||
console.log(`Its window is also closing.`);
|
||||
} else {
|
||||
console.log(`Its window is not closing`);
|
||||
}
|
||||
});
|
||||
|
||||
//onMoved listener. fired when tab is moved into the same window
|
||||
chrome.tabs.onMoved.addListener(function(tabId, moveInfo){
|
||||
var startIndex = moveInfo.fromIndex;
|
||||
var endIndex = moveInfo.toIndex;
|
||||
console.log(`Tab with id: ${tabId} moved from index: ${startIndex} to index: ${endIndex}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user