Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/TRHX/SpiderApi
Browse files Browse the repository at this point in the history
  • Loading branch information
TRHX committed Jan 18, 2025
2 parents 68fbb91 + f9a10bf commit 02d7035
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
39 changes: 39 additions & 0 deletions docs/03.辅助查询/01.辅助脚本/01.JS HOOK.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,45 @@ for (let i = 1; i < 99999; i++) window.clearInterval(i);
})();
```

## Hook 固定浏览器高度和宽度值

::: tip
来源于Github:[0xsdeo's Github](https://github.com/0xsdeo/Hook_JS)
:::

```javascript
let height = 660; // 固定的高度值
let width = 1366; // 固定的宽度值

let innerHeight_property_accessor = Object.getOwnPropertyDescriptor(window, "innerHeight"); // 获取innerHeight属性访问器描述符
let innerHeight_set_accessor = innerHeight_property_accessor.set; // 获取setter

Object.defineProperty(window, "innerHeight", {
get: function () {
// 在这里写你想让hook后的属性在被获取值时执行的代码
return height;
},
set: function () {
// 在这里写你想让hook后的属性在被设置值时执行的代码
innerHeight_set_accessor.call(window, height);// 将网站js设置目标属性值时所传入的内容传给原setter设置并返回结果
}
});

let innerWidth_property_accessor = Object.getOwnPropertyDescriptor(window, "innerWidth"); // 获取innerWidth属性访问器描述符
let innerWidth_set_accessor = innerWidth_property_accessor.set; // 获取setter

Object.defineProperty(window, "innerWidth", {
get: function () {
// 在这里写你想让hook后的属性在被获取值时执行的代码
return width;
},
set: function () {
// 在这里写你想让hook后的属性在被设置值时执行的代码
innerWidth_set_accessor.call(window, width);// 将网站js设置目标属性值时所传入的内容传给原setter设置并返回结果
}
});
```

## Hook 通用模板

```javascript
Expand Down
2 changes: 1 addition & 1 deletion vdoing/components/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<a href="https://beian.miit.gov.cn/" target="_blank"><img src="https://static.spiderapi.cn/public/images/logo/icp_48x48.png" alt="ICP 备案" style="width:20px; height:auto; margin-bottom:-2px"> 鄂ICP备19003281号-9</a>丨
<a href="https://beian.mps.gov.cn/" target="_blank"><img src="https://static.spiderapi.cn/public/images/logo/mps_48x48.png" alt="MPS 公网安备" style="width:auto; height:20px; margin-bottom:-4px"> 鄂公网安备42280202422959</a>丨
<a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank"><img src="https://static.spiderapi.cn/public/images/logo/vue_48x48.png" alt="Theme by Vdoing" style="width:18px; height:auto; margin-bottom:-4px"> Theme Vdoing</a>丨
<a href="https://cloudbase.net/" target="_blank"><img src="https://static.spiderapi.cn/public/images/logo/cloudbase.png" alt="云开发 CloudBase" style="width:22px; height:auto; margin-bottom:-2px"> CloudBase</a>丨
<a href="https://edgeone.ai/" target="_blank"><img src="https://static.spiderapi.cn/public/images/logo/tencent_edgeone_48x48.png" alt="Tencent EdgeOne" style="width:18px; height:auto; margin-bottom:-3px"> Tencent EdgeOne</a>丨
<a href="https://v6.51.la/land/3FcHt9RWSQ8XvN5u" target="_blank"><img src="https://sdk.51.la/icon/1-1.png" alt="51la 网站统计" style="width:auto; height:12px; margin-bottom:-1px"></a>
</span>
<br/>
Expand Down

0 comments on commit 02d7035

Please sign in to comment.