10 examples of 'chrome.tabs.getcurrent' in JavaScript

Every line of 'chrome.tabs.getcurrent' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
281function getTabForBrowser(browser) {
282
283 if (isFennec) {
284 var windows = adguard.windowsImpl.getWindows();
285 for (var i = 0; i < windows.length; i++) {
286 var win = windows[i];
287 // this function may be called when not using fennec
288 if (!win.BrowserApp) {
289 continue;
290 }
291 var tabs = win.BrowserApp.tabs;
292 for (var j = 0; j < tabs.length; j++) {
293 var tab = tabs[j];
294 if (tab.browser === browser) {
295 return tab;
296 }
297 }
298 }
299 }
300
301 var tabbrowser = browser.getTabBrowser && browser.getTabBrowser();
302 if (!tabbrowser) {
303 return null;
304 }
305
306 var index;
307 if (isFennec) {
308 // Fennec
309 // https://developer.mozilla.org/en-US/Add-ons/Firefox_for_Android/API/BrowserApp
310 index = tabbrowser.tabs.indexOf(tabbrowser.getTabForBrowser(browser));
311 } else {
312 index = tabbrowser.browsers.indexOf(browser);
313 }
314 if (!tabbrowser.tabs || index < 0 || index >= tabbrowser.tabs.length) {
315 return null;
316 }
317 return tabbrowser.tabs[index];
318}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

193addTab(tabProperties, { animate = true, background = false } = {}) {
194 const tabEl = this.createNewTabEl()
195
196 if (animate) {
197 tabEl.classList.add('chrome-tab-was-just-added')
198 setTimeout(() => tabEl.classList.remove('chrome-tab-was-just-added'), 500)
199 }
200
201 tabProperties = Object.assign({}, defaultTapProperties, tabProperties)
202 this.tabContentEl.appendChild(tabEl)
203 this.setTabCloseEventListener(tabEl)
204 this.updateTab(tabEl, tabProperties)
205 this.emit('tabAdd', { tabEl })
206 if (!background) this.setCurrentTab(tabEl)
207 this.cleanUpPreviouslyDraggedTabs()
208 this.layoutTabs()
209 this.setupDraggabilly()
210}
30function getCurrentTabID() {
31 return new Promise((resolve) => {
32 chrome.tabs.getCurrent(({ id: tabID }) => {
33 resolve(tabID);
34 });
35 });
36}
3function getCurrentTabs(callback) {
4 // Query filter to be passed to chrome.tabs.query - see
5 // https://developer.chrome.com/extensions/tabs#method-query
6 var queryInfo = {
7 active: true,
8 currentWindow: true
9 };
10
11 chrome.tabs.query(queryInfo, function(tabs) {
12 // TODO: Won't necessarily work when code is run as a background plugin instead of as a popup
13 // chrome.tabs.query invokes the callback with a list of tabs that match the
14 // query. When the popup is opened, there is certainly a window and at least
15 // one tab, so we can safely assume that |tabs| is a non-empty array.
16 // A window can only have one active tab at a time, so the array consists of
17 // exactly one tab.
18 callback(tabs);
19 });
20}
58function onTabChanged(tabId, windowId) {
59 if (isWindowClosing[windowId])
60 return;
61 getPopulatedWindow(windowId, function(browserWindow) {
62 // if the window is saved, we update it
63 if (windowIdToName[windowId]) {
64 tabIdToSavedWindowId[tabId] = windowId;
65 var name = windowIdToName[windowId];
66 var displayName = savedWindows[name].displayName;
67 storeWindow(browserWindow, name, displayName);
68 } else {
69 // otherwise we double check that it's not saved
70 for (i in closedWindows) {
71 var savedWindow = closedWindows[i];
72 if (windowsAreEqual(browserWindow, savedWindow)) {
73 var name = savedWindow.name;
74 var displayName = savedWindow.displayName;
75 storeWindow(browserWindow, name, displayName);
76 markWindowAsOpen(browserWindow);
77 }
78 }
79 }
80 if (tabId) {
81 updateBadgeForTab({id:tabId, windowId:windowId});
82 }
83 });
84}
238public getCurrentTab(callback: (tab: chrome.tabs.Tab) => void): void {
239 chrome.tabs.getCurrent((tab: chrome.tabs.Tab) => {
240 callback(tab);
241 });
242}
104async closeCurrentTab() {
105 await this.driver.close();
106 return this;
107}
168getActiveTabId() {
169 return this.getActiveTab()._id;
170}
23function current_tab()
24{
25 return window.tab_view.get_nth_page(window.tab_view.page);
26}
140function getCurrentTab(callback) {
141 chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
142 callback(tabs[0])
143 })
144}

Related snippets