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

Adblock Workaround #1701

Closed
BennyHinrichs opened this issue Apr 17, 2019 · 1 comment
Closed

Adblock Workaround #1701

BennyHinrichs opened this issue Apr 17, 2019 · 1 comment

Comments

@BennyHinrichs
Copy link

This is my workaround for adblockers. Thought I'd put it on here so that anyone looking in the future can find a quick solution.

async function hasAdblock() {
  var hasAdblock = false;
  var testAd = document.createElement('div');
  testAd.innerHTML = ' ';
  testAd.className = 'ads ad adsbox doubleclick ad-placement carbon-ads';
  document.body.appendChild(testAd);
  await new Promise(resolve => {
    setTimeout(() => {
      testAd.offsetHeight === 0 && (hasAdblock = true);
      testAd.remove();
      resolve();
    }, 100);
  });
  return hasAdblock;
};

Usage:

hasAdblock().then(value => value ? pdf.download() : pdf.open());

If an adblocker is installed, download, otherwise open.

Are there ways to tag a post? "pdfmake open not working" "pdfmake print not working"

@liborm85
Copy link
Collaborator

liborm85 commented Sep 1, 2019

See #800 (comment)

@liborm85 liborm85 closed this as completed Sep 1, 2019
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

2 participants