[] [] [] – GeeksforGeeks [] elem.id) if(abp) { for(let curr_unit of units) { const iframe = document.createElement(‘iframe’); iframe.setAttribute(‘src’,”https://aa.geeksforgeeks.org/iframe.html?code=”+curr_unit.substr(1)) const elem = document.getElementById(curr_unit) const div = document.createElement(‘div’); div.setAttribute(‘id’,curr_unit.substr(1)) let sizes = curr_unit.split(“_”); sizes = sizes.filter(val => val.includes(‘x’)); let [width, height] = sizes[0].split(“x”); iframe.style.width = `${+width+20}px` iframe.style.height = `${+height+20}px` if(elem) { elem.appendChild(iframe); } } var gfgAdDivs = […document.querySelectorAll(‘div[id^=GFG_AD_]’)]; gfgAdDivs.forEach(gfgDiv => document.getElementById(gfgDiv.id).removeAttribute(“style”)); jQuery(‘#secondary .widget_text:last-child’).css({“position”: “unset”}); } });*/ AdblockPlus.detect(“https://cdnads.geeksforgeeks.org/res/px.gif”, function(abp){ window.googletag = window.googletag || {cmd: []}; window.abp=abp; var elms = […document.querySelectorAll(‘div[id^=_GFG_ABP_]’)]; //const units=elms.map(elem=>elem.id) const units = elms .filter(elem => !(window.innerWidth elem.id); if(abp) { isAdBlockerPresent = true; for(let curr_unit of units) { const iframe = document.createElement(‘iframe’); iframe.addEventListener(“load”, () => { iframe.contentWindow.postMessage(JSON.stringify({host: window.location.host,category: window.arrPostCatName,parentWidth: window.innerWidth}),’https://aa.geeksforgeeks.org’); }); iframe.setAttribute(‘src’,”https://aa.geeksforgeeks.org/iframe.html?code=”+curr_unit.substr(1)) const elem = document.getElementById(curr_unit) const div = document.createElement(‘div’); div.setAttribute(‘id’,curr_unit.substr(1)) let sizes = curr_unit.split(“_”); sizes = sizes.filter(val => val.includes(‘x’)); let [width, height] = sizes[0].split(“x”); iframe.style.width = `${+width+20}px` iframe.style.height = `${+height+20}px` if(elem) { elem.appendChild(iframe); } } var gfgAdDivs = […document.querySelectorAll(‘div[id^=GFG_AD_]’)]; gfgAdDivs.forEach(gfgDiv => document.getElementById(gfgDiv.id).removeAttribute(“style”)); jQuery(‘#secondary .widget_text:last-child’).css({“position”: “unset”}); } else{ try { var isAdblockEnabled = t => fetch( new Request(‘https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js’, { method: ‘HEAD’, mode: ‘no-cors’ }) ).catch(t); isAdblockEnabled(() => { // here goes modal pop-up code isAdBlockerPresent = true; }); } catch (err) {console.error(err);} } }); function closeAdBlockPopupModal(){ const modal = document.getElementById(“adBlockerModal”); $(‘body’).removeClass(‘body-for-ad-blocker’); $(‘#adBlockerModal’).remove() localStorage.setItem(‘gfgAdBlockPopup’,new Date()) } function showAdblockerModal(){ let randomNumberForButtonText = Math.round(Math.random()); let currTime = new Date(); let lastTime = new Date(localStorage.getItem(‘gfgAdBlockPopup’)); if(((currTime-lastTime)/(1000*60*60))<1) { return; } const adBlockerModal = `
It seems that you are using an ad blocker.
Please disable it to support us!
“For an ad-free experience and exclusive features, subscribe to our Premium Plan!”
`;
$(‘body’).append(adBlockerModal);
$(‘body’).addClass(‘body-for-ad-blocker’);
const modal = document.getElementById(“adBlockerModal”);
modal.style.display = “block”;
}
function handleAdBlockerClick(type){
if(type == ‘disabled’){
window.location.reload();
}
else if(type == ‘info’){
document.getElementById(“ad-blocker-div”).style.display = “none”;
document.getElementById(“ad-blocker-info-div”).style.display = “flex”;
handleAdBlockerIconClick(0);
}
}
var lastSelected= null;
//Mapping of name and video URL with the index.
const adBlockerVideoMap = [
[‘Ad Block Plus’,’https://media.geeksforgeeks.org/auth-dashboard-uploads/abp-blocker-min.mp4′],
[‘Ad Block’,’https://media.geeksforgeeks.org/auth-dashboard-uploads/Ad-block-min.mp4′],
[‘uBlock Origin’,’https://media.geeksforgeeks.org/auth-dashboard-uploads/ub-blocke-min.mp4′],
[‘uBlock’,’https://media.geeksforgeeks.org/auth-dashboard-uploads/U-blocker-min.mp4′],
]
function handleAdBlockerIconClick(currSelected){
const videocontainer = document.getElementById(‘ad-blocker-info-div-gif’);
const videosource = document.getElementById(‘ad-blocker-info-div-gif-src’);
if(lastSelected != null){
document.getElementById(“ad-blocker-info-div-icons-“+lastSelected).style.backgroundColor = “white”;
document.getElementById(“ad-blocker-info-div-icons-“+lastSelected).style.borderColor = “#D6D6D6”;
}
document.getElementById(“ad-blocker-info-div-icons-“+currSelected).style.backgroundColor = “#D9D9D9”;
document.getElementById(“ad-blocker-info-div-icons-“+currSelected).style.borderColor = “#848484”;
document.getElementById(‘ad-blocker-info-div-name-span’).innerHTML = adBlockerVideoMap[currSelected][0]
videocontainer.pause();
videosource.setAttribute(‘src’, adBlockerVideoMap[currSelected][1]);
videocontainer.load();
videocontainer.play();
lastSelected = currSelected;
}
[] []