-2

I was asked to display a pop-up to the user if he has at least 1 out of 5 extensions.

The extensions are: adblock plus,adBlock,Disconnect and etc...

I am not familiar with all the extensions and their affect on the DOM (except for adblock plus) so I am looking for a function that will check by the extension id if it exist in the browser?

I tried:

var detect = function(base, if_installed, if_not_installed) {
    var s = document.createElement('script');
    s.onerror = if_not_installed;
    s.onload = if_installed;
    document.body.appendChild(s);
    s.src = base + '/manifest.json';
}
detect('chrome-extension://' + 'gcbommkclmclpchllfjekcdonpmejbdp', function() {alert('boom!');});

Which I got from:http://blog.kotowicz.net/2012/02/intro-to-chrome-addons-hacking.html, He says it works, but I got this error:

Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.

Offir
  • 3,252
  • 3
  • 41
  • 73
  • 1
    If people are having problem viewing your site with HTTPS Everywhere, it's likely because you're doing HTTPS wrong. I would recommend that you look into that instead. – Frxstrem Oct 31 '16 at 15:40
  • 3
    "Please disable the SUPER USEFUL extension for best viewing", seriously? What's next "This website is best viewed at 800x600px resolution in Internet Explorer"? Because it seems like a huge step back in how we do web nowadays. – VLAZ Oct 31 '16 at 15:46
  • @vlaz, I agree with you but as you know, many times you get tasks from "product" department that not always you agree with... – Offir Oct 31 '16 at 15:48
  • 1
    If your problem is that you have assets within your site that are not available via HTTPS even though your pages themselves are, you could try something like [CrossOrigin.me](https://crossorigin.me/). If that works for you, you should consider making sure all your content gets moved to real HTTPS paths in the future. – UtopiaLtd Oct 31 '16 at 16:01
  • 1
    Ugh, this is a rather drastic change from the original question. Not sure if, in general, it's better to open a new question for that. However, specifically for this situation, I don't think there is a good general way to detect _specific_ extensions across different browsers. – VLAZ Oct 31 '16 at 16:17
  • Ha ha , found an answer for this problem! – Offir Oct 31 '16 at 16:37
  • @OffirPe'er Regarding your edit, the solution you tried is old, from 2012. Back then, `web_accessible_resources` wasn't a thing and you could sniff the extensions this way. Not anymore. – Xan Oct 31 '16 at 19:35

2 Answers2

2

That extension probably makes changes to the HTML headers or at least something in the DOM. So figure out what that change might be and detect that using JS.

If that is no good, take a look here.
Check whether user has a Chrome extension installed

Community
  • 1
  • 1
TheValyreanGroup
  • 3,554
  • 2
  • 12
  • 30
  • 1
    Why was this downvoted? – TheValyreanGroup Oct 31 '16 at 15:59
  • This is a perfectly legitimate troubleshooting answer. Please do not downvote. – Korgrue Oct 31 '16 at 16:08
  • Not sure if that's the reason (didn't downvote), but this only accounts for Chrome. It also uses the ID, but I don't know if that gets generated if you don't get the extension from the store, and HTTPS Everywhere is available from the EFF page. EDIT: or...not. Apparently the link on the EFF page goes to the store. So scratch that. – VLAZ Oct 31 '16 at 16:09
  • I didn't downvote it, I edited the question, please take a look at it... – Offir Oct 31 '16 at 16:14
  • The linked question is about cooperating between a Chrome extension and a webpage, both written by the same developer/developer team, to allow the webpage to detect *their extension*. That is a *very* different situation than detecting that an extension is installed without the cooperation of the extension. – Makyen Oct 31 '16 at 16:29
  • @OffirPe'er You just changed the entire question, they're barely even related. – TheValyreanGroup Oct 31 '16 at 16:46
-1

You can check current protocol with window.location.protocol

Eugene Tsakh
  • 2,777
  • 2
  • 14
  • 27