<!-- Improved Join Now button + robust 7s redirect for Blogger -->
<div id="join-now-container" style="text-align:center; margin:20px 0;">
<button id="joinNowBtn"
style="font-size:18px; padding:12px 28px; border-radius:8px; border:0; cursor:pointer;
background:#e60000; color:white; font-weight:bold;">
Join Now
</button>
<div id="jn-msg" style="margin-top:8px; font-size:14px; display:none;"></div>
<div id="jn-manual" style="margin-top:8px; font-size:14px; display:none;"></div>
</div>
<script type="text/javascript">
(function(){
// ==== আপনার লিংকগুলো এখানে বসান ====
var adsterraLink = "https://www.effectivegatecpm.com/mcp4jgwr?key=ecea75279cbd5183ca69c05a2f9c1a57"; // <-- Adsterra Direct Link
var afterRedirectLink = "https://www.effectivegatecpm.com/v8m386sxd?key=d049f02b099928f15bd684c8e550c5eb"; // <-- 7 সেকেন্ড পরে যেখনে পাঠাবেন
var delayMs = 7000; // ৭ সেকেন্ড
var btn = document.getElementById('joinNowBtn');
var msg = document.getElementById('jn-msg');
var manual = document.getElementById('jn-manual');
function showMessage(text){
msg.style.display = 'block';
msg.textContent = text;
}
function showManualLink(){
manual.style.display = 'block';
manual.innerHTML = 'Pop-up blocked? <a href="' + adsterraLink + '" target="_blank" rel="noopener noreferrer">Click here to open</a>';
}
btn.addEventListener('click', function(e){
// এগুলো একে অপরের পরে চেষ্টা করবে
var openedWindow = null;
try {
// প্রথমে সরাসরি window.open চেষ্টা
openedWindow = window.open(adsterraLink, '_blank');
} catch(err) {
openedWindow = null;
}
// যদি window.open সফল না হয় (ব্রাউজার ব্লক করে), প্রোগ্রাম্যাটিকালি একটি <a> ক্লিক করে দেখাই
if (!openedWindow) {
try {
var a = document.createElement('a');
a.href = adsterraLink;
a.target = '_blank';
a.rel = 'noopener noreferrer';
// some browsers require it to be in DOM
a.style.display = 'none';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
// small timeout: browsers may still block, so we can't be 100% sure
// we will still check openedWindow via window.open attempt with a short delay below
} catch(err) {
// ignore
}
}
// Give the browser a tiny moment then check whether a new window/tab is likely opened.
setTimeout(function(){
// Heuristic: if last window.open returned non-null we assume success.
// There's no reliable cross-browser way to detect popup if created by <a> click.
var popupLikely = (openedWindow !== null);
if (!popupLikely) {
// Show manual fallback link and inform user to allow popups
showMessage('Could not open the Adsterra link automatically. Please allow pop-ups or use the manual link below.');
showManualLink();
return; // cannot reliably auto-redirect if new tab didn't open
}
// যদি এখানে পর্যন্ত আসে মানে নতুন ট্যাব খুলেছে — কাউন্টডাউন শুরু করে মূল ট্যাব রিডাইরেক্ট
var remaining = Math.ceil(delayMs / 1000);
msg.style.display = 'block';
msg.textContent = 'Redirecting this tab in ' + remaining + ' second' + (remaining>1 ? 's' : '') + '...';
var interval = setInterval(function(){
remaining--;
if (remaining > 0) {
msg.textContent = 'Redirecting this tab in ' + remaining + ' second' + (remaining>1 ? 's' : '') + '...';
}
}, 1000);
setTimeout(function(){
clearInterval(interval);
msg.textContent = 'Redirecting now...';
// Final redirect of the current tab
window.location.href = afterRedirectLink;
}, delayMs);
}, 200); // 200ms ডিলে — দরকার হলে বাড়ান
});
})();
</script>
Comments
Post a Comment