I’ll introduce that Chrome’s secret mode, Safari’s private browsing, etc. cannot be detected.
First, as background knowledge, there was a trend in 2019 where each browser took countermeasures to prevent websites from detecting secret mode and private browsing.
Google has decided to eliminate methods that websites can use to detect when people visit websites using Chrome's secret mode.Quote source: Next “Chrome” to Avoid Secret Mode Detection by Sites - CNET Japan (次期「Chrome」、サイトによるシークレットモード検知を回避へ - CNET Japan)
In the latest version of Apple's browser Safari, which began distribution to users in late September, sites can no longer detect when users with private browsing mode enabled visit the site.Quote source: Safari’s New Private Mode Disables Metered Billing: Publishers Troubled | DIGIDAY [Japan Edition] (Safari 新プライベートモード、メーター制課金を無効化に:頭悩ますパブリッシャーたち | DIGIDAY[日本版])
Each browser has addressed this, and while it’s no longer useful reference now, I’ll list articles that show “how secret mode and private browsing used to be detected 🤔💭”:
Since each browser has implemented countermeasures, we should understand that secret mode and private browsing cannot be detected with JavaScript.
That’s all from the Gemba on wanting to detect secret mode and private browsing with JavaScript.