Вот несколько способов создать скрипт антиблокировки рекламы YouTube на английском языке:
Метод 1: обнаружение Adblock с помощью JavaScript
<script>
// Check if an adblocker is enabled
if (typeof blockAdBlock === 'undefined') {
// Adblock is enabled
alert('Please disable your adblocker to continue watching this video.');
} else {
// Adblock is not enabled
// Insert your video player code here
}
</script>
Метод 2: наложение видеоплеера
<div id="video-container">
<!-- Insert your video player code here -->
</div>
<div id="overlay-container">
<div id="adblock-overlay">
<p>Please disable your adblocker to continue watching this video.</p>
</div>
</div>
#overlay-container {
position: relative;
}
#adblock-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
text-align: center;
color: white;
font-size: 18px;
padding-top: 50px;
}
<script>
// Check if an adblocker is enabled
if (typeof blockAdBlock === 'undefined') {
// Adblock is enabled
document.getElementById('video-container').style.display = 'none';
document.getElementById('overlay-container').style.display = 'block';
} else {
// Adblock is not enabled
document.getElementById('video-container').style.display = 'block';
document.getElementById('overlay-container').style.display = 'none';
}
</script>
Метод 3. Замена рекламы пользовательским контентом
<div id="video-container">
<!-- Insert your video player code here -->
</div>
<div id="ad-container">
<!-- Insert your ad content here -->
</div>
<script>
// Check if an adblocker is enabled
if (typeof blockAdBlock === 'undefined') {
// Adblock is enabled
document.getElementById('ad-container').innerHTML = 'Please disable your adblocker to continue watching this video.';
} else {
// Adblock is not enabled
// Remove the ad container
var adContainer = document.getElementById('ad-container');
adContainer.parentNode.removeChild(adContainer);
// Insert your video player code here
}
</script>