Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yangyang0507 committed Nov 27, 2024
1 parent 82e8c92 commit e0002a4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
33 changes: 20 additions & 13 deletions src/components/CheckAdBlocked.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,58 @@
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);
});
</script>
<div
class="{adBlockDetected
class="{hasAdBlockDetected
? 'flex'
: 'hidden'} fixed inset-0 bg-black bg-opacity-90 z-[99999]"
>
Expand Down Expand Up @@ -75,4 +82,4 @@
</a>
</div>
</div>
</div>
</div>
17 changes: 0 additions & 17 deletions src/components/LastedDependency.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e0002a4

Please sign in to comment.