IntersectionObserver对象

网友投稿 635 2022-09-11

IntersectionObserver对象

IntersectionObserver对象

IntersectionObserver对象

​​IntersectionObserver​​​对象,从属于​​Intersection Observer API​​​,提供了一种异步观察目标元素与其祖先元素或顶级文档视窗​​viewport​​​交叉状态的方法,祖先元素与视窗​​viewport​​​被称为根​​root​​​,也就是说​​IntersectionObserver API​​​,可以自动观察元素是否可见,由于可见​​visible​​​的本质是,目标元素与视口产生一个交叉区,所以这个​​API​​​叫做交叉观察器,兼容性​​https://caniuse.com/?search=IntersectionObserver​​。

描述

​​IntersectionObserver​​​解决了一个长期以来​​Web​​​的问题,观察元素是否可见,这个可见​​visible​​​的本质是,目标元素与视口产生一个交叉区,所以这个​​API​​​叫做交叉观察器。 要检测一个元素是否可见或者两个元素是否相交并不容易,很多解决办法不可靠或性能很差。现在很多需求下都需要用到相交检测,例如图片懒加载、内容无限滚动、检测元素的曝光情况、可视区域播放动画等等,相交检测通常要用到​​​onscroll​​​事件监听,并且可能需要频繁调用​​Element.getBoundingClientRect()​​​等方法以获取相关元素的边界信息,事件监听和调用​​Element.getBoundingClientRect​​​都是在主线程上运行,因此频繁触发、调用可能会造成性能问题,这种检测方法极其怪异且不优雅。​​​Intersection Observer API​​​会注册一个回调函数,每当被监视的元素进入或者退出另外一个元素时或​​viewport​​​,或者两个元素的相交部分大小发生变化时,该回调方法会被触发执行,这样网站的主线程不需要再为了监听元素相交而辛苦劳作,浏览器会自行优化元素相交管理,注意​​Intersection Observer API​​​无法提供重叠的像素个数或者具体哪个像素重叠,他的更常见的使用方式是当两个元素相交比例在​​N%​​左右时,触发回调,以执行某些逻辑。

const io = new IntersectionObserver(callback, option);// 开始观察io.observe(document.getElementById("example"));// 停止观察io.unobserve(element);// 关闭观察器io.disconnect();

参数​​callback​​​,创建一个新的​​IntersectionObserver​​​对象后,当其监听到目标元素的可见部分穿过了一个或多个阈​​thresholds​​时,会执行指定的回调函数。参数​​option​​​,​​IntersectionObserver​​构造函数的第二个参数是一个配置对象,其可以设置以下属性:

​​threshold​​​属性决定了什么时候触发回调函数,它是一个数组,每个成员都是一个门槛值,默认为​​[0]​​​,即交叉比例​​intersectionRatio​​​达到​​0​​​时触发回调函数,用户可以自定义这个数组,比如​​[0, 0.25, 0.5, 0.75, 1]​​​就表示当目标元素​​0%​​​、​​25%​​​、​​50%​​​、​​75%​​​、​​100%​​可见时,会触发回调函数。​​root​​​属性指定了目标元素所在的容器节点即根元素,目标元素不仅会随着窗口滚动,还会在容器里面滚动,比如在​​iframe​​​窗口里滚动,这样就需要设置​​root​​属性,注意,容器元素必须是目标元素的祖先节点。​​rootMargin​​​属性定义根元素的​​margin​​​,用来扩展或缩小​​rootBounds​​​这个矩形的大小,从而影响​​intersectionRect​​​交叉区域的大小,它使用​​CSS​​​的定义方法,比如​​10px 20px 30px 40px​​​,表示​​top​​​、​​right​​​、​​bottom​​​和​​left​​四个方向的值。

属性​​IntersectionObserver.root​​​只读,所监听对象的具体祖先元素​​element​​​,如果未传入值或值为​​null​​,则默认使用顶级文档的视窗。属性​​IntersectionObserver.rootMargin​​​只读,计算交叉时添加到根​​root​​​边界盒​​bounding box​​​的矩形偏移量,可以有效的缩小或扩大根的判定范围从而满足计算需要,此属性返回的值可能与调用构造函数时指定的值不同,因此可能需要更改该值,以匹配内部要求,所有的偏移量均可用像素​​pixel​​​、​​px​​​或百分比​​percentage​​​、​​%​​​来表达,默认值为​​0px 0px 0px 0px​​。属性​​IntersectionObserver.thresholds​​​只读,一个包含阈值的列表,按升序排列,列表中的每个阈值都是监听对象的交叉区域与边界区域的比率,当监听对象的任何阈值被越过时,都会生成一个通知​​Notification​​​,如果构造器未传入值,则默认值为​​0​​。方法​​IntersectionObserver.disconnect()​​​,使​​IntersectionObserver​​对象停止监听工作。方法​​IntersectionObserver.observe()​​​,使​​IntersectionObserver​​开始监听一个目标元素。方法​​IntersectionObserver.takeRecords()​​​,返回所有观察目标的​​IntersectionObserverEntry​​对象数组。方法​​IntersectionObserver.unobserve()​​​,使​​IntersectionObserver​​停止监听特定目标元素。

此外当执行​​callback​​​函数时,会传递一个​​IntersectionObserverEntry​​对象参数,其提供的信息如下。

​​time:​​可见性发生变化的时间,是一个高精度时间戳,单位为毫秒。​​target:​​​被观察的目标元素,是一个​​DOM​​节点对象。​​rootBounds:​​​根元素的矩形区域的信息,是​​getBoundingClientRect​​​方法的返回值,如果没有根元素即直接相对于视口滚动,则返回​​null​​。​​boundingClientRect:​​目标元素的矩形区域的信息。​​intersectionRect:​​目标元素与视口或根元素的交叉区域的信息。​​intersectionRatio:​​​目标元素的可见比例,即​​intersectionRect​​​占​​boundingClientRect​​​的比例,完全可见时为​​1​​​,完全不可见时小于等于​​0​​。

应用

实现一个使用​​IntersectionObserver​​​的简单示例,两个方块分别可以演示方块​​1​​​是否在屏幕可见区域内以及方块​​2​​​是否在方块​​1​​​的相对可见交叉区域内,另外可以使用​​IntersectionObserver​​​可以进行首屏渲染的优化,可以参考​​lang="en"> Documenttitle> <style> body{ margin: 0; padding: 0; height: 100vh; width: 100vw; overflow-x: hidden; } .flex{ display: flex; } --fixed{ top: 0; position: fixed; } .placeholder1{ width: 100%; } #box1{ height: 200px; overflow-y: auto; border: 1px solid #aaa; width: 60%; } .box1-placeholder{ height: 105vh; } #box2{ height: 100px; background-color: blue; margin-top: 300px; width: 60%; } .box2-placeholder{ height: 205px; } style>head><body> <section class="flex top-fixed"> <div class="flex">BOX1:div> <div class="flex" id="box1-status">invisiblediv> <div class="flex"> BOX2:div> <div class="flex" id="box2-status">invisiblediv> section> <div class="box1-placeholder">div> <div id="box1"> <div class="box2-placeholder">div> <div id="box2">div> <div class="box2-placeholder">div> div> <div class="box1-placeholder">div>body><script> (function(){ const box1 = document.querySelector("#box1"); const box2 = document.querySelector("#box2"); const box1Status = document.querySelector("#box1-status"); const box2Status = document.querySelector("#box2-status"); const box1Observer = new IntersectionObserver(entries => { entries.forEach(item => { // `intersectionRatio`为目标元素的可见比例,大于`0`代表可见 if (item.intersectionRatio > 0) { box1Status.innerText = "visible"; }else{ box1Status.innerText = "invisible"; } }); }, {root: document}); const box2Observer = new IntersectionObserver(entries => { entries.forEach(item => { // `intersectionRatio`为目标元素的可见比例,大于`0`代表可见 if (item.intersectionRatio > 0) { box2Status.innerText = "visible"; }else{ box2Status.innerText = "invisible"; } }); }, {root: box1}); box1Observer.observe(box1); box2Observer.observe(box2); })();script>html></p><p>每日一题</p><p>https://github.com/WindrunnerMax/EveryDay</p><p>参考</p><p>https://jianshu.com/p/eadd83d794c8https://ruanyifeng.com/blog/2016/11/intersectionobserver_api.htmlhttps://developer.mozilla.org/zh-CN/docs/Web/API/IntersectionObserver</p><p> <strong>版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。</strong> </p></div> <div class="article_footer clear"> <div class="fr tag">标签:<a href="https://www.finclip.com/news/tags-98.html">浏览器</a> </div> <div class="bdsharebuttonbox fl share"> <div class="share-widget fl"> <div class="social-share" data-sites="wechat,weibo, qq, qzone"></div> </div> </div> </div> <!-- 广告位ad4 --> <div class="post-navigation clear"> <div class="post-previous fl"> <span>上一篇:</span><a href="https://www.finclip.com/news/f/8351.html">Exceptionless - 本地搭建(Exceptionless 7)</a> </div> <div class="post-next fr"> <span>下一篇:</span><a href="https://www.finclip.com/news/f/8353.html">SQL 注入详解 SQL 注入详解</a> </div> </div> </div> <div class="related_article"> <div class="box_title clear"> <span><i class="icon fa fa-paper-plane"></i>相关文章</span> </div> <div class="related_list clear"> <article class="fl"> <div class="related_img"><a href="https://www.finclip.com/news/f/87336.html"><img src="https://www.finclip.com/news/zb_users/upload/2024/09/202409041725414580252941.png"></a></div> <div class="related_detail"> <h3><a href="https://www.finclip.com/news/f/87336.html" title="Koa2 开发微信二维码扫码支付的方法详细解析">Koa2 开发微信二维码扫码支付的方法详细解析</a></h3> <div class="meta"> <span><i class="fa fa-eye"></i>635</span> <span><i class="fa fa-clock-o"></i>2022-09-11</span> </div> </div> </article> <article class="fl"> <div class="related_img"><a href="https://www.finclip.com/news/f/87305.html"><img src="https://www.finclip.com/news/zb_users/upload/2024/09/20240903101943172532998364536.gif"></a></div> <div class="related_detail"> <h3><a href="https://www.finclip.com/news/f/87305.html" title="Vue 框架中操作 DIV 元素的方法与流程详解">Vue 框架中操作 DIV 元素的方法与流程详解</a></h3> <div class="meta"> <span><i class="fa fa-eye"></i>635</span> <span><i class="fa fa-clock-o"></i>2022-09-11</span> </div> </div> </article> <article class="fl"> <div class="related_img"><a href="https://www.finclip.com/news/f/87294.html"><img src="https://www.finclip.com/news/zb_users/cache/ly_autoimg/o/ODcyOTQ.jpg"></a></div> <div class="related_detail"> <h3><a href="https://www.finclip.com/news/f/87294.html" title="小程序开发方案: 构建你的在线商店">小程序开发方案: 构建你的在线商店</a></h3> <div class="meta"> <span><i class="fa fa-eye"></i>635</span> <span><i class="fa fa-clock-o"></i>2022-09-11</span> </div> </div> </article> </div> </div> <div id="comment" class="post-comment clearfix sb br mt"> <p id="comments-title" class="c-title mb bn"><span><i class="fa fa-pencil"></i> 发表评论</span></p> <div class="compost"> <form id="frmSumbit" target="_self" method="post" action="https://www.finclip.com/news/zb_system/cmd.php?act=cmt&postid=8352&key=b346ff76b07b4c0ef7abc69afa3b2e31"> <input type="hidden" name="inpId" id="inpId" value="8352"/> <input type="hidden" name="inpRevID" id="inpRevID" value="0"/> <div class="com-name"> <a rel="nofollow" id="cancel-reply" href="#comments" style="display:none;">取消回复</a> </div> <div class="com-info"> <ul> <li> <span class="hide" for="author"></span> <input class="ipt" type="text" name="inpName" id="inpName" value="" tabindex="2" placeholder="昵称(必填)"> </li> <li> <span class="hide" for="author"></span> <input class="ipt" type="text" name="inpEmail" id="inpEmail" value="" tabindex="3" placeholder="邮箱"> </li> <li> <span class="hide" for="author"></span> <input class="ipt" type="text" name="inpHomePage" id="inpHomePage" value="" tabindex="4" placeholder="网址"> </li> </ul> </div> <div class="com-box"> <textarea placeholder="来都来了,说点什么吧..." class="textarea" name="txaArticle" id="txaArticle" cols="5" rows="5" tabindex="1"></textarea> </div> <div class="com-info"><button class="com-submit br brightness" name="sumbit" type="submit" tabindex="5" onclick="return zbp.comment.post()">发布评论</button></div> </form> </div> <div class="comment-list mt"> <p class="no-comment"><i class="iconfont icon-sofa"></i> 暂时没有评论,来抢沙发吧~</p> <span id="AjaxCommentBegin"></span> <div class="pagination pagination-multi"> <ul> </ul> </div> <span id="AjaxCommentEnd"></span> </div> </div> </div> </div> <div class="sidebar"> <div id="divPrevious" class="part clear previous"> <div class="top"> <h3 class="title">最近发表</h3> </div> <div class="side divPrevious"><ul><li><a title="微信小程序选项卡功能开发步骤与方法全解析" href="https://www.finclip.com/news/f/87443.html">微信小程序选项卡功能开发步骤与方法全解析</a></li> <li><a title="微信开发中 ACCESS TOKEN 过期失效的解决方案详解" href="https://www.finclip.com/news/f/87442.html">微信开发中 ACCESS TOKEN 过期失效的解决方案详解</a></li> <li><a title="微信小程序利用 JS 实现注册 60s 倒计时功能解析" href="https://www.finclip.com/news/f/87441.html">微信小程序利用 JS 实现注册 60s 倒计时功能解析</a></li> <li><a title="微信小程序开发实现 tabs 选项卡效果实例代码解析" href="https://www.finclip.com/news/f/87440.html">微信小程序开发实现 tabs 选项卡效果实例代码解析</a></li> <li><a title="微信小程序开发中选项卡页面切换实现方法详解" href="https://www.finclip.com/news/f/87438.html">微信小程序开发中选项卡页面切换实现方法详解</a></li> <li><a title="微信小程序获取验证码倒计时 60s 实例分析与解读" href="https://www.finclip.com/news/f/87439.html">微信小程序获取验证码倒计时 60s 实例分析与解读</a></li> <li><a title="微信小程序开发中实现侧边栏滑动效果方法详细解析" href="https://www.finclip.com/news/f/87437.html">微信小程序开发中实现侧边栏滑动效果方法详细解析</a></li> <li><a title="微信小程序页面间跳转监听事件详解及方法说明" href="https://www.finclip.com/news/f/87436.html">微信小程序页面间跳转监听事件详解及方法说明</a></li> <li><a title="微信小程序本地存储与登录页面处理实例详细讲解" href="https://www.finclip.com/news/f/87435.html">微信小程序本地存储与登录页面处理实例详细讲解</a></li> <li><a title="PHP 对接微信公众平台消息接口开发流程实例详解" href="https://www.finclip.com/news/f/87433.html">PHP 对接微信公众平台消息接口开发流程实例详解</a></li> </ul></div> </div> <div id="newmodule" class="part clear 更多内容"> <div class="top"> <h3 class="title">更多内容</h3> </div> <div class="side newmodule"><ul><ul class="hot_posts"> <li><h4><a href="https://www.finclip.com/news/category-2.html" title="小程序SDK">小程序SDK</a></h4></li><li><h4><a href="https://www.finclip.com/news/category-3.html" title="Finclip技术文档">Finclip技术文档</a></h4></li><li><h4><a href="https://www.finclip.com/news/category-4.html" title="小程序开发">小程序开发</a></h4></li><li><h4><a href="https://www.finclip.com/news/category-5.html" title="小程序容器">小程序容器</a></h4></li><li><h4><a href="https://www.finclip.com/news/category-6.html" title="小程序框架">小程序框架</a></h4></li><li><h4><a href="https://www.finclip.com/news/category-7.html" title="Finclip小程序平台">Finclip小程序平台</a></h4></li><li><h4><a href="https://www.finclip.com/news/category-8.html" title="Finclip用户投稿">Finclip用户投稿</a></h4></li><li><h4><a href="https://www.finclip.com/news/category-9.html" title="车联网">车联网</a></h4></li></ul></ul></div> </div> <div id="tuijianwenzhang" class="part clear 推荐文章"> <div class="top"> <h3 class="title">推荐文章</h3> </div> <div class="side tuijianwenzhang"><ul><ul class="hot_posts"> <li><h4><a href="https://www.finclip.com/news/f/9435.html" title="小程序SDK是什么意思?小程序sdk和插件有什么区别?">小程序SDK是什么意思?小程序sdk和插件有什么区别?</a></h4></li><li><h4><a href="https://www.finclip.com/news/f/58967.html" title="小程序支付功能怎么实现?一篇详细教程来了!">小程序支付功能怎么实现?</a></h4></li><li><h4><a href="https://www.finclip.com/news/f/58064.html" title="企业app开发(企业app开发定制外包)">企业app开发流程是什么?</a></h4></li><li><h4><a href="https://www.finclip.com/news/f/52142.html" title="app运营模式框架(app运营体系搭建)">app运营模式有哪些?</a></h4></li><li><h4><a href="https://www.finclip.com/news/f/21082.html" title="小程序成为多社交平台引流利器,小程序多端引流怎么做">小程序多端引流怎么做?</a></h4></li><li><h4><a href="https://www.finclip.com/news/f/48029.html" title="小程序生态分析(小程序经济环境分析)">小程序生态分析的机会和威胁</a></h4></li><li><h4><a href="https://www.finclip.com/news/f/54499.html" title="flutter 小程序(flutter 小程序方案)">Flutter入门这一篇效率文章就够了</a></h4></li><li><h4><a href="https://www.finclip.com/news/f/39393.html" title="原生与跨平台解决方案分析,跨平台软件开发技术方案">原生与跨平台解决方案分析,跨平台软件开发技术方案</a></h4></li><li><h4><a href="https://www.finclip.com/news/f/58899.html" title="热更新技术:让软件更新变得更加轻松快速">热更新技术:让软件更新变得更加轻松快速</a></h4></ul></ul></div> </div> <div id="jiejuefangan" class="part clear 解决方案"> <div class="top"> <h3 class="title">解决方案</h3> </div> <div class="side jiejuefangan"><ul><ul class="hot_posts"> <li><h4><a href="https://www.finclip.com/solutions/bank" title="银行解决方案">银行解决方案</a></h4></li><li><h4><a href="https://www.finclip.com/solutions/broker" title="证券解决方案">证券解决方案</a></h4></li><li><h4><a href="https://www.finclip.com/solutions/internet" title="互联网解决方案">互联网解决方案</a></h4></li><li><h4><a href="https://www.finclip.com/solutions/oa" title="政企OA解决方案">政企OA解决方案</a></h4></li><li><h4><a href="https://www.finclip.com/solutions/technology" title="科技解决方案">科技解决方案</a></h4></li><li><h4><a href="https://www.finclip.com/solutions/car" title="智能车载解决方案">loT解决方案</a></h4></li><li><h4><a href="https://www.finclip.com/solutions/zerotrust" title="信任解决方案">信任解决方案</a></h4></li></ul></ul></div> </div> <div id="hot_posts" class="part clear hot_posts"> <div class="top"> <h3 class="title">热评文章</h3> </div> <ul class="hot_posts"><li><h4><a href="https://www.finclip.com/news/f/21046.html" title="AppCan:基于混合模式的移动应用开发,移动混合模式应用开发方案">AppCan:基于混合模式的移动应用开发,移动混合模</a></h4></li><li><h4><a href="https://www.finclip.com/news/f/7989.html" title="Hybrid App混合模式开发的了解">Hybrid App混合模式开发的了解</a></h4></li><li><h4><a href="https://www.finclip.com/news/f/5713.html" title="小程序容器技术助力券商数字营销突围,小程序容器化的意义">小程序容器技术助力券商数字营销突围,小程序容器化的意</a></h4></li><li><h4><a href="https://www.finclip.com/news/f/14756.html" title="用mpvue开发微信小程序基础知识(vue.js开发微信小程序)">用mpvue开发微信小程序基础知识(vue.js开发</a></h4></li><li><h4><a href="https://www.finclip.com/news/f/33154.html" title="小程序多端框架全面测评对比,强烈推荐!">小程序多端框架全面测评对比,强烈推荐!</a></h4></li><li><h4><a href="https://www.finclip.com/news/f/72383.html" title="开放银行银行案例,迎接金融创新的未来">开放银行银行案例,迎接金融创新的未来</a></h4></li></ul> </div> <div id="sidebar_ad" class="part clear sidebar_ad"> <div class="part sidebar_ad"><div class="active"><a href='http://www.finclip.com/?channel=jtseo' target='_blank'><img style='width:100%;height:100%' src='https://www.finclip.com/news/zb_users/upload/2022/11/%E4%B8%80%E7%AB%AF%E5%BC%80%E5%8F%91%EF%BC%8C%E8%B7%A8%E7%AB%AF%E8%BF%90%E8%A1%8C-370_680.png'></a><br></div></div> </div> </div> </div> </section> </div> <footer class="p-footer"> <div class="contant_box"> <div class="discover_tmt"> <div class="text_box"> <h5 class="" style="margin-bottom: 5px; margin-right: 5px;"><a href="https://www.finclip.com/" title="Finclip小程序容器技术" style="text-align: left;">小程序容器技术</a></h5> <a href="https://www.finclip.com/product/wxsupport/" title="微信生态支持" target="_blank" style="text-decoration: none; color: black; margin-right: 5px;" onmouseover="this.style.textDecoration='underline'; this.style.color='blue'" onmouseout="this.style.textDecoration='none'; this.style.color='black'" onclick="this.style.textDecoration='underline'; this.style.color='blue'">微信生态支持</a> <a href="https://www.finclip.com/product/management" title="小程序生命周期管理" target="_blank" style="text-decoration: none; color: black; margin-right: 5px;" onmouseover="this.style.textDecoration='underline'; this.style.color='blue'" onmouseout="this.style.textDecoration='none'; this.style.color='black'" onclick="this.style.textDecoration='underline'; this.style.color='blue'">小程序生命周期管理</a> <a href="https://www.finclip.com/product/developertools" title="开发生态工具完善" target="_blank" style="text-decoration: none; color: black; margin-right: 5px;" onmouseover="this.style.textDecoration='underline'; this.style.color='blue'" onmouseout="this.style.textDecoration='none'; this.style.color='black'" onclick="this.style.textDecoration='underline'; this.style.color='blue'">开发生态工具完善</a> <a href="https://www.finclip.com/product/sdk" title="小程序SDK" target="_blank" style="text-decoration: none; color: black; margin-right: 5px;" onmouseover="this.style.textDecoration='underline'; this.style.color='blue'" onmouseout="this.style.textDecoration='none'; this.style.color='black'" onclick="this.style.textDecoration='underline'; this.style.color='blue'">小程序SDK</a> <a href="https://www.finclip.com/technology-alliance-partner" title="技术生态" target="_blank" style="text-decoration: none; color: black; margin-right: 5px;" onmouseover="this.style.textDecoration='underline'; this.style.color='blue'" onmouseout="this.style.textDecoration='none'; this.style.color='black'" onclick="this.style.textDecoration='underline'; this.style.color='blue'">技术生态</a> </div> </div> <div class="collaboration_box"> <h5>交流与合作</h5> <div class="text_box"> <a href="#" title="地址">地址:深圳市福田区凯丰路 10号 国际金融科技城 19层</a> <a href="#" title="电话">电话:0755-86967467</a> <a href="#" title="邮箱">邮箱:contact@finogeeks.com</a> </div> </div> <div class="we_img_box clear"> <div class="img_box"> <img src="https://www.finclip.com/news/zb_users/theme/zblog5_news/image/ewm.png" alt="" class="hover_tmt"> </div> </div> </div> <p class="info"> <a href="https://beian.miit.gov.cn" target="_blank" rel="nofollow">粤ICP备2023123045号-2 </a> <span> <a href="#"></a></span> </p> </footer> <div id="backtop" class="backtop"> <div class="bt-box top"> <i class="fa fa-angle-up fa-2x"></i> </div> </div> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?b724df561c68ae808f6c323456db4430"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> <script> (()=>{const e="https://analyze.jiasou.cc/api/v1/page_view/report/",n="a92e22b2e862418c89a0fb0e07e0b287";let t=null;const o=new Proxy({},{get:(e,n)=>localStorage.getItem(window.btoa(n)),set:(e,n,t)=>!!t&&(localStorage.setItem(window.btoa(n),t),!0)});new Promise((t=>{if(o.fingerprint)t();else{const a=function(){var e={};if(e.userAgent=navigator.userAgent||"",e.plugins=[],navigator.plugins&&navigator.plugins.length>0)for(var n=0;n<navigator.plugins.length;n++){var t={name:navigator.plugins[n].name||"",filename:navigator.plugins[n].filename||"",description:navigator.plugins[n].description||""};e.plugins.push(t)}e.languages=navigator.languages||[navigator.language||""],e.timezone=(new Date).getTimezoneOffset(),e.screenResolution={width:window.screen.width||0,height:window.screen.height||0,pixelDepth:window.screen.pixelDepth||0,colorDepth:window.screen.colorDepth||0};var o=document.createElement("canvas").getContext("2d"),a=[],i=["monospace","sans-serif","serif"];for(n=0;n<i.length;n++){var r=i[n];o.font="12px "+r,o.measureText("abcdefghijklmnopqrstuvwxyz0123456789").width>0&&a.push(r)}return e.fonts=a,e.cookieEnabled=navigator.cookieEnabled||!1,e.localStorage=void 0!==window.localStorage,e.sessionStorage=void 0!==window.sessionStorage,e.doNotTrack="1"===navigator.doNotTrack||"1"===window.doNotTrack||"1"===navigator.msDoNotTrack||"yes"===navigator.doNotTrack,e}();fetch(`${e}u/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:n,f:window.btoa(JSON.stringify(a))})}).then((e=>{console.debug("browser fingerprint sent"),200===e.status&&e.json().then((e=>{console.debug("browser fingerprint received",e),o.fingerprint=e.fp,t()}))}))}})).then((()=>{e&&o.fingerprint&&fetch(e+`?${new URLSearchParams({token:n}).toString()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({c:window.btoa(JSON.stringify({u:o.fingerprint,l:window.location.href,r:document.referrer}))})}).then((e=>{200==e.status&&e.json().then((e=>{e.track_id&&(t=e.track_id)}))}))})),window.addEventListener("beforeunload",(async n=>{t&&fetch(e+`?${new URLSearchParams({track_id:t}).toString()}`,{method:"GET",headers:{"Content-Type":"text/plain"},keepalive:!0}),n.returnValue=""}))})(); </script><script language="javascript" src="https://www.finclip.com/news/zb_users/plugin/ZF_ad/js/index.js?id=907"></script> <script language="javascript" src="https://www.finclip.com/news/zb_users/plugin/ZF_ad/js/ZF_ad__cookie.js"></script> </body> </html> <!--183.71 ms , 38 queries , 20102kb memory , 0 error-->