Fix: don't run thread_inject.js in the CC

The thread_inject.js script is injected into the Community Console when
loading a URL of the form
https://support.google.com/s/community/*/thread/, because it matches the
https://support.google.com/*/thread/* pattern.

A check was added to the script so it only runs when the page loaded is
TW and not the CC.

Change-Id: Ia199916f2b658e47c2a4f7c14651325b3da63d62
diff --git a/src/content_scripts/thread_inject.js b/src/content_scripts/thread_inject.js
index 89ef2f6..706277f 100644
--- a/src/content_scripts/thread_inject.js
+++ b/src/content_scripts/thread_inject.js
@@ -1,61 +1,64 @@
-var intersectionObserver;
+var CCRegex = /^https:\/\/support\.google\.com\/s\/community/;
+if (!CCRegex.test(location.href)) {
+  var intersectionObserver;
 
-function intersectionCallback(entries, observer) {
-  entries.forEach(entry => {
-    if (entry.isIntersecting) {
-      entry.target.click();
+  function intersectionCallback(entries, observer) {
+    entries.forEach(entry => {
+      if (entry.isIntersecting) {
+        entry.target.click();
+      }
+    });
+  };
+
+  var intersectionOptions = {
+    threshold: 1.0,
+  };
+
+  chrome.storage.sync.get(null, function(items) {
+    var path = document.location.pathname.split('/');
+    if (path[path.length - 1] == 'new' ||
+        (path.length > 1 && path[path.length - 1] == '' &&
+         path[path.length - 2] == 'new')) {
+      return;
+    }
+
+    var redirectLink = document.querySelector('.community-console');
+    if (items.redirect && redirectLink !== null) {
+      window.location = redirectLink.href;
+    } else {
+      var button =
+          document.querySelector('.thread-all-replies__load-more-button');
+      if (items.thread && button !== null) {
+        intersectionObserver =
+            new IntersectionObserver(intersectionCallback, intersectionOptions);
+        intersectionObserver.observe(button);
+      }
+      var allbutton =
+          document.querySelector('.thread-all-replies__load-all-button');
+      if (items.threadall && button !== null) {
+        intersectionObserver =
+            new IntersectionObserver(intersectionCallback, intersectionOptions);
+        intersectionObserver.observe(allbutton);
+      }
+
+      if (items.profileindicator) {
+        injectScript(
+            chrome.runtime.getURL('injections/profileindicator_inject.js'));
+        injectStylesheet(
+            chrome.runtime.getURL('injections/profileindicator_inject.css'));
+
+        // In order to pass i18n strings to the injected script, which doesn't
+        // have access to the chrome.i18n API.
+        window.addEventListener('geti18nString', evt => {
+          var request = evt.detail;
+          var response = {
+            string: chrome.i18n.getMessage(request.msg),
+            requestId: request.id
+          };
+          window.dispatchEvent(
+              new CustomEvent('sendi18nString', {detail: response}));
+        });
+      }
     }
   });
-};
-
-var intersectionOptions = {
-  threshold: 1.0,
-};
-
-chrome.storage.sync.get(null, function(items) {
-  var path = document.location.pathname.split('/');
-  if (path[path.length - 1] == 'new' ||
-      (path.length > 1 && path[path.length - 1] == '' &&
-       path[path.length - 2] == 'new')) {
-    return;
-  }
-
-  var redirectLink = document.querySelector('.community-console');
-  if (items.redirect && redirectLink !== null) {
-    window.location = redirectLink.href;
-  } else {
-    var button =
-        document.querySelector('.thread-all-replies__load-more-button');
-    if (items.thread && button !== null) {
-      intersectionObserver =
-          new IntersectionObserver(intersectionCallback, intersectionOptions);
-      intersectionObserver.observe(button);
-    }
-    var allbutton =
-        document.querySelector('.thread-all-replies__load-all-button');
-    if (items.threadall && button !== null) {
-      intersectionObserver =
-          new IntersectionObserver(intersectionCallback, intersectionOptions);
-      intersectionObserver.observe(allbutton);
-    }
-
-    if (items.profileindicator) {
-      injectScript(
-          chrome.runtime.getURL('injections/profileindicator_inject.js'));
-      injectStylesheet(
-          chrome.runtime.getURL('injections/profileindicator_inject.css'));
-
-      // In order to pass i18n strings to the injected script, which doesn't
-      // have access to the chrome.i18n API.
-      window.addEventListener('geti18nString', evt => {
-        var request = evt.detail;
-        var response = {
-          string: chrome.i18n.getMessage(request.msg),
-          requestId: request.id
-        };
-        window.dispatchEvent(
-            new CustomEvent('sendi18nString', {detail: response}));
-      });
-    }
-  }
-});
+}