Update inline documentation

main
Elbert Alias 4 years ago
parent 42560d53e4
commit 8caee3841a

@ -8,6 +8,10 @@
--color-light-grey: #fafafa; --color-light-grey: #fafafa;
} }
* {
box-sizing: border-box;
}
body { body {
background: #fff; background: #fff;
color: var(--color-text); color: var(--color-text);
@ -17,6 +21,8 @@ body {
line-height: 1.5rem; line-height: 1.5rem;
margin: 0; margin: 0;
min-width: 35rem; min-width: 35rem;
overflow-x: hidden;
padding-bottom: 3rem;
} }
a { a {
@ -51,11 +57,15 @@ a:hover {
.footer { .footer {
align-items: center; align-items: center;
background: #fff;
bottom: 0;
justify-content: space-between; justify-content: space-between;
border-top: 1px solid var(--color-secondary); border-top: 1px solid var(--color-secondary);
height: 3rem; height: 3rem;
display: flex; display: flex;
padding: 0 1.5rem; padding: 0 1.5rem;
position: fixed;
width: 100%;
} }
.alerts__icon { .alerts__icon {
@ -258,6 +268,7 @@ a:hover {
} }
.theme-mode .footer { .theme-mode .footer {
background: var(--color-primary-darken);
border-color: var(--color-secondary-dark) border-color: var(--color-secondary-dark)
} }

@ -4,11 +4,12 @@
const Content = { const Content = {
/** /**
* Initialize content detection. * Initialise content script
*/ */
async init() { async init() {
await new Promise((resolve) => setTimeout(resolve, 1000)) await new Promise((resolve) => setTimeout(resolve, 1000))
// Enable messaging to and from driver.js
Content.port = chrome.runtime.connect({ name: 'content.js' }) Content.port = chrome.runtime.connect({ name: 'content.js' })
Content.port.onMessage.addListener(({ func, args }) => { Content.port.onMessage.addListener(({ func, args }) => {
@ -23,6 +24,7 @@ const Content = {
// HTML // HTML
let html = new XMLSerializer().serializeToString(document) let html = new XMLSerializer().serializeToString(document)
// Discard the middle portion of HTML to avoid performance degradation on large pages
const chunks = [] const chunks = []
const maxCols = 2000 const maxCols = 2000
const maxRows = 3000 const maxRows = 3000
@ -36,6 +38,7 @@ const Content = {
html = chunks.join('\n') html = chunks.join('\n')
// Determine language based on the HTML lang attribute or content
const language = const language =
document.documentElement.getAttribute('lang') || document.documentElement.getAttribute('lang') ||
document.documentElement.getAttribute('xml:lang') || document.documentElement.getAttribute('xml:lang') ||
@ -81,10 +84,11 @@ const Content = {
}, },
/** /**
* Callback for fetching technologies. * Callback for getTechnologies
* @param {Object} technologies * @param {Object} technologies
*/ */
onGetTechnologies(technologies) { onGetTechnologies(technologies) {
// Inject a script tag into the page to access methods of the window object
const script = document.createElement('script') const script = document.createElement('script')
script.onload = () => { script.onload = () => {

@ -7,7 +7,8 @@ const {
setCategories, setCategories,
analyze, analyze,
analyzeManyToMany, analyzeManyToMany,
resolve resolve,
open
} = Wappalyzer } = Wappalyzer
const { agent, promisify, getOption, setOption } = Utils const { agent, promisify, getOption, setOption } = Utils
@ -17,9 +18,10 @@ const Driver = {
lastPing: Date.now(), lastPing: Date.now(),
/** /**
* Initialize Chrome extension. * Initialise driver
*/ */
async init() { async init() {
// Enable messaging between scripts
chrome.runtime.onConnect.addListener(Driver.onRuntimeConnect) chrome.runtime.onConnect.addListener(Driver.onRuntimeConnect)
await Driver.loadTechnologies() await Driver.loadTechnologies()
@ -69,16 +71,16 @@ const Driver = {
const upgradeMessage = await getOption('upgradeMessage', true) const upgradeMessage = await getOption('upgradeMessage', true)
if (previous === null) { if (previous === null) {
Driver.open('https://www.wappalyzer.com/installed') open('https://www.wappalyzer.com/installed')
} else if (version !== previous && upgradeMessage) { } else if (version !== previous && upgradeMessage) {
Driver.open(`https://www.wappalyzer.com/upgraded?v${version}`, false) open(`https://www.wappalyzer.com/upgraded?v${version}`, false)
} }
await setOption('version', version) await setOption('version', version)
}, },
/** /**
* Logging utility function. * Log debug messages to the console
* @param {String} message * @param {String} message
* @param {String} source * @param {String} source
* @param {String} type * @param {String} type
@ -89,7 +91,7 @@ const Driver = {
}, },
/** /**
* Error utility function. * Log errors to the console
* @param {String} error * @param {String} error
* @param {String} source * @param {String} source
*/ */
@ -98,16 +100,7 @@ const Driver = {
}, },
/** /**
* Open browser tab utility function. * Load technologies and categories into memory
* @param {String} url
* @param {Boolean} active
*/
open(url, active = true) {
chrome.tabs.create({ url, active })
},
/**
* Load technologies into memory.
*/ */
async loadTechnologies() { async loadTechnologies() {
try { try {
@ -123,7 +116,7 @@ const Driver = {
}, },
/** /**
* Post-wrapper for fetch. * Perform a HTTP POST request
* @param {String} url * @param {String} url
* @param {String} body * @param {String} body
*/ */
@ -139,7 +132,7 @@ const Driver = {
}, },
/** /**
* Analyize JavaScript detections. * Analyse JavaScript variables
* @param {String} url * @param {String} url
* @param {Array} js * @param {Array} js
*/ */
@ -160,7 +153,7 @@ const Driver = {
}, },
/** /**
* Initialize PostMessage interface. * Enable scripts to call Driver functions through messaging
* @param {Object} port * @param {Object} port
*/ */
onRuntimeConnect(port) { onRuntimeConnect(port) {
@ -187,7 +180,7 @@ const Driver = {
}, },
/** /**
* Callback for WebRequestComplete listener. * Analyse response headers
* @param {Object} request * @param {Object} request
*/ */
async onWebRequestComplete(request) { async onWebRequestComplete(request) {
@ -224,7 +217,7 @@ const Driver = {
}, },
/** /**
* Callback for onContentLoad listener. * Process return values from content.js
* @param {String} url * @param {String} url
* @param {Object} items * @param {Object} items
* @param {String} language * @param {String} language
@ -252,14 +245,14 @@ const Driver = {
}, },
/** /**
* Get technology detections. * Get all technologies
*/ */
getTechnologies() { getTechnologies() {
return Wappalyzer.technologies return Wappalyzer.technologies
}, },
/** /**
* Callback for detections. * Callback for detections
* @param {String} url * @param {String} url
* @param {Array} detections * @param {Array} detections
* @param {String} language * @param {String} language
@ -350,7 +343,7 @@ const Driver = {
}, },
/** /**
* Callback for onAd listener. * Callback for onAd listener
* @param {Object} ad * @param {Object} ad
*/ */
async onAd(ad) { async onAd(ad) {
@ -360,7 +353,7 @@ const Driver = {
}, },
/** /**
* Generate linked icon for detections. * Update the extension icon
* @param {String} url * @param {String} url
* @param {Object} technologies * @param {Object} technologies
*/ */
@ -400,7 +393,7 @@ const Driver = {
}, },
/** /**
* Get detections from site. * Get the detected technologies for the current tab
*/ */
async getDetections() { async getDetections() {
const [{ id }] = await promisify(chrome.tabs, 'query', { const [{ id }] = await promisify(chrome.tabs, 'query', {
@ -412,7 +405,7 @@ const Driver = {
}, },
/** /**
* Check for robot rules on site. * Fetch the website's robots.txt rules
* @param {String} hostname * @param {String} hostname
* @param {Boolean} secure * @param {Boolean} secure
*/ */
@ -484,7 +477,7 @@ const Driver = {
}, },
/** /**
* Check for robots.txt rules. * Check if the website allows indexing of a URL
* @param {String} href * @param {String} href
*/ */
async checkRobots(href) { async checkRobots(href) {
@ -505,7 +498,8 @@ const Driver = {
}, },
/** /**
* Ping back home. * Anonymously send identified technologies to wappalyzer.com
* This function can be disabled in the extension settings
*/ */
async ping() { async ping() {
const tracking = await getOption('tracking', true) const tracking = await getOption('tracking', true)

@ -6,7 +6,7 @@ const { i18n, getOption, setOption } = Utils
const Options = { const Options = {
/** /**
* Initialize Chrome options. * Initialise options
*/ */
async init() { async init() {
// Theme mode // Theme mode

@ -2,13 +2,13 @@
/* eslint-env browser */ /* eslint-env browser */
/* globals chrome, Utils */ /* globals chrome, Utils */
const { agent, i18n, getOption, setOption, promisify } = Utils const { agent, open, i18n, getOption, setOption, promisify } = Utils
const Popup = { const Popup = {
port: chrome.runtime.connect({ name: 'popup.js' }), port: chrome.runtime.connect({ name: 'popup.js' }),
/** /**
* Initialize popup. * Initialise popup
*/ */
async init() { async init() {
// Templates // Templates
@ -50,7 +50,7 @@ const Popup = {
Popup.driver('getDetections') Popup.driver('getDetections')
}) })
// Run internationalization. // Apply internationalization
i18n() i18n()
} }
@ -72,7 +72,7 @@ const Popup = {
}, },
/** /**
* Apply function to postMessage request. * Call a function on driver.js through messaging
* @param {function} func * @param {function} func
* @param {...any} args * @param {...any} args
*/ */
@ -81,7 +81,7 @@ const Popup = {
}, },
/** /**
* Log message. * Log debug messages to the console
* @param {String} message * @param {String} message
*/ */
log(message) { log(message) {
@ -89,7 +89,7 @@ const Popup = {
}, },
/** /**
* Group technologies into categories. * Group technologies into categories
* @param {Object} technologies * @param {Object} technologies
*/ */
categorise(technologies) { categorise(technologies) {
@ -110,7 +110,7 @@ const Popup = {
}, },
/** /**
* Callback for getDetection listener. * Callback for getDetection listener
* @param {Array} detections * @param {Array} detections
*/ */
async onGetDetections(detections) { async onGetDetections(detections) {
@ -200,7 +200,7 @@ const Popup = {
a.addEventListener('click', (event) => { a.addEventListener('click', (event) => {
event.preventDefault() event.preventDefault()
Popup.driver('open', a.href) open(a.href)
return false return false
}) })
@ -210,7 +210,7 @@ const Popup = {
} }
} }
// Add listener for popup PostMessage API. // Add listener for popup PostMessage API
Popup.port.onMessage.addListener(({ func, args }) => { Popup.port.onMessage.addListener(({ func, args }) => {
const onFunc = `on${func.charAt(0).toUpperCase() + func.slice(1)}` const onFunc = `on${func.charAt(0).toUpperCase() + func.slice(1)}`

@ -6,7 +6,7 @@ const Utils = {
agent: chrome.extension.getURL('/').startsWith('moz-') ? 'firefox' : 'chrome', agent: chrome.extension.getURL('/').startsWith('moz-') ? 'firefox' : 'chrome',
/** /**
* Promise utility tool. * Use promises instead of callbacks
* @param {Object} context * @param {Object} context
* @param {String} method * @param {String} method
* @param {...any} args * @param {...any} args
@ -24,7 +24,7 @@ const Utils = {
}, },
/** /**
* Chrome tab utility. * Open a browser tab
* @param {String} url * @param {String} url
* @param {Boolean} active * @param {Boolean} active
*/ */
@ -33,7 +33,7 @@ const Utils = {
}, },
/** /**
* Get value from local storage. * Get value from local storage
* @param {String} name * @param {String} name
* @param {string|mixed|null} defaultValue * @param {string|mixed|null} defaultValue
*/ */
@ -52,7 +52,7 @@ const Utils = {
}, },
/** /**
* Set value in local storage. * Set value in local storage
* @param {String} name * @param {String} name
* @param {String} value * @param {String} value
*/ */
@ -67,7 +67,7 @@ const Utils = {
}, },
/** /**
* Load internationalization. * Apply internationalization
*/ */
i18n() { i18n() {
Array.from(document.querySelectorAll('[data-i18n]')).forEach( Array.from(document.querySelectorAll('[data-i18n]')).forEach(

Loading…
Cancel
Save