ttsvetko
3/21/2014 - 3:27 PM

Code running inside chrome extension check

Code running inside chrome extension check

(function () {
  var isChrome = (function () {
    var contentWindow,
        iframe = document.createElement("iframe"),
        isChrome;
    if ("sandbox" in iframe) {
      try {
        iframe.sandbox = "allow-same-origin";
        iframe.src='/';
        iframe.style="display: none";
        document.body.appendChild(iframe);
        contentWindow = iframe.contentWindow;
        isChrome = (contentWindow.chrome && contentWindow.chrome.extension);
        document.body.removeChild(iframe);
      } catch(e) {}
    } else {
      isChrome = false;
    }
    return isChrome;
  }());
}());