webext-schema
Advanced tools
Comparing version 5.2.10 to 5.3.0
@@ -993,2 +993,40 @@ /** | ||
/** | ||
* capture visible tab | ||
* @param {number} windowId - window ID | ||
* @param {object} opt - options | ||
* @returns {Promise.<?string>} - data URL | ||
*/ | ||
export const captureVisibleTab = async (windowId, opt) => { | ||
const info = await runtime.getBrowserInfo(); | ||
let isGranted; | ||
if (info.vender === 'Mozilla') { | ||
const browserVersion = parseFloat(info.version); | ||
isGranted = (browserVersion >= 126 && await isPermissionGranted({ | ||
permissions: ['activeTab'] | ||
})) || await isPermissionGranted({ | ||
origins: ['<all_urls>'] | ||
}); | ||
} else { | ||
isGranted = await isPermissionGranted({ | ||
permissions: ['activeTab'] | ||
}) || await isPermissionGranted({ | ||
origins: ['<all_urls>'] | ||
}); | ||
} | ||
let url; | ||
if (isGranted) { | ||
if (!Number.isInteger(windowId)) { | ||
windowId = windows.WINDOW_ID_CURRENT; | ||
} | ||
if (!opt) { | ||
opt = { | ||
format: 'png' | ||
}; | ||
} | ||
url = await tabs.captureVisibleTab(windowId, opt); | ||
} | ||
return url ?? null; | ||
}; | ||
/** | ||
* is tab | ||
@@ -995,0 +1033,0 @@ * @param {*} tabId - tab ID |
@@ -24,3 +24,3 @@ { | ||
"@types/firefox-webext-browser": "^120.0.3", | ||
"@types/node": "^20.11.30", | ||
"@types/node": "^20.12.7", | ||
"@types/sinon": "^17.0.3", | ||
@@ -32,9 +32,9 @@ "c8": "^9.1.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-jsdoc": "^48.2.1", | ||
"eslint-plugin-regexp": "^2.3.0", | ||
"eslint-plugin-unicorn": "^51.0.1", | ||
"mocha": "^10.3.0", | ||
"eslint-plugin-jsdoc": "^48.2.3", | ||
"eslint-plugin-regexp": "^2.5.0", | ||
"eslint-plugin-unicorn": "^52.0.0", | ||
"mocha": "^10.4.0", | ||
"npm-run-all": "^4.1.5", | ||
"typescript": "^5.4.2", | ||
"undici": "^6.9.0" | ||
"typescript": "^5.4.5", | ||
"undici": "^6.13.0" | ||
}, | ||
@@ -59,3 +59,3 @@ "scripts": { | ||
}, | ||
"version": "5.2.10" | ||
"version": "5.3.0" | ||
} |
@@ -53,2 +53,3 @@ export function isPermissionGranted(perm: object): Promise<boolean>; | ||
export function warmupTab(tabId: number): Promise<void>; | ||
export function captureVisibleTab(windowId: number, opt: object): Promise<string | null>; | ||
export function isTab(tabId: any): Promise<boolean>; | ||
@@ -55,0 +56,0 @@ export function getCurrentTheme(windowId?: number): Promise<object>; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3670437
102580