diff --git a/lib/elemHide.js b/lib/elemHide.js
--- a/lib/elemHide.js
+++ b/lib/elemHide.js
@@ -142,22 +142,25 @@
 
 /**
  * Returns the list of selectors that apply on a given domain from the subset
  * of filters that do not apply unconditionally on all domains.
  *
  * @param {string} domain The domain.
  * @param {boolean} specificOnly Whether selectors from generic filters should
  *   be included.
+ * @param {boolean} [withExceptions=false] Whether exceptions should be
+ *   included.
  *
  * @returns {Array.<string>} The list of selectors.
  */
-function getConditionalSelectors(domain, specificOnly)
+function getConditionalSelectors(domain, specificOnly, withExceptions = false)
 {
   let selectors = [];
+  let exceptions = [];
 
   let excluded = new Set();
   let currentDomain = domain;
 
   // This code is a performance hot-spot, which is why we've made certain
   // micro-optimisations. Please be careful before making changes.
   while (true)
   {
@@ -171,32 +174,38 @@
       {
         if (!isIncluded)
         {
           excluded.add(filter);
         }
         else
         {
           let {selector} = filter;
-          if ((excluded.size == 0 || !excluded.has(filter)) &&
-              !ElemHideExceptions.getException(selector, domain))
+          if (excluded.size == 0 || !excluded.has(filter))
           {
-            selectors.push(selector);
+            let exception = ElemHideExceptions.getException(selector, domain);
+            if (!exception)
+              selectors.push(selector);
+            else if (withExceptions)
+              exceptions.push(exception);
           }
         }
       }
     }
 
     if (currentDomain == "")
       break;
 
     let nextDot = currentDomain.indexOf(".");
     currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1);
   }
 
+  if (withExceptions)
+    selectors.exceptions = exceptions;
+
   return selectors;
 }
 
 /**
  * Returns the default style sheet that applies on all domains.
  * @returns {string}
  */
 function getDefaultStyleSheet()
@@ -355,43 +364,47 @@
    * Generates a style sheet for a given domain based on the current set of
    * filters.
    *
    * @param {string} domain The domain.
    * @param {boolean} [specificOnly=false] Whether selectors from generic
    *   filters should be included.
    * @param {boolean} [includeSelectors=false] Whether the return value should
    *   include a separate list of selectors.
+   * @param {boolean} [withExceptions=false] Whether the selectors should
+   *   include exceptions. Ignored if <code>includeSelectors</code> is
+   *   <code>false</code>.
    *
    * @returns {ElemHideStyleSheet} An object containing the CSS code and the
    *   list of selectors.
    */
   generateStyleSheetForDomain(domain, specificOnly = false,
-                              includeSelectors = false)
+                              includeSelectors = false, withExceptions = false)
   {
     let code = null;
     let selectors = null;
 
     if (domain[domain.length - 1] == ".")
       domain = domain.replace(/\.+$/, "");
 
     domain = domain.toLowerCase();
 
     if (specificOnly)
     {
-      selectors = getConditionalSelectors(domain, true);
+      selectors = getConditionalSelectors(domain, true,
+                                          includeSelectors && withExceptions);
       code = createStyleSheet(selectors);
     }
     else
     {
       let knownSuffix = getKnownSuffix(domain);
 
       if (includeSelectors)
       {
-        selectors = getConditionalSelectors(knownSuffix, false);
+        selectors = getConditionalSelectors(knownSuffix, false, withExceptions);
         code = knownSuffix == "" ? getCommonStyleSheet() :
                  (getDefaultStyleSheet() + createStyleSheet(selectors));
 
         selectors = getUnconditionalSelectors().concat(selectors);
       }
       else
       {
         code = knownSuffix == "" ? getCommonStyleSheet() :
