Merge pull request #6804 from nurbek91/drupal1

Update Drupal / cms
main
Elbert Alias 2 years ago committed by GitHub
commit a19696c9b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,7 +10,7 @@ const {
resolve, resolve,
getTechnology, getTechnology,
} = Wappalyzer } = Wappalyzer
const { agent, promisify, getOption, setOption, open, globEscape } = Utils const { agent, getOption, setOption, open, globEscape } = Utils
const expiry = 1000 * 60 * 60 * 24 const expiry = 1000 * 60 * 60 * 24
@ -93,7 +93,7 @@ const Driver = {
chrome.tabs.onUpdated.addListener(async (id, { status, url }) => { chrome.tabs.onUpdated.addListener(async (id, { status, url }) => {
if (status === 'complete') { if (status === 'complete') {
;({ url } = await promisify(chrome.tabs, 'get', id)) ;({ url } = await chrome.tabs.get(id))
} }
if (url) { if (url) {
@ -335,7 +335,7 @@ const Driver = {
}, },
async content(url, func, args) { async content(url, func, args) {
const [tab] = await promisify(chrome.tabs, 'query', { const [tab] = await chrome.tabs.query({
url: globEscape(url), url: globEscape(url),
}) })
@ -347,29 +347,23 @@ const Driver = {
throw new Error(`Tab ${tab.id} not ready for sendMessage: ${tab.status}`) throw new Error(`Tab ${tab.id} not ready for sendMessage: ${tab.status}`)
} }
return new Promise((resolve, reject) => { const response = await chrome.tabs.sendMessage(tab.id, {
chrome.tabs.sendMessage( source: 'driver.js',
tab.id, func,
{ args: args ? (Array.isArray(args) ? args : [args]) : [],
source: 'driver.js',
func,
args: args ? (Array.isArray(args) ? args : [args]) : [],
},
(response) => {
chrome.runtime.lastError
? func === 'error'
? resolve()
: Driver.error(
new Error(
`${
chrome.runtime.lastError.message
}: Driver.${func}(${JSON.stringify(args)})`
)
)
: resolve(response)
}
)
}) })
if (chrome.runtime.lastError && func !== 'error') {
Driver.error(
new Error(
`${chrome.runtime.lastError.message}: Driver.${func}(${JSON.stringify(
args
)})`
)
)
} else {
return response
}
}, },
/** /**
@ -387,7 +381,7 @@ const Driver = {
try { try {
await new Promise((resolve) => setTimeout(resolve, 500)) await new Promise((resolve) => setTimeout(resolve, 500))
const [tab] = await promisify(chrome.tabs, 'query', { const [tab] = await chrome.tabs.query({
url: globEscape(request.url), url: globEscape(request.url),
}) })
@ -502,7 +496,7 @@ const Driver = {
// //
;( ;(
await promisify(chrome.cookies, 'getAll', { await chrome.cookies.getAll({
url, url,
}) })
).forEach( ).forEach(
@ -673,7 +667,7 @@ const Driver = {
let tabs = [] let tabs = []
try { try {
tabs = await promisify(chrome.tabs, 'query', { tabs = await chrome.tabs.query({
url: globEscape(url), url: globEscape(url),
}) })
} catch (error) { } catch (error) {
@ -734,7 +728,7 @@ const Driver = {
let tabs = [] let tabs = []
try { try {
tabs = await promisify(chrome.tabs, 'query', { tabs = await chrome.tabs.query({
url: globEscape(url), url: globEscape(url),
}) })
} catch (error) { } catch (error) {
@ -773,7 +767,7 @@ const Driver = {
* Get the detected technologies for the current tab * Get the detected technologies for the current tab
*/ */
async getDetections() { async getDetections() {
const tab = await promisify(chrome.tabs, 'query', { const tab = await chrome.tabs.query({
active: true, active: true,
currentWindow: true, currentWindow: true,
}) })

@ -2,8 +2,7 @@
/* eslint-env browser */ /* eslint-env browser */
/* globals chrome, Utils */ /* globals chrome, Utils */
const { agent, open, i18n, getOption, setOption, promisify, sendMessage } = const { agent, open, i18n, getOption, setOption, sendMessage } = Utils
Utils
const baseUrl = 'https://www.wappalyzer.com' const baseUrl = 'https://www.wappalyzer.com'
const utm = '?utm_source=popup&utm_medium=extension&utm_campaign=wappalyzer' const utm = '?utm_source=popup&utm_medium=extension&utm_campaign=wappalyzer'
@ -345,7 +344,7 @@ const Popup = {
let url let url
const tabs = await promisify(chrome.tabs, 'query', { const tabs = await chrome.tabs.query({
active: true, active: true,
currentWindow: true, currentWindow: true,
}) })
@ -962,7 +961,7 @@ const Popup = {
new Blob([csv.join('\n')], { type: 'text/csv;charset=utf-8' }) new Blob([csv.join('\n')], { type: 'text/csv;charset=utf-8' })
) )
const granted = await promisify(chrome.permissions, 'request', { const granted = await chrome.permissions.request({
permissions: ['downloads'], permissions: ['downloads'],
}) })

@ -5,13 +5,6 @@
// Manifest v2 polyfill // Manifest v2 polyfill
if (chrome.runtime.getManifest().manifest_version === 2) { if (chrome.runtime.getManifest().manifest_version === 2) {
chrome.action = chrome.browserAction chrome.action = chrome.browserAction
chrome.storage.sync = {
get: (...args) =>
new Promise((resolve) => chrome.storage.local.get(...args, resolve)),
set: (...args) =>
new Promise((resolve) => chrome.storage.local.set(...args, resolve)),
}
} }
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
@ -22,24 +15,6 @@ const Utils = {
? 'safari' ? 'safari'
: 'chrome', : 'chrome',
/**
* Use promises instead of callbacks
* @param {Object} context
* @param {String} method
* @param {...any} args
*/
promisify(context, method, ...args) {
return new Promise((resolve, reject) => {
context[method](...args, (...args) => {
if (chrome.runtime.lastError) {
return reject(chrome.runtime.lastError)
}
resolve(...args)
})
})
},
/** /**
* Open a browser tab * Open a browser tab
* @param {String} url * @param {String} url
@ -56,7 +31,7 @@ const Utils = {
*/ */
async getOption(name, defaultValue = null) { async getOption(name, defaultValue = null) {
try { try {
const option = await chrome.storage.sync.get(name) const option = await chrome.storage.local.get(name)
if (option[name] !== undefined) { if (option[name] !== undefined) {
return option[name] return option[name]
@ -76,7 +51,7 @@ const Utils = {
*/ */
async setOption(name, value) { async setOption(name, value) {
try { try {
await chrome.storage.sync.set({ await chrome.storage.local.set({
[name]: value, [name]: value,
}) })
} catch (error) { } catch (error) {

@ -74,11 +74,11 @@
"options_page": "html/options.html", "options_page": "html/options.html",
"permissions": [ "permissions": [
"cookies", "cookies",
"storage",
"scripting", "scripting",
"storage",
"tabs", "tabs",
"webRequest", "webNavigation",
"webNavigation" "webRequest"
], ],
"host_permissions": [ "host_permissions": [
"http://*/*", "http://*/*",
@ -90,4 +90,4 @@
"content_security_policy": { "content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'" "extension_pages": "script-src 'self'; object-src 'self'"
} }
} }

@ -1497,6 +1497,7 @@
}, },
"oss": true, "oss": true,
"scriptSrc": "drupal\\.js", "scriptSrc": "drupal\\.js",
"scripts": "drupal_internal__nid",
"website": "https://drupal.org" "website": "https://drupal.org"
}, },
"Drupal Commerce": { "Drupal Commerce": {