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 e0002a4 commit c36c0e6
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/components/CheckAdBlocked.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,17 @@
hasAdBlockDetected = false;
}
function adBlockDetected() {
console.log("ADBlock Detected...");
function checkAdBlocker() {
let adBlockNoticeClosed = session.get(key) ?? false;
if (adBlockNoticeClosed) {
console.log("ADBlock Notice Chosen Closed...");
console.log("ADBlock notice closed...");
return;
}
hasAdBlockDetected = true;
}
function checkAdBlocker() {
console.log("Checking ADBlock...");
// check ad block init
if (window._AdBlockInit === undefined) {
adBlockDetected();
console.log("ADBlock detected, cause window._AdBlockInit is undefined");
hasAdBlockDetected = true;
return;
}
Expand All @@ -38,11 +33,13 @@
fetch(scriptUrl)
.then(response => {
if (!response.ok) {
adBlockDetected();
console.log("ADBlock detected, cause script can't be loaded");
hasAdBlockDetected = true;
}
})
.catch(() => {
adBlockDetected();
console.log("ADBlock detected, cause script banned");
hasAdBlockDetected = true;
});
}
Expand Down

0 comments on commit c36c0e6

Please sign in to comment.