構文
js
var duplicating = browser.tabs.duplicate(
tabId, // integer
);
パラメーター
tabId-
integer. 複製するタブの ID を指定します。
戻り値
A Promise that will be fulfilled with a tabs.Tab object containing details about the duplicated tab. The Tab object only contains url, title and favIconUrl if the extension has the "tabs" permission. If any error occurs the promise will be rejected with an error message.
ブラウザーの互換性
Loading…
例
1つ目のタブを複製し、新しく作られたタブの ID をログに残す例:
js
function onDuplicated(tabInfo) {
console.log(tabInfo.id);
}
function onError(error) {
console.log(`Error: ${error}`);
}
// Duplicate the first tab in the array
function duplicateFirstTab(tabs) {
console.log(tabs);
if (tabs.length > 0) {
var duplicating = browser.tabs.duplicate(tabs[0].id);
duplicating.then(onDuplicated, onError);
}
}
// Query for all open tabs
var querying = browser.tabs.query({});
querying.then(duplicateFirstTab, onError);
Example extensions
メモ:
この API は Chromiums の chrome.tabs API に基づいています。 This documentation is derived from tabs.json in the Chromium code.