MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / getCurrentTab

Function getCurrentTab

scripts/helpers/utils.js:290–304  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

288};
289
290export const getCurrentTab = async () => {
291 try {
292 // case normal popup
293 let tabs = await chrome?.tabs?.query?.({
294 active: true,
295 currentWindow: true,
296 });
297 if (tabs?.[0]?.url !== getPopupURL()) return tabs[0];
298
299 return await getLastFocusedTab();
300 } catch (err) {
301 console.log(err);
302 return null;
303 }
304};
305
306export const getCurrentTabId = async () => {
307 return (await getCurrentTab())?.id;

Callers 15

webToPDF.jsFile · 0.90
runScriptFunction · 0.90
index.jsFile · 0.90
refreshSpecialTabsFunction · 0.90
getCurrentTabIdFunction · 0.70
getCurrentTabUrlFunction · 0.70
runScriptInCurrentTabFunction · 0.70
checkWebDie.jsFile · 0.50

Calls 2

getPopupURLFunction · 0.85
getLastFocusedTabFunction · 0.85

Tested by

no test coverage detected