fix(layout): 为外部脚本添加 data-swup-ignore-script 属性

防止页面切换库 Swup 重新执行第三方脚本,避免重复初始化或跟踪事件。
This commit is contained in:
二叉树树
2026-01-30 21:05:33 +08:00
parent f7848ff585
commit 9ae65d19ea

View File

@@ -240,8 +240,8 @@ const bannerOffset =
> >
<!-- Cookie Consent by TermsFeed https://www.TermsFeed.com --> <!-- Cookie Consent by TermsFeed https://www.TermsFeed.com -->
<script type="text/javascript" src="https://www.termsfeed.com/public/cookie-consent/4.2.0/cookie-consent.js" charset="UTF-8"></script> <script data-swup-ignore-script type="text/javascript" src="https://www.termsfeed.com/public/cookie-consent/4.2.0/cookie-consent.js" charset="UTF-8"></script>
<script type="text/javascript" charset="UTF-8"> <script data-swup-ignore-script type="text/javascript" charset="UTF-8">
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
cookieconsent.run({"notice_banner_type":"simple","consent_type":"express","palette":"dark","language":"en","page_load_consent_levels":["strictly-necessary"],"notice_banner_reject_button_hide":false,"preferences_center_close_button_hide":false,"page_refresh_confirmation_buttons":false,"website_name":"AcoFork Blog","website_privacy_policy_url":"https://blog.acofork.com/posts/privacy-policy/"}); cookieconsent.run({"notice_banner_type":"simple","consent_type":"express","palette":"dark","language":"en","page_load_consent_levels":["strictly-necessary"],"notice_banner_reject_button_hide":false,"preferences_center_close_button_hide":false,"page_refresh_confirmation_buttons":false,"website_name":"AcoFork Blog","website_privacy_policy_url":"https://blog.acofork.com/posts/privacy-policy/"});
}); });
@@ -254,7 +254,7 @@ cookieconsent.run({"notice_banner_type":"simple","consent_type":"express","palet
<!-- Google Analytics --> <!-- Google Analytics -->
<!-- Google tag (gtag.js) --> <!-- Google tag (gtag.js) -->
<script type="text/plain" data-cookie-consent="tracking" async src="https://www.googletagmanager.com/gtag/js?id=G-YG02LLPGWC"></script> <script type="text/plain" data-cookie-consent="tracking" async src="https://www.googletagmanager.com/gtag/js?id=G-YG02LLPGWC" data-swup-ignore-script></script>
<script type="text/plain" data-cookie-consent="tracking"> <script type="text/plain" data-cookie-consent="tracking">
window.dataLayer = window.dataLayer || []; window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);} function gtag(){dataLayer.push(arguments);}
@@ -264,7 +264,7 @@ cookieconsent.run({"notice_banner_type":"simple","consent_type":"express","palet
<!-- end of Google Analytics--> <!-- end of Google Analytics-->
<!-- Microsoft Clarity --> <!-- Microsoft Clarity -->
<script type="text/plain" data-cookie-consent="tracking"> <script type="text/plain" data-cookie-consent="tracking" data-swup-ignore-script>
(function(c,l,a,r,i,t,y){ (function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
@@ -274,7 +274,7 @@ cookieconsent.run({"notice_banner_type":"simple","consent_type":"express","palet
<!-- end of Site Experience & Interaction Analytics--> <!-- end of Site Experience & Interaction Analytics-->
<!-- Google Adsense --> <!-- Google Adsense -->
<script type="text/plain" data-cookie-consent="targeting" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1683686345039700" <script type="text/plain" data-cookie-consent="targeting" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1683686345039700 data-swup-ignore-script"
crossorigin="anonymous"></script> crossorigin="anonymous"></script>
<!-- end of Google Adsense--> <!-- end of Google Adsense-->