Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To detect if an extension is installed in Chrome, you can check for a known resource included in the extension such as an image. Resources for the extension are referenced using the following URL pattern:</p> <pre><code>chrome-extension://&lt;extensionID&gt;/&lt;pathToFile&gt; </code></pre> <p>The basic detection technique involves creating a hidden image tag and attaching load and error events to it to see if the image loads (as described <a href="http://webdevwonders.com/detecting-firefox-add-ons/" rel="noreferrer">here</a> for Firefox):</p> <pre><code>extensionImg.setAttribute("src", "chrome-extension://&lt;INSERT EXTENSION ID HERE&gt;/images/someImage.png"); // See below for discussion of how to find this /* * Add event listeners for both "load"- and "error"-event * Set the variable showing the existence of the extension by * setting it to "true" or "false" according to the fired event */ extensionImg.addEventListener("load", function(e) { extensionExists = true; removeImgTag(e); }, false); extensionImg.addEventListener("error", function(e) { extensionExists = false; removeImgTag(e); }, false); function removeImgTag(e) { e.currentTarget.parentNode.removeChild(e.currentTarget); } </code></pre> <p>Check the installation directory of the extension in the Chrome configuration to find a likely target for detection. On my Linux workstation extensions are located in:</p> <pre><code> ~/.config/chromium/Default/Extensions </code></pre> <p>You can see that I have 3 extensions installed right now:</p> <pre><code>~/.config/chromium/Default/Extensions$ ls cpecbmjeidppdiampimghndkikcmoadk nmpeeekfhbmikbdhlpjbfmnpgcbeggic cpngackimfmofbokmjmljamhdncknpmg </code></pre> <p>The odd looking names are the unique IDs given to the extension when it is uploaded to the Chrome webstore. You can obtain the ID either from the webstore or by going to the Extensions tab (wrench -> Extensions) and hovering over the link to the extension in question, or "Screen Capture (by Google)" in this case (note the asterisked extension ID):</p> <pre><code>https://chrome.google.com/webstore/detail/**cpngackimfmofbokmjmljamhdncknpmg** </code></pre> <p>In the extension directory there will be one or more versions; you can ignore this. Within the version directory is the actual content of the extension:</p> <pre><code>~/.config/chromium/Default/Extensions/cpngackimfmofbokmjmljamhdncknpmg/5.0.3_0$ ls account.js images page.js sina_microblog.js ajax.js isLoad.js picasa.js site.js background.html _locales plugin style.css editor.js manifest.json popup.html ui.js facebook.js notification.html sha1.js upload_ui.js hotkey_storage.js oauth.js shortcut.js hub.html options.html showimage.css i18n_styles page_context.js showimage.html </code></pre> <p>In the case of the Screen Capture extension there are a number of images to use:</p> <pre><code>~/.config/chromium/Default/Extensions/cpngackimfmofbokmjmljamhdncknpmg/5.0.3_0/images$ ls arrow.png icon_128.png icon_save.png print.png copy.png icon_16.png line.png region.png cross.png icon_19.png loading.gif screen.png custom.png icon_32.png loading_icon.gif sina_icon.png delete_account_icon.png icon_48.png mark.png toolbar_bg.png down_arrow.png icon_close.png picasa_icon.png upload.png facebook_icon.png icon_copy.png popup_bg.jpg whole.png </code></pre> <p>These can be referenced under this URL:</p> <pre><code>chrome-extension://cpngackimfmofbokmjmljamhdncknpmg/images/arrow.png </code></pre> <p>This technique obviously depends on the stability of the content of the extension. I recommend using an image that looks likely to remain through all versions. </p> <hr> <p>As mentioned above, the same technique can be used to detect Firefox extensions. In this case the content URL looks like this:</p> <pre><code>chrome://&lt;EXTENSION NAME&gt;/content/&lt;PATH TO RESOURCE&gt; </code></pre> <p>On my Linux workstation Firefox extensions are located in:</p> <pre><code> ~/.mozilla/firefox/&lt;USER PROFILE ID&gt;/extensions </code></pre> <p>Where &lt;USER PROFILE ID&gt; looks something like this: "h4aqaewq.default"</p> <p>You can see that I have 2 extensions installed right now, one of which is a directory installation and the other of which is a <a href="https://developer.mozilla.org/en/XPInstall" rel="noreferrer">XPI (pronounced "zippy")</a> file:</p> <pre><code>~/.mozilla/firefox/h4aqaewq.default/extensions$ ls {3e9a3920-1b27-11da-8cd6-0800200c9a66} staged firebug@software.joehewitt.com.xpi </code></pre> <p>The "staged" directory is where Firefox keeps extensions that will be updated (I think). The GUID directory with the brackets is a directory-based extension installation, and the .xpi file is Firebug.</p> <p><strong>Note</strong>: XPI is going away (see the link above). It's basically a zip file that can be opened and inspected by anything that understands zip. I used Emacs.</p> <p>Finding the extension ID in Firefox is a bit more involved. Go to "Tools -> Add-ons", click the Extensions tab, click the "More" link next to the extension description, then click the "reviews" link to go to the Firefox extension site and get the ID from the URL (note the asterisked extension ID):</p> <pre><code>https://addons.mozilla.org/en-US/firefox/addon/**firebug**/reviews/?src=api </code></pre> <p>There's probably an easier way to do this; suggestions welcome.</p> <p>TODO: how to find a likely image in a Firefox extension.</p> <hr> <p>As an extra note, in Chrome you can only communicate with an extension via the shared DOM of the page: <a href="http://code.google.com/chrome/extensions/content_scripts.html#host-page-communication" rel="noreferrer">Host page communication</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload