Skip to content

TASK Ad blocker prevention #96

@thejhh

Description

@thejhh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions