2016-07-21 19:45:32 +02:00
|
|
|
const apis = [
|
|
|
|
'alarms',
|
|
|
|
'bookmarks',
|
|
|
|
'browserAction',
|
|
|
|
'commands',
|
|
|
|
'contextMenus',
|
|
|
|
'cookies',
|
|
|
|
'downloads',
|
|
|
|
'events',
|
|
|
|
'extension',
|
|
|
|
'extensionTypes',
|
|
|
|
'history',
|
|
|
|
'i18n',
|
|
|
|
'idle',
|
|
|
|
'notifications',
|
|
|
|
'pageAction',
|
|
|
|
'runtime',
|
|
|
|
'storage',
|
|
|
|
'tabs',
|
|
|
|
'webNavigation',
|
|
|
|
'webRequest',
|
|
|
|
'windows',
|
|
|
|
]
|
|
|
|
|
|
|
|
function Extension () {
|
|
|
|
const _this = this
|
|
|
|
|
|
|
|
apis.forEach(function (api) {
|
2016-07-26 02:47:14 +02:00
|
|
|
|
|
|
|
_this[api] = null
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (chrome[api]) {
|
|
|
|
_this[api] = chrome[api]
|
|
|
|
}
|
|
|
|
} catch (e) {}
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (window[api]) {
|
|
|
|
_this[api] = window[api]
|
|
|
|
}
|
|
|
|
} catch (e) {}
|
|
|
|
|
2016-08-17 01:46:44 +02:00
|
|
|
try {
|
|
|
|
if (browser[api]) {
|
|
|
|
_this[api] = browser[api]
|
|
|
|
}
|
2016-08-17 02:32:54 +02:00
|
|
|
} catch (e) {}
|
2016-07-26 02:47:14 +02:00
|
|
|
try {
|
|
|
|
_this.api = browser.extension[api]
|
|
|
|
} catch (e) {}
|
2016-07-21 19:45:32 +02:00
|
|
|
})
|
2016-08-30 02:33:18 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
if (browser && browser.runtime) {
|
|
|
|
this.runtime = browser.runtime
|
|
|
|
}
|
|
|
|
} catch (e) {}
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (browser && browser.browserAction) {
|
|
|
|
this.browserAction = browser.browserAction
|
|
|
|
}
|
|
|
|
} catch (e) {}
|
|
|
|
|
2016-07-21 19:45:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Extension
|