Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK Ad blocker prevention #96

Open
Tracked by #2
thejhh opened this issue Apr 14, 2024 · 0 comments
Open
Tracked by #2

TASK Ad blocker prevention #96

thejhh opened this issue Apr 14, 2024 · 0 comments

Comments

@thejhh
Copy link
Contributor

thejhh commented Apr 14, 2024

Goal

Implement dynamic code which detects if the ad code isn't placed on the DOM, and in this case prevent the use of the
game. We could also add the ad code dynamically there.

Example

Something like this:

// This function checks if a particular ad script can be loaded
function detectAdBlocker() {
    let adBlockEnabled = false;
    const testAd = document.createElement('div');
    testAd.innerHTML = ' ';
    testAd.className = 'adsbox';
    document.body.appendChild(testAd);

    if (testAd.offsetHeight === 0) {
        adBlockEnabled = true;
    }
    testAd.remove();

    return adBlockEnabled;
}

// Example usage
window.addEventListener('load', () => {
    if (detectAdBlocker()) {
        document.body.innerHTML = '<p>Please disable your ad blocker to use this site.</p>';
        // Additional code to disable app functionality
    }
});

Tasks

@thejhh thejhh mentioned this issue Apr 14, 2024
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant