Update inline documentation

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

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

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

@ -7,7 +7,8 @@ const {
setCategories,
analyze,
analyzeManyToMany,
resolve
resolve,
open
} = Wappalyzer
const { agent, promisify, getOption, setOption } = Utils
@ -17,9 +18,10 @@ const Driver = {
lastPing: Date.now(),
/**
* Initialize Chrome extension.
* Initialise driver
*/
async init() {
// Enable messaging between scripts
chrome.runtime.onConnect.addListener(Driver.onRuntimeConnect)
await Driver.loadTechnologies()
@ -69,16 +71,16 @@ const Driver = {
const upgradeMessage = await getOption('upgradeMessage', true)
if (previous === null) {
Driver.open('https://www.wappalyzer.com/installed')
open('https://www.wappalyzer.com/installed')
} 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)
},
/**
* Logging utility function.
* Log debug messages to the console
* @param {String} message
* @param {String} source
* @param {String} type
@ -89,7 +91,7 @@ const Driver = {
},
/**
* Error utility function.
* Log errors to the console
* @param {String} error
* @param {String} source
*/
@ -98,16 +100,7 @@ const Driver = {
},
/**
* Open browser tab utility function.
* @param {String} url
* @param {Boolean} active
*/
open(url, active = true) {
chrome.tabs.create({ url, active })
},
/**
* Load technologies into memory.
* Load technologies and categories into memory
*/
async loadTechnologies() {
try {
@ -123,7 +116,7 @@ const Driver = {
},
/**
* Post-wrapper for fetch.
* Perform a HTTP POST request
* @param {String} url
* @param {String} body
*/
@ -139,7 +132,7 @@ const Driver = {
},
/**
* Analyize JavaScript detections.
* Analyse JavaScript variables
* @param {String} url
* @param {Array} js
*/
@ -160,7 +153,7 @@ const Driver = {
},
/**
* Initialize PostMessage interface.
* Enable scripts to call Driver functions through messaging
* @param {Object} port
*/
onRuntimeConnect(port) {
@ -187,7 +180,7 @@ const Driver = {
},
/**
* Callback for WebRequestComplete listener.
* Analyse response headers
* @param {Object} request
*/
async onWebRequestComplete(request) {
@ -224,7 +217,7 @@ const Driver = {
},
/**
* Callback for onContentLoad listener.
* Process return values from content.js
* @param {String} url
* @param {Object} items
* @param {String} language
@ -252,14 +245,14 @@ const Driver = {
},
/**
* Get technology detections.
* Get all technologies
*/
getTechnologies() {
return Wappalyzer.technologies
},
/**
* Callback for detections.
* Callback for detections
* @param {String} url
* @param {Array} detections
* @param {String} language
@ -350,7 +343,7 @@ const Driver = {
},
/**
* Callback for onAd listener.
* Callback for onAd listener
* @param {Object} ad
*/
async onAd(ad) {
@ -360,7 +353,7 @@ const Driver = {
},
/**
* Generate linked icon for detections.
* Update the extension icon
* @param {String} url
* @param {Object} technologies
*/
@ -400,7 +393,7 @@ const Driver = {
},
/**
* Get detections from site.
* Get the detected technologies for the current tab
*/
async getDetections() {
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 {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
*/
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() {
const tracking = await getOption('tracking', true)

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

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

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

Loading…
Cancel
Save