青岛模板化网站网站推广公司
自定义chormium-修改屏幕尺寸
屏幕尺寸信息雷同太大,用作指纹信息,作用不多。
但多个类似小信息组合在一起的话,也就是成唯一指纹了。积少成多吧。
一、如何使用js获取屏幕信息
将下面的代码复制进F12控制台
console.log("screen.width", screen.width)
console.log("screen.height", screen.height)
console.log("screen.availWidth", screen.availWidth)
console.log("screen.availHeight", screen.availHeight)
输出:
screen.width 1707
screen.height 1067
screen.availWidth 1707
screen.availHeight 1019
二、如何更改源码:
- 打开
/third_party/blink/renderer/core/frame/screen.cc
1.头部加上(随便加在一个#include
后面)
#include "base/command_line.h"
2.找到:
int Screen::availHeight() const {if (!DomWindow())return 0;return GetRect(/*available=*/true).height();
}
3.替换为:
int Screen::availHeight() const {if (!DomWindow())return 0;// 追加base::CommandLine* base_command_line = base::CommandLine::ForCurrentProcess();int seed;if (base_command_line->HasSwitch("fingerprints")) {std::istringstream(base_command_line->GetSwitchValueASCII("fingerprints")) >> seed; }else{auto now = std::chrono::system_clock::now();std::time_t now_time_t = std::chrono::system_clock::to_time_t(now);seed = static_cast<int>(now_time_t);}return GetRect(/*available=*/true).height() - 10 - seed%10;//return GetRect(/*available=*/true).height();
}
4.编译
ninja -C out/Default chrome
注意:这里只更改了
Screen::availHeight()
函数,剩下的几个函数,小伙伴们按需更改。
Screen::height()
Screen::width()
Screen::availHeight()
Screen::availWidth()
三、结语
写到这里,小伙伴们修改chromium源码的技术已经炉火纯青了,能引导集帅们入门是我的荣幸。
博客就写到这里吧,后续我就不肝了。
玩游戏老是吃保底,烦死了,系列完结。