Skip to content

Commit 9173ab6

Browse files
committed
fix: 跳过站点自身品牌识别
身在 github.com 还把 GitHub.com 当作「使用了的技术」展示,已经是 URL 栏里的内容;新增 self-host 抑制表,覆盖 GitHub / GitLab / Bitbucket / npm / PyPI / Stack Overflow / Twitter / Facebook / YouTube / Bilibili / 知乎 / 百度 等常见目的地站点,当用户处于该域时不再把同名技术加入识别结果。 将版本号提升到 1.3.37。
1 parent 8533e8f commit 9173ab6

2 files changed

Lines changed: 81 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "stackprism",
33
"private": true,
4-
"version": "1.3.36",
4+
"version": "1.3.37",
55
"type": "module",
66
"description": "StackPrism 用于检测网页前端、后端、CDN、SaaS、广告营销、统计、登录、支付、网站程序和主题模板线索。",
77
"scripts": {

src/background/popup-cache.ts

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,81 @@ const cleanRawDynamicObservation = (dynamic: any, data: any) => {
213213
}
214214
}
215215

216+
// 站点自身的「品牌识别」抑制:当用户就在 github.com 时不再把 GitHub.com 当作一项「使用了的技术」
217+
// 显示给他,那是 URL 栏里已经告诉他的事情
218+
const SELF_HOST_SUPPRESS: Record<string, readonly string[]> = {
219+
'github.com': ['GitHub.com', 'GitHub'],
220+
'gitlab.com': ['GitLab.com', 'GitLab'],
221+
'bitbucket.org': ['Bitbucket'],
222+
'codeberg.org': ['Codeberg'],
223+
'gitee.com': ['Gitee'],
224+
'huggingface.co': ['Hugging Face'],
225+
'stackoverflow.com': ['Stack Overflow'],
226+
'stackexchange.com': ['Stack Exchange'],
227+
'npmjs.com': ['npm', 'npm 包注册中心'],
228+
'pypi.org': ['PyPI'],
229+
'crates.io': ['crates.io'],
230+
'rubygems.org': ['RubyGems'],
231+
'packagist.org': ['Packagist'],
232+
'twitter.com': ['Twitter', 'X (Twitter)'],
233+
'x.com': ['Twitter', 'X (Twitter)'],
234+
'facebook.com': ['Facebook'],
235+
'instagram.com': ['Instagram'],
236+
'linkedin.com': ['LinkedIn'],
237+
'youtube.com': ['YouTube'],
238+
'tiktok.com': ['TikTok'],
239+
'reddit.com': ['Reddit'],
240+
'discord.com': ['Discord'],
241+
'slack.com': ['Slack'],
242+
'telegram.org': ['Telegram'],
243+
'whatsapp.com': ['WhatsApp'],
244+
'medium.com': ['Medium'],
245+
'substack.com': ['Substack'],
246+
'notion.so': ['Notion'],
247+
'figma.com': ['Figma'],
248+
'linear.app': ['Linear'],
249+
'asana.com': ['Asana'],
250+
'trello.com': ['Trello'],
251+
'monday.com': ['monday.com', 'Monday'],
252+
'airtable.com': ['Airtable'],
253+
'shopify.com': ['Shopify Admin'],
254+
'replit.com': ['Replit'],
255+
'codepen.io': ['CodePen'],
256+
'stackblitz.com': ['StackBlitz'],
257+
'codesandbox.io': ['CodeSandbox'],
258+
'jsfiddle.net': ['JSFiddle'],
259+
'google.com': ['Google Search'],
260+
'bing.com': ['Bing'],
261+
'duckduckgo.com': ['DuckDuckGo'],
262+
'baidu.com': ['百度', 'Baidu'],
263+
'zhihu.com': ['知乎', 'Zhihu'],
264+
'weibo.com': ['微博', 'Weibo'],
265+
'bilibili.com': ['哔哩哔哩', 'Bilibili']
266+
}
267+
268+
const extractRegistrableHost = (url: string): string => {
269+
try {
270+
return new URL(url).hostname.toLowerCase().replace(/^www\./, '')
271+
} catch {
272+
return ''
273+
}
274+
}
275+
276+
const suppressSelfHostTechs = (technologies: any[], pageUrl: string): any[] => {
277+
const host = extractRegistrableHost(pageUrl)
278+
if (!host) return technologies
279+
// 主域匹配:github.com 时也抑制;gist.github.com 时按完整 host 找不到,回退取末两段
280+
const parts = host.split('.')
281+
const candidates = [host, parts.slice(-2).join('.')]
282+
const suppressNames = new Set<string>()
283+
for (const candidate of candidates) {
284+
const list = SELF_HOST_SUPPRESS[candidate]
285+
if (list) for (const name of list) suppressNames.add(name)
286+
}
287+
if (!suppressNames.size) return technologies
288+
return technologies.filter(tech => !suppressNames.has(String(tech?.name || '')))
289+
}
290+
216291
const buildDisplayTechnologies = (data: any, settings: any) => {
217292
const all: any[] = []
218293
addAllTechnologies(all, data.page?.technologies)
@@ -249,7 +324,11 @@ const buildDisplayTechnologies = (data: any, settings: any) => {
249324
source: tech.source || 'JS 版权注释'
250325
}))
251326
)
252-
return filterTechnologiesBySettings(suppressGenericCdnFallbacks(mergeDisplayTechnologyRecords(all)), settings)
327+
const pageUrl = data.page?.url || data.dynamic?.url || data.main?.url || ''
328+
return filterTechnologiesBySettings(
329+
suppressSelfHostTechs(suppressGenericCdnFallbacks(mergeDisplayTechnologyRecords(all)), pageUrl),
330+
settings
331+
)
253332
}
254333

255334
const buildPopupResult = async (data: any, settings: any, tab: any) => {

0 commit comments

Comments
 (0)