Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
{
"options": { "message": "Options" },
"optionsSave": { "message": "Save options" },
"optionsSaved": { "message": "Saved" },
"optionDynamicIcon": { "message": "Use technology icon instead of Wappalyzer logo" },
"optionBadge": { "message": "Show the number of identified technologies on the icon" },
"optionShowCached": { "message": "Include cached detections in results" },
"disableOnDomain": { "message": "Disable on this website" },
"clearCache": { "message": "Clear cached detections" },
"nothingToDo": { "message": "Nothing to do here." },
"noAppsDetected": { "message": "No technologies detected." },
"reloadPage": { "message": "Reload" },
"categoryPin": { "message": "Always show icon" },
"tabTechnologies": { "message": "Technologies" },
"issue": { "message": "Something wrong or missing?" },

"categoryName1": { "message": "CMS" },
Expand Down
15 changes: 0 additions & 15 deletions src/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -605,21 +605,6 @@ body.dynamic-icon .category__heading:hover .category__pin {
width: 100%;
}

.options__cache {
background: var(--color-primary);
border: none;
border-radius: 4px;
color: var(--color-primary-lighten);
cursor: pointer;
font-size: .85rem;
font-weight: bold;
padding: .8rem 1.5rem;
margin-bottom: 1.5rem;
}

.options__cache:active {
opacity: .9;
}

@keyframes blink {
50% {
Expand Down
37 changes: 0 additions & 37 deletions src/html/options.html

This file was deleted.

19 changes: 1 addition & 18 deletions src/html/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title data-i18n="options"></title>
<title>Wappalyzer</title>

<link rel="stylesheet" href="../css/styles.css">

Expand All @@ -17,23 +17,6 @@
<a href="https://www.wappalyzer.com/?utm_source=popup&utm_medium=extension&utm_campaign=wappalyzer" class="header__link">
<img alt="" class="header__logo" src="../images/logo-white.svg">
</a>

<div class="spacer"></div>

<svg class="header__switch header__switch--enabled header__icon" viewBox="0 0 24 24">
<title data-i18n="disableOnDomain"></title>
<path fill="currentColor" d="M17,7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7M17,15A3,3 0 0,1 14,12A3,3 0 0,1 17,9A3,3 0 0,1 20,12A3,3 0 0,1 17,15Z" />
</svg>

<svg class="header__switch header__switch--disabled header__icon" viewBox="0 0 24 24">
<title data-i18n="disableOnDomain"></title>
<path fill="currentColor" d="M17,7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7M7,15A3,3 0 0,1 4,12A3,3 0 0,1 7,9A3,3 0 0,1 10,12A3,3 0 0,1 7,15Z" />
</svg>

<svg class="header__settings header__icon" viewBox="0 0 24 24">
<title data-i18n="options"></title>
<path fill="currentColor" d="M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z" />
</svg>
</div>


Expand Down
157 changes: 40 additions & 117 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,45 +40,15 @@ function getRequiredTechnologies(name, categoryId) {
return undefined;
}

function isSimilarUrl(a, b) {
const normalise = (url) => String(url || '').replace(/(\/|\/?#.+)$/, '');

return normalise(a) === normalise(b);
}

const Driver = {
/**
* Initialise driver
*/
async init() {
await Driver.loadTechnologies();

const hostnameCache = await getOption('hostnames', {});

Driver.cache = {
hostnames: Object.keys(hostnameCache).reduce(
(cache, hostname) => ({
...cache,
[hostname]: {
...hostnameCache[hostname],
detections: hostnameCache[hostname].detections.map(
({
technology: name,
pattern: { regex, confidence },
version
}) => ({
technology: getTechnology(name, true),
pattern: {
regex: new RegExp(regex, 'i'),
confidence
},
version
})
)
}
}),
{}
),
urls: {},
robots: await getOption('robots', {})
};

Expand Down Expand Up @@ -462,27 +432,21 @@ const Driver = {
return;
}

let hostname;

try {
({ hostname } = new URL(initiatorUrl));
} catch (error) {
return;
}
const pageUrl = initiatorUrl.split('#')[0];

if (!Driver.cache.hostnames[hostname]) {
Driver.cache.hostnames[hostname] = {};
if (!Driver.cache.urls[pageUrl]) {
Driver.cache.urls[pageUrl] = {};
}

if (!Driver.cache.hostnames[hostname].analyzedScripts) {
Driver.cache.hostnames[hostname].analyzedScripts = [];
if (!Driver.cache.urls[pageUrl].analyzedScripts) {
Driver.cache.urls[pageUrl].analyzedScripts = [];
}

if (Driver.cache.hostnames[hostname].analyzedScripts.length >= 25) {
if (Driver.cache.urls[pageUrl].analyzedScripts.length >= 25) {
return;
}

Driver.cache.hostnames[hostname].analyzedScripts.push(request.url);
Driver.cache.urls[pageUrl].analyzedScripts.push(request.url);

const response = await fetch(request.url);

Expand Down Expand Up @@ -586,13 +550,7 @@ const Driver = {
* Check if Wappalyzer has been disabled for the domain
*/
async isDisabledDomain(url) {
try {
const { hostname } = new URL(url);

return (await getOption('disabledDomains', [])).includes(hostname);
} catch (error) {
return false;
}
return false;
},

/**
Expand All @@ -618,12 +576,12 @@ const Driver = {
const { hostname, pathname } = new URL(url);

// Cache detections
const cache = (Driver.cache.hostnames[hostname] = {
const cache = (Driver.cache.urls[url] = {
detections: [],
hits: incrementHits ? 0 : 1,
https: url.startsWith('https://'),
analyzedScripts: [],
...(Driver.cache.hostnames[hostname] || []),
...(Driver.cache.urls[url] || []),
dateTime: Date.now()
});

Expand Down Expand Up @@ -703,59 +661,23 @@ const Driver = {
cache.language = cache.language || language;

// Expire cache
Driver.cache.hostnames = Object.keys(Driver.cache.hostnames)
Driver.cache.urls = Object.keys(Driver.cache.urls)
.sort((a, b) =>
Driver.cache.hostnames[a].dateTime > Driver.cache.hostnames[b].dateTime
? -1
: 1
Driver.cache.urls[a].dateTime > Driver.cache.urls[b].dateTime ? -1 : 1
)
.reduce((hostnames, hostname) => {
const cache = Driver.cache.hostnames[hostname];
.reduce((urls, u) => {
const cache = Driver.cache.urls[u];

if (
cache.dateTime > Date.now() - expiry &&
Object.keys(hostnames).length < maxHostnames
Object.keys(urls).length < maxHostnames
) {
hostnames[hostname] = cache;
urls[u] = cache;
}

return hostnames;
return urls;
}, {});

// Save cache
await setOption(
'hostnames',
Object.keys(Driver.cache.hostnames).reduce(
(hostnames, hostname) => ({
...hostnames,
[hostname]: {
...cache,
detections: Driver.cache.hostnames[hostname].detections
.filter(({ technology }) => technology)
.map(
({
technology: { name: technology },
pattern: { regex, confidence },
version,
rootPath,
lastUrl
}) => ({
technology,
pattern: {
regex: regex.source,
confidence
},
version,
rootPath,
lastUrl
})
)
}
}),
{}
)
);

Driver.log({ hostname, technologies: resolved });
},

Expand All @@ -769,16 +691,13 @@ const Driver = {
technologies = [];
}

const dynamicIcon = await getOption('dynamicIcon', false);
const showCached = await getOption('showCached', true);
const dynamicIcon = await getOption('dynamicIcon', true);
const badge = await getOption('badge', true);

let icon = 'default.svg';

const _technologies = technologies.filter(
({ slug, lastUrl }) =>
slug !== 'cart-functionality' &&
(showCached || isSimilarUrl(url, lastUrl))
({ slug }) => slug !== 'cart-functionality'
);

if (dynamicIcon) {
Expand Down Expand Up @@ -854,15 +773,25 @@ const Driver = {
return;
}

const showCached = await getOption('showCached', true);
// Force a fresh scan on the active tab's content script with a 500ms timeout
try {
await Promise.race([
chrome.tabs.sendMessage(tab.id, {
source: 'index.js',
func: 'onGetTechnologies',
args: [Wappalyzer.technologies]
}),
new Promise((resolve) => setTimeout(resolve, 500))
]);
} catch (error) {
// Content script not loaded/ready or target page is restricted (e.g. chrome://)
}

const { hostname } = new URL(url);
const pageUrl = url.split('#')[0];

const cache = Driver.cache.hostnames?.[hostname];
const cache = Driver.cache.urls?.[pageUrl];

const resolved = (cache ? resolve(cache.detections) : []).filter(
({ lastUrl }) => showCached || isSimilarUrl(url, lastUrl)
);
const resolved = cache ? resolve(cache.detections) : [];

await Driver.setIcon(url, resolved);

Expand Down Expand Up @@ -965,11 +894,9 @@ const Driver = {
* Clear caches
*/
async clearCache() {
Driver.cache.hostnames = {};
Driver.cache.urls = {};

xhrAnalyzed = {};

await setOption('hostnames', {});
}
};

Expand Down Expand Up @@ -997,15 +924,11 @@ chrome.tabs.onUpdated.addListener(async (id, { status, url }) => {
}

if (url) {
const { hostname } = new URL(url);
const pageUrl = url.split('#')[0];

const showCached = await getOption('showCached', true);
const cache = Driver.cache?.urls?.[pageUrl];

const cache = Driver.cache?.hostnames?.[hostname];

const resolved = (cache ? resolve(cache.detections) : []).filter(
({ lastUrl }) => showCached || isSimilarUrl(url, lastUrl)
);
const resolved = cache ? resolve(cache.detections) : [];

await Driver.setIcon(url, resolved);
}
Expand Down
Loading