前端通过navigator.cookieEnabled 检测是否开启。
1、cookieEnabled 接口定义在 navigator_cookies.idl
interface mixin NavigatorCookies {
[HighEntropy=Direct,MeasureAs=NavigatorCookieEnabled]
readonly attribute boolean cookieEnabled;
};
2、cookieEnabled 实现在
third_party\blink\renderer\core\frame\navigator.h
third_party\blink\renderer\core\frame\navigator.cc
bool Navigator::cookieEnabled() const {
if (!DomWindow())
return false;
Settings* settings = DomWindow()->GetFrame()->GetSettings();
if (!settings || !settings->GetCookieEnabled())
return false;
return DomWindow()->document()->CookiesEnabled();
}
可以在cookieEnabled()函数里面返回false直接禁用即可。
3、CookieJar::CookiesEnabled()实现
third_party\blink\renderer\core\loader\cookie_jar.cc
third_party\blink\renderer\core\loader\cookie_jar.h
bool CookieJar::CookiesEnabled() {
KURL cookie_url = document_->CookieURL();
if (cookie_url.IsEmpty())
return false;
base::ElapsedTimer timer;
RequestRestrictedCookieManagerIfNeeded();
bool cookies_enabled = false;
backend_->CookiesEnabledFor(
cookie_url, document_->SiteForCookies(), document_->TopFrameOrigin(),
document_->GetExecutionContext()->HasStorageAccess(), &cookies_enabled);
base::UmaHistogramTimes("Blink.CookiesEnabledTime", timer.Elapsed());
return cookies_enabled;
}
至此cookies指纹修改介绍完毕。
道路千万条,也可以在其他地方修改,仅供学习交流。