From e0002a4fbaeb99c8ed4193bbee2ce72ce2312edb Mon Sep 17 00:00:00 2001 From: "D.Yang" Date: Wed, 27 Nov 2024 17:44:47 +0800 Subject: [PATCH] update --- src/components/CheckAdBlocked.svelte | 33 ++++++++++++++++----------- src/components/LastedDependency.astro | 17 -------------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/src/components/CheckAdBlocked.svelte b/src/components/CheckAdBlocked.svelte index fcb4f6c2..53b1001a 100644 --- a/src/components/CheckAdBlocked.svelte +++ b/src/components/CheckAdBlocked.svelte @@ -2,43 +2,50 @@ import { onMount } from "svelte"; import store from "store2"; - let adBlockDetected = false; + let hasAdBlockDetected = false; let session = store.session; const key = "adBlockNoticeClosed"; - function checkAdBlocker() { + function closeNotice() { + session.set(key, true); + hasAdBlockDetected = false; + } + + function adBlockDetected() { + console.log("ADBlock Detected..."); let adBlockNoticeClosed = session.get(key) ?? false; if (adBlockNoticeClosed) { + console.log("ADBlock Notice Chosen Closed..."); return; } + hasAdBlockDetected = true; + } + + function checkAdBlocker() { + console.log("Checking ADBlock..."); // check ad block init if (window._AdBlockInit === undefined) { - adBlockDetected = true; + adBlockDetected(); return; } // check script banned - checkAdScriptBanned('https://cdn.wwads.cn/js/makemoney.js'); + checkAdScriptBanned('https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'); } function checkAdScriptBanned(scriptUrl) { fetch(scriptUrl) .then(response => { if (!response.ok) { - adBlockDetected = true; + adBlockDetected(); } }) .catch(() => { - adBlockDetected = true; + adBlockDetected(); }); } - function closeNotice() { - session.set(key, true); - adBlockDetected = false; - } - onMount(() => { const interval = setInterval(checkAdBlocker, 5000); return () => clearInterval(interval); @@ -46,7 +53,7 @@
@@ -75,4 +82,4 @@
- \ No newline at end of file + diff --git a/src/components/LastedDependency.astro b/src/components/LastedDependency.astro index 36c19bed..1be38a5e 100644 --- a/src/components/LastedDependency.astro +++ b/src/components/LastedDependency.astro @@ -9,23 +9,6 @@ export interface Props { const {groupId, artifactId} = Astro.props as Props; // 调用中央库 API 返回最新的 Jar 包版本信息 -const fetchJarVersion = async (groupId: string, artifactId: string) => { - try { - // Maven 中央库的搜索 API,这个 URL 可能需要根据 Maven API 的最新文档进行更新 - const searchUrl = `https://search.maven.org/solrsearch/select?q=g:"${encodeURIComponent(groupId)}"+AND+a:"${encodeURIComponent(artifactId)}"&rows=1&wt=json`; - const response = await fetch(searchUrl); - if (!response.ok) { - console.error(`Failed to fetch version for ${groupId}:${artifactId}`); - return 'lasted-version'; - } - const data = await response.json(); - return data.response.docs[0].latestVersion; - } catch (error) { - console.error("Error fetching Jar version:", error); - return 'lasted-version'; - } -}; - const fetchJarVersionByXML = async (groupId: string, artifactId: string) => { try { // 构建 metadata XML URL