webext-schema
Advanced tools
Comparing version 4.2.1 to 5.0.0
@@ -38,3 +38,3 @@ /** | ||
} | ||
return node || null; | ||
return node ?? null; | ||
}; | ||
@@ -46,3 +46,3 @@ | ||
* @param {string|Array} id - bookmark ID or array of bookmark IDs | ||
* @returns {Array} - array of bookmarks.BookmarkTreeNode | ||
* @returns {?Array} - array of bookmarks.BookmarkTreeNode | ||
*/ | ||
@@ -64,3 +64,3 @@ export const getBookmarkTreeNode = async id => { | ||
} | ||
return res || null; | ||
return res ?? null; | ||
}; | ||
@@ -83,3 +83,3 @@ | ||
} | ||
return userValue || null; | ||
return userValue ?? null; | ||
}; | ||
@@ -142,3 +142,3 @@ | ||
} | ||
return res || null; | ||
return res ?? null; | ||
}; | ||
@@ -193,3 +193,3 @@ | ||
} | ||
return func || null; | ||
return func ?? null; | ||
}; | ||
@@ -210,9 +210,5 @@ | ||
const { contextualIdentities } = browser; | ||
try { | ||
arr = await contextualIdentities.query({}); | ||
} catch (e) { | ||
logErr(e); | ||
} | ||
arr = await contextualIdentities.query({}); | ||
} | ||
return arr || null; | ||
return arr ?? null; | ||
}; | ||
@@ -236,9 +232,5 @@ | ||
const { contextualIdentities } = browser; | ||
try { | ||
id = await contextualIdentities.get(cookieStoreId); | ||
} catch (e) { | ||
logErr(e); | ||
} | ||
id = await contextualIdentities.get(cookieStoreId); | ||
} | ||
return id || null; | ||
return id ?? null; | ||
}; | ||
@@ -259,13 +251,8 @@ | ||
const { management } = browser; | ||
try { | ||
const arr = await management.getAll(); | ||
if (Array.isArray(arr) && arr.length) { | ||
res = | ||
arr.filter(info => info?.type === 'theme' && info?.enabled && info); | ||
} | ||
} catch (e) { | ||
logErr(e); | ||
const arr = await management.getAll(); | ||
if (Array.isArray(arr) && arr.length) { | ||
res = arr.filter(info => info?.type === 'theme' && info?.enabled && info); | ||
} | ||
} | ||
return res || null; | ||
return res ?? null; | ||
}; | ||
@@ -291,3 +278,3 @@ | ||
} | ||
return ext || null; | ||
return ext ?? null; | ||
}; | ||
@@ -298,3 +285,3 @@ | ||
* | ||
* @returns {?Array} -array of management.extensionInfo | ||
* @returns {?Array|boolean} -array of management.extensionInfo | ||
*/ | ||
@@ -308,13 +295,8 @@ export const getExternalExtensions = async () => { | ||
const { management } = browser; | ||
try { | ||
const arr = await management.getAll(); | ||
if (Array.isArray(arr) && arr.length) { | ||
res = | ||
arr.filter(info => info?.type === 'extension' && info); | ||
} | ||
} catch (e) { | ||
logErr(e); | ||
const arr = await management.getAll(); | ||
if (Array.isArray(arr) && arr.length) { | ||
res = arr.filter(info => info?.type === 'extension' && info); | ||
} | ||
} | ||
return res || null; | ||
return res ?? null; | ||
}; | ||
@@ -341,3 +323,3 @@ | ||
} | ||
return func || null; | ||
return func ?? null; | ||
}; | ||
@@ -367,3 +349,3 @@ | ||
} | ||
return func || null; | ||
return func ?? null; | ||
}; | ||
@@ -504,5 +486,53 @@ | ||
} | ||
return func || null; | ||
return func ?? null; | ||
}; | ||
/* scripting */ | ||
/** | ||
* is scripting available | ||
* | ||
* @returns {boolean} - result | ||
*/ | ||
export const isScriptingAvailable = async () => { | ||
const isGranted = await isPermissionGranted({ | ||
permissions: ['scripting'] | ||
}); | ||
let res; | ||
if (isGranted) { | ||
const { scripting } = browser; | ||
res = typeof scripting?.executeScript === 'function'; | ||
} | ||
return !!res; | ||
}; | ||
/** | ||
* execute script to tab | ||
* | ||
* @param {object} opt - options | ||
* @returns {?Array|boolean} - array of InjectionResult object | ||
*/ | ||
export const executeScriptToTab = async (opt = {}) => { | ||
const { args, injectImmediately, files, func, target } = opt; | ||
const isGranted = await isScriptingAvailable(); | ||
let fn; | ||
if (isGranted && Number.isInteger(target?.tabId)) { | ||
const { scripting } = browser; | ||
if (Array.isArray(files) && files.length) { | ||
fn = scripting.executeScript({ | ||
files, | ||
target, | ||
injectImmediately: !!injectImmediately | ||
}); | ||
} else if (typeof func === 'function') { | ||
fn = scripting.executeScript({ | ||
func, | ||
target, | ||
args: Array.isArray(args) ? args : null, | ||
injectImmediately: !!injectImmediately | ||
}); | ||
} | ||
} | ||
return fn ?? null; | ||
}; | ||
/* search */ | ||
@@ -561,3 +591,3 @@ /** | ||
} | ||
return tab || null; | ||
return tab ?? null; | ||
}; | ||
@@ -587,3 +617,3 @@ | ||
} | ||
return value || null; | ||
return value ?? null; | ||
}; | ||
@@ -609,3 +639,3 @@ | ||
} | ||
return ses || null; | ||
return ses ?? null; | ||
}; | ||
@@ -671,3 +701,3 @@ | ||
} | ||
return data || null; | ||
return data ?? null; | ||
}; | ||
@@ -692,3 +722,3 @@ | ||
} | ||
return data || null; | ||
return data ?? null; | ||
}; | ||
@@ -846,3 +876,3 @@ | ||
} | ||
return res || null; | ||
return res ?? null; | ||
}; | ||
@@ -972,3 +1002,3 @@ | ||
} | ||
return arr || null; | ||
return arr ?? null; | ||
}; | ||
@@ -1072,3 +1102,3 @@ | ||
} | ||
return currentTheme || null; | ||
return currentTheme ?? null; | ||
}; | ||
@@ -1075,0 +1105,0 @@ |
@@ -51,3 +51,3 @@ { | ||
}, | ||
"version": "4.2.1" | ||
"version": "5.0.0" | ||
} |
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
3420277
96488
2