Files
Hextra-AI-Insight-Daily/layouts/partials/custom/head-end.html
2025-07-06 17:44:42 +08:00

350 lines
14 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<meta name="twitter:site" content="@justlikemaki">
<meta name="twitter:image" content="{{ .Site.BaseURL }}/images/logo-dark.png">
<meta name="og:image" content="{{ .Site.BaseURL }}/images/logo-dark.png">
{{ if .IsTranslated }}
{{ range .AllTranslations }}
<link rel="alternate" hreflang="{{ .Language.Lang }}" href="{{ .Permalink }}" />
{{ end }}
{{ end }}
<script async src="//finicounter.eu.org/finicounter.js"></script>
<script src="/adview_pic_cpc_cpm_cpa_guanggao_gg_guge__ads_300x250.js" type="text/javascript"></script>
<script type="text/javascript">
if (typeof(killads) == 'undefined') {
// 创建一个函数来显示美化后的广告屏蔽提示
function createEnhancedAdBlockNotice() {
// 如果弹窗已存在,则不再创建
if (document.getElementById('adblock-overlay-enhanced')) {
return;
}
// 为弹窗添加一个柔和的入场动画 (通过动态创建<style>标签)
var css = `
@keyframes fadeIn {
from { opacity: 0; transform: scale(0.95); }
to { opacity: 1; transform: scale(1); }
}
`;
var style = document.createElement('style');
style.id = 'adblock-notice-styles';
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
document.head.appendChild(style);
// 1. 创建遮罩层 (背景)
var overlay = document.createElement('div');
overlay.id = 'adblock-overlay-enhanced';
overlay.style.cssText = 'position:fixed; top:0; left:0; width:100%; height:100%; background-color:rgba(0, 0, 0, 0.8); z-index:9999; display:flex; justify-content:center; align-items:center; backdrop-filter:blur(4px);';
// 2. 创建弹窗容器 (主面板)
var modal = document.createElement('div');
modal.id = 'adblock-modal-enhanced';
modal.style.cssText = 'background-color:#fff; padding:40px; border-radius:16px; max-width:460px; width:90%; box-shadow:0 15px 30px rgba(0,0,0,0.2); font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif; animation: fadeIn 0.3s ease-out;';
// 3. 设置弹窗内的HTML内容 (包含SVG图标、美化文案和按钮)
modal.innerHTML = `
<div style="text-align: center; margin-bottom: 20px;">
<h2 style="margin: 15px 0 10px; color: #333; font-size: 24px; font-weight: 600;">
一份小小的请求
</h2>
</div>
<p style="color: #555; font-size: 16px; line-height: 1.8; margin-bottom: 15px;">
我们发现您可能正在使用广告屏蔽器。
</p>
<p style="color: #555; font-size: 16px; line-height: 1.8; margin-bottom: 25px;">
广告是支持本站 <strong>持续运营</strong> 与 <strong>免费分享</strong> 的动力来源。如果本站对您有帮助,恳请将我们加入 <strong>白名单</strong>。您的这份善意,是对我们 <strong>最大的支持</strong>
</p>
<div style="background-color: #E8F5E9; border-left: 4px solid #4CAF50; padding: 15px 20px; border-radius: 8px;">
<p style="margin: 0; color: #2E7D32; font-size: 16px; line-height: 1.6; text-align: center;">
<strong>操作很简单:</strong>在插件中将本站设为白名单,然后 <strong>刷新页面</strong> 即可。
</p>
</div>
<div style="text-align: center; margin-top: 30px;">
<button id="close-adblock-notice-enhanced" style="background-color: #f1f1f1; color: #666; border: none; padding: 12px 25px; border-radius: 8px; cursor: pointer; font-size: 15px; font-weight: 500; transition: background-color 0.2s, transform 0.1s;">
我明白了,继续浏览
</button>
</div>
`;
// 4. 组合并添加到页面
overlay.appendChild(modal);
document.body.appendChild(overlay);
document.body.style.overflow = 'hidden';
// 5. 为关闭按钮添加功能和交互效果
var closeButton = document.getElementById('close-adblock-notice-enhanced');
closeButton.addEventListener('click', function() {
document.body.removeChild(overlay);
document.head.removeChild(style); // 顺便移除添加的样式
document.body.style.overflow = 'auto';
});
// 为按钮添加更丰富的悬停效果
closeButton.onmouseover = function() { this.style.backgroundColor = '#e0e0e0'; };
closeButton.onmouseout = function() { this.style.backgroundColor = '#f1f1f1'; };
closeButton.onmousedown = function() { this.style.transform = 'scale(0.98)'; };
closeButton.onmouseup = function() { this.style.transform = 'scale(1)'; };
}
// 确保在页面DOM加载完毕后再执行脚本
window.addEventListener('DOMContentLoaded', createEnhancedAdBlockNotice);
}
</script>
<script>
// 这是一个自定义脚本,用于处理特定的页面逻辑和功能
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.createTemplateTagFirstArg=function(a){return a.raw=a};$jscomp.createTemplateTagFirstArgWithRaw=function(a,b){a.raw=b;return a};
(function(){var a=window.location.href,b=window.location.pathname;"justlovemaki.github.io"===window.location.hostname&&b.startsWith("/Hextra-AI-Insight-Daily/")&&(b="https://ai.hubtoday.app/"+b.substring(40)+window.location.search+window.location.hash,console.log("Original URL: "+a),console.log("Redirecting to: "+b),window.location.replace(b))})();
// 这是一个自定义脚本,用于处理侧边栏菜单的点击阻止逻辑
document.addEventListener('DOMContentLoaded', function() {
/**
* 为指定的侧边栏菜单应用点击阻止逻辑。
* @param {string} selector - 目标 <ul> 元素的 CSS 选择器。
* @param {string} menuType - 菜单类型(例如 'Desktop' 或 'Mobile'),用于日志记录。
*/
function applyClickPrevention(selector, menuType) {
// 使用提供的选择器查找菜单UL元素
// 注意CSS选择器中的冒号需要用反斜杠转义
const menuUl = document.querySelector(selector);
if (menuUl) {
// 选择该UL下所有第一级的<a>标签
const firstLevelAnchors = menuUl.querySelectorAll(':scope > li > a');
let preventedCount = 0;
firstLevelAnchors.forEach(anchor => {
const parentLi = anchor.closest('li');
// 检查这个li内部是否包含一个子菜单另一个ul
const hasSubmenu = parentLi && parentLi.querySelector('ul');
// **仅当存在子菜单时**,才阻止链接的默认导航行为
if (hasSubmenu) {
anchor.addEventListener('click', function(event) {
// 阻止链接的默认导航行为
event.preventDefault();
console.log(`[${menuType}] Default navigation prevented for:`, anchor.href);
// 切换父级li的 'open' 类以展开/折叠子菜单
if (parentLi) {
parentLi.classList.toggle('open');
console.log(`[${menuType}] ${parentLi.classList.contains('open') ? 'Opened' : 'Closed'} submenu for:`, anchor.textContent.trim());
}
});
preventedCount++;
}
});
console.log(`[${menuType}] Added click prevention to ${preventedCount} first-level <a> tags with submenus in '${selector}'.`);
} else {
console.warn(`[${menuType}] The specified UL ('${selector}') was not found.`);
}
}
// --- 主逻辑 ---
// 1. 定义桌面端菜单的选择器
const desktopMenuSelector = 'ul.hx-flex.hx-flex-col.hx-gap-1.max-md\\:hx-hidden';
// 2. 定义移动端菜单的选择器
// 通常移动端菜单的类与桌面端相反例如在md及以上屏幕隐藏
// !!! 请根据你的HTML结构检查并确认这个选择器是正确的 !!!
const mobileMenuSelector = 'ul.hx-flex.hx-flex-col.hx-gap-1.md\\:hx-hidden';
// 3. 分别为桌面和移动端菜单应用逻辑
applyClickPrevention(desktopMenuSelector, 'Desktop Menu');
applyClickPrevention(mobileMenuSelector, 'Mobile Menu');
});
// 在页面加载完成后执行时间标签本地化
document.addEventListener('DOMContentLoaded', function() {
// 1. 获取所有 <time> 元素
const timeElements = document.querySelectorAll('time');
// 2. 遍历每个元素
timeElements.forEach(timeEl => {
// 3. 获取 UTC 时间字符串
const utcDateTime = timeEl.getAttribute('datetime');
if (!utcDateTime) {
return; // 跳过没有 datetime 属性的标签
}
// 4. 创建 Date 对象
const dateObj = new Date(utcDateTime);
if (isNaN(dateObj.getTime())) {
return; // 跳过无效的日期
}
// 5. 转换为本地化字符串并更新内容
// toLocaleString() 会自动处理时区偏移
timeEl.textContent = dateObj.toLocaleString();
});
});
</script>
{{- if .Site.Params.adsenseId -}}
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client={{- .Site.Params.adsenseId | safeJS -}}" crossorigin="anonymous"></script>
{{- end -}}
{{- if .Site.Params.ahrefsKey -}}
<script src="https://analytics.ahrefs.com/analytics.js" data-key="{{- .Site.Params.ahrefsKey | safeJS -}}" async></script>
{{- end -}}
{{/* 只有在配置文件中设置了 clarityID 时,才输出这段脚本 */}}
{{- if .Site.Params.clarityID -}}
<script type="text/javascript">
// Clarity Analytics Script
(function(c,l,a,r,i,t,y){
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;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "{{- .Site.Params.clarityID | safeJS -}}");
</script>
{{- end -}}
{{ "<!-- ENTERING partial seo-schema.html -->" | safeHTML }}
{{/* --- Publisher Block --- */}}
{{- $publisher := "" -}}
{{- with .Site.Params.publisher -}}
{{- $p := . -}}
{{- $type := .type | default "Organization" -}}
{{- $name := .name | default $.Site.Title -}}
{{- $publisherData := dict "@type" $type "name" $name -}}
{{- if eq $type "Organization" -}}
{{- with .logo -}}
{{- $logoData := dict "@type" "ImageObject" "url" ( . | absURL ) -}}
{{- $publisherData = merge $publisherData (dict "logo" $logoData) -}}
{{- end -}}
{{- else if eq $type "Person" -}}
{{- with .url -}}
{{- $publisherData = merge $publisherData (dict "url" ( . | absURL )) -}}
{{- end -}}
{{- with .sameAs -}}
{{- $publisherData = merge $publisherData (dict "sameAs" .) -}}
{{- end -}}
{{- end -}}
{{- $publisher = $publisherData -}}
{{- end -}}
{{/* --- Author Block --- */}}
{{- $author := "" -}}
{{/* 1. Check for single author in page Front Matter */}}
{{- $author_id := .Params.author -}}
{{- if and $author_id (index .Site.Data.authors $author_id) -}}
{{- $authorData := index .Site.Data.authors $author_id -}}
{{- $author = dict "@type" "Person" "name" $authorData.name -}}
{{- with $authorData.website -}}
{{- $author = merge $author (dict "url" ( . | absURL )) -}}
{{- end -}}
{{/* 2. Fallback to global author in hugo.yaml `params` */}}
{{- else if .Site.Params.author -}}
{{- $author = dict "@type" "Person" "name" .Site.Params.author.name -}}
{{- with .Site.Params.author.website -}}
{{- $author = merge $author (dict "url" ( . | absURL )) -}}
{{- end -}}
{{/* 3. Fallback to global author in hugo.yaml `author` */}}
{{- else if .Site.Author.name -}}
{{- $author = dict "@type" "Person" "name" .Site.Author.name -}}
{{- with .Site.Author.website -}}
{{- $author = merge $author (dict "url" ( . | absURL )) -}}
{{- end -}}
{{- end -}}
{{- if .IsHome -}}
{{/* --- WebSite Schema --- */}}
{{- $schema := dict "@context" "https://schema.org" "@type" "WebSite" -}}
{{- $schema = merge $schema (dict "url" .Site.BaseURL "name" .Site.Title) -}}
{{- with .Site.Params.description -}}
{{- $schema = merge $schema (dict "description" .) -}}
{{- end -}}
{{- with $publisher -}}
{{- $schema = merge $schema (dict "publisher" .) -}}
{{- end -}}
<script type="application/ld+json">
{{ $schema }}
</script>
{{- else if .IsPage -}}
{{/* --- Article/TechArticle Schema --- */}}
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
{{- $schema := dict "@context" "https://schema.org" "@type" "TechArticle" -}}
{{- $schema = merge $schema (dict
"mainEntityOfPage" (dict "@type" "WebPage" "@id" .Permalink)
"headline" .Title
"url" .Permalink
"wordCount" .WordCount
) -}}
{{- $docDesc := .Description | default "" -}}
{{- $siteParamDesc := .Site.Params.description | default "" -}}
{{- $description := or $docDesc $siteParamDesc -}}
{{- with $description -}}
{{- $schema = merge $schema (dict "description" .) -}}
{{- end -}}
{{- $image := "" -}}
{{- if .Params.image.url -}}
{{- $image = .Params.image -}}
{{- else if .Site.Params.image.url -}}
{{- $image = .Site.Params.image -}}
{{- end -}}
{{- with $image -}}
{{- if ge .width 696 -}}
{{- $imageData := dict "@type" "ImageObject" "url" ( .url | absURL ) "width" .width "height" .height -}}
{{- $schema = merge $schema (dict "image" $imageData) -}}
{{- end -}}
{{- end -}}
{{- with .Type -}}
{{- $schema = merge $schema (dict "genre" .) -}}
{{- end -}}
{{- with .Params.tags -}}
{{- $schema = merge $schema (dict "keywords" (delimit . ", ")) -}}
{{- end -}}
{{- $published := .PublishDate | default .Date -}}
{{- if not $published.IsZero -}}
{{- $schema = merge $schema (dict "datePublished" ($published.Format $iso8601)) -}}
{{- end -}}
{{- with .Lastmod -}}
{{- if not .IsZero -}}
{{- $schema = merge $schema (dict "dateModified" (.Format $iso8601)) -}}
{{- end -}}
{{- end -}}
{{- with .Site.Copyright -}}
{{- $schema = merge $schema (dict "license" .) -}}
{{- end -}}
{{- with $publisher -}}
{{- $schema = merge $schema (dict "publisher" .) -}}
{{- end -}}
{{- with $author -}}
{{- $schema = merge $schema (dict "author" .) -}}
{{- end -}}
<script type="application/ld+json">
{{ $schema }}
</script>
{{- end }}
{{ "<!-- LEAVING partial seo-schema.html -->" | safeHTML }}