[CodeFactor] Apply fixes
[ci skip] [skip ci]
This commit is contained in:
@@ -6,28 +6,28 @@ module.exports = async (ctx) => {
|
||||
const page = await browser.newPage();
|
||||
|
||||
// 浏览器伪装
|
||||
await page.evaluateOnNewDocument(() => { //在每个新页面打开前执行以下脚本
|
||||
await page.evaluateOnNewDocument(() => { // 在每个新页面打开前执行以下脚本
|
||||
const newProto = navigator.__proto__;
|
||||
delete newProto.webdriver; //删除navigator.webdriver字段
|
||||
delete newProto.webdriver; // 删除navigator.webdriver字段
|
||||
navigator.__proto__ = newProto;
|
||||
window.chrome = {}; //添加window.chrome字段,为增加真实性还需向内部填充一些值
|
||||
window.chrome = {}; // 添加window.chrome字段,为增加真实性还需向内部填充一些值
|
||||
window.chrome.app = {"InstallState":"hehe", "RunningState":"haha", "getDetails":"xixi", "getIsInstalled":"ohno"};
|
||||
window.chrome.csi = function(){};
|
||||
window.chrome.loadTimes = function(){};
|
||||
window.chrome.runtime = function(){};
|
||||
Object.defineProperty(navigator, 'userAgent', { //userAgent在无头模式下有headless字样,所以需覆写
|
||||
window.chrome.csi = function() {};
|
||||
window.chrome.loadTimes = function() {};
|
||||
window.chrome.runtime = function() {};
|
||||
Object.defineProperty(navigator, 'userAgent', { // userAgent在无头模式下有headless字样,所以需覆写
|
||||
get: () => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36",
|
||||
});
|
||||
Object.defineProperty(navigator, 'plugins', { //伪装真实的插件信息
|
||||
Object.defineProperty(navigator, 'plugins', { // 伪装真实的插件信息
|
||||
get: () => [{"description": "Portable Document Format",
|
||||
"filename": "internal-pdf-viewer",
|
||||
"length": 1,
|
||||
"name": "Chrome PDF Plugin"}]
|
||||
});
|
||||
Object.defineProperty(navigator, 'languages', { //添加语言
|
||||
Object.defineProperty(navigator, 'languages', { // 添加语言
|
||||
get: () => ["zh-CN", "zh", "en"],
|
||||
});
|
||||
const originalQuery = window.navigator.permissions.query; //notification伪装
|
||||
const originalQuery = window.navigator.permissions.query; // notification伪装
|
||||
window.navigator.permissions.query = (parameters) => (
|
||||
parameters.name === 'notifications' ?
|
||||
Promise.resolve({ state: Notification.permission }) :
|
||||
@@ -58,7 +58,6 @@ module.exports = async (ctx) => {
|
||||
).get();
|
||||
|
||||
|
||||
|
||||
ctx.state.data = {
|
||||
title: '信通通知公告',
|
||||
link: 'https://www.sice.uestc.edu.cn/tzgg/yb.htm',
|
||||
|
||||
Reference in New Issue
Block a user