Refactored code to comply with Google Style Guides

This commit refactors JS, MD and Bash files in order to comply with the
Google style guides.

Change-Id: I5bc9a175d2400fa1095ba9eb1c8cff3ebfef4b8f
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..f6cb8ad
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1 @@
+BasedOnStyle: Google
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..e5dd176
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,15 @@
+root = true
+
+[*]
+end_of_line = lf
+insert_final_line = true
+charset = utf-8
+
+[*.{sh,bash}]
+indent_style = space
+indent_size = 2
+switch_case_indent = true
+
+[*.{html,css,js,json}]
+indent_style = space
+indent_size = 2
diff --git a/README.md b/README.md
index f651f8b..c3bf730 100644
--- a/README.md
+++ b/README.md
@@ -1,51 +1,96 @@
 # TW Power Tools
 [![Available in the Chrome Web Store](https://developer.chrome.com/webstore/images/ChromeWebStore_Badge_v2_206x58.png)](https://chrome.google.com/webstore/detail/infinite-scroll-in-tw/hpgakoecmgibigdbnljgecablpipbajb)
 
-An extension which brings several enhancements to the Google Forums and the Community Console.
+An extension which brings several enhancements to the Google Forums and the
+Community Console.
 
 ## Release cycle
-When the code in the `master` branch is considered to be stable, a release can be made. This is the procedure:
+When the code in the `master` branch is considered to be stable, a release can
+be made. This is the procedure:
 
-1. Tag the last commit with a version number (in the format `vx`, where x is the extension's [version number](https://developer.chrome.com/extensions/manifest/version) for that release) by running `git tag -a vx -m "vx"`. Note that the tag should be an annotated tag and not a lightweight tag, and it must be pushed to Gerrit after being created.
-2. Build the extension for both the stable and beta channels (this is explained in the next section). This will output a ZIP file for each release channel and each supported browser.
+1. Tag the last commit with a version number (in the format `vx`, where x is the
+extension's [version number](https://developer.chrome.com/extensions/manifest/version)
+for that release) by running `git tag -a vx -m "vx"`. Note that the tag should
+be an annotated tag and not a lightweight tag, and it must be pushed to Gerrit
+after being created.
+2. Build the extension for both the stable and beta channels (this is explained
+in the next section). This will output a ZIP file for each release channel and
+each supported browser.
 
-Afterwards, the release/build files must be submitted to the Chrome Web Store and addons.mozilla.org.
+Afterwards, the release/build files must be submitted to the Chrome Web Store
+and addons.mozilla.org.
 
 ### Submitting to the Chrome Web Store
-1. [Upload both release files](https://developer.chrome.com/webstore/publish#upload-your-item) to the Chrome Web Store, one for each release channel.
-2. [Submit both releases](https://developer.chrome.com/webstore/publish#submit-your-item-for-publishing) to be reviewed by the Chrome Web Store team, but in the case of the stable channel uncheck the "Publish automatically after it has passed review" option.
-3. Upload the beta release file to the [GitHub releases page](https://github.com/avm99963/infinitegforums/releases) under the newly created tag. Mark that release as a pre-release at GitHub.
+1. [Upload both release files](https://developer.chrome.com/webstore/publish#upload-your-item)
+to the Chrome Web Store, one for each release channel.
+2. [Submit both releases](https://developer.chrome.com/webstore/publish#submit-your-item-for-publishing)
+to be reviewed by the Chrome Web Store team, but in the case of the stable
+channel uncheck the "Publish automatically after it has passed review" option.
+3. Upload the beta release file to the
+[GitHub releases page](https://github.com/avm99963/infinitegforums/releases)
+under the newly created tag. Mark that release as a pre-release at GitHub.
 4. Wait until the beta release is reviewed and approved by Google.
-5. Test again the extension by using the beta channel. Check if the options have been transfered correctly from version to version, and wait some days (for instance between 3 and 5 days) to see if other people report issues with the updated version.
-6. If everything goes well, publish the update in the stable channel. The updated version should have already been reviewed by the Chrome Web Store team at this time.
-7. Update the release file in the GitHub releases page by removing the beta release file and uploading the stable release file. Also, remove the pre-release label.
+5. Test again the extension by using the beta channel. Check if the options have
+been transfered correctly from version to version, and wait some days (for
+instance between 3 and 5 days) to see if other people report issues with the
+updated version.
+6. If everything goes well, publish the update in the stable channel. The
+updated version should have already been reviewed by the Chrome Web Store team
+at this time.
+7. Update the release file in the GitHub releases page by removing the beta
+release file and uploading the stable release file. Also, remove the pre-release
+label.
 
-If during this process the release wasn't approved by Google or an issue was found during beta testing, a new release which fixes this should be created.
+If during this process the release wasn't approved by Google or an issue was
+found during beta testing, a new release which fixes this should be created.
 
 ### Submitting to addons.mozilla.org
 The procedure is similar to the one with the Chrome Web Store.
 
-@TODO: Add more details once the first version of the extension has been uploaded to addons.mozilla.org.
+@TODO: Add more details once the first version of the extension has been
+uploaded to addons.mozilla.org.
 
 ## Build the extension
-A zip file with the contents of the extension, which can be uploaded to the Chrome Web Store and addons.mozilla.org, can be created with any of the following procedures:
+A zip file with the contents of the extension, which can be uploaded to the
+Chrome Web Store and addons.mozilla.org, can be created with any of the
+following procedures:
 
 ### Using the release.bash script
-Run `bash release.bash -h` in order to learn how to use this command. To summarize, the command accepts the `--channel` and `--browser` flags (or their short versions `-c` and `-b`).
+Run `bash release.bash -h` in order to learn how to use this command. To
+summarize, the command accepts the `--channel` and `--browser` flags (or their
+short versions `-c` and `-b`).
 
-As an example, if you wanted to create a ZIP file of the beta-branded extension targeted for Firefox, you would run `bash release.bash -c beta -b gecko`.
+As an example, if you wanted to create a ZIP file of the beta-branded extension
+targeted for Firefox, you would run `bash release.bash -c beta -b gecko`.
 
 ### Using make
-You can also use _make_ to build the extension. This is just a wrapper for the `release.bash` command.
+You can also use _make_ to build the extension. This is just a wrapper for the
+`release.bash` command.
 
-Run `make all` to build the extension for all the available channels and browsers. You can also run `make {target}` where `{target}` is one of the following: `chromium-stable`, `chromium-beta`, `gecko-stable`, `gecko-beta`.
+Run `make all` to build the extension for all the available channels and
+browsers. You can also run `make {target}` where `{target}` is one of the
+following: `chromium-stable`, `chromium-beta`, `gecko-stable`, `gecko-beta`.
 
-Run `make clean` to clean all the release files (this removes the `out` folder, which is where the release files are saved).
+Run `make clean` to clean all the release files (this removes the `out` folder,
+which is where the release files are saved).
 
 ## Testing notes
-When testing the extension during development, you don't have to build the extension each time you want to import an updated version to Chrome/Firefox. Instead, run `bash generateManifest.bash {browser}` once, where `{browser}` is either `CHROMIUM` or `GECKO`, and this will generate a `manifest.json` file for the specified browser in the `src` directory. Now, you can load the `src` folder directly in the browser in order to import the extension, which removes the need to build it. When the `manifest.gjson` file is modified, you'll have to generate the manifest again.
+When testing the extension during development, you don't have to build the
+extension each time you want to import an updated version to Chrome/Firefox.
+Instead, run `bash generateManifest.bash {browser}` once, where `{browser}`
+is either `CHROMIUM` or `GECKO`, and this will generate a `manifest.json`
+file for the specified browser in the `src` directory. Now, you can load the
+`src` folder directly in the browser in order to import the extension, which
+removes the need to build it. When the `manifest.gjson` file is modified, you'll
+have to generate the manifest again.
 
-To test translations, you might want to set your browser's locale. This section tells you how to set the locale in [Windows](https://developer.chrome.com/extensions/i18n#testing-win), [Mac OS X](https://developer.chrome.com/extensions/i18n#testing-mac), [Linux](https://developer.chrome.com/extensions/i18n#testing-linux), and [Chrome OS](https://developer.chrome.com/extensions/i18n#testing-chromeos).
+To test translations, you might want to set your browser's locale. This section
+tells you how to set the locale in
+[Windows](https://developer.chrome.com/extensions/i18n#testing-win),
+[Mac OS X](https://developer.chrome.com/extensions/i18n#testing-mac),
+[Linux](https://developer.chrome.com/extensions/i18n#testing-linux),
+and [Chrome OS](https://developer.chrome.com/extensions/i18n#testing-chromeos).
 
 ## Beta channel
-The beta channel for Chrome is available [here](https://chrome.google.com/webstore/detail/infinite-scroll-in-tw-bet/memmklnkkhifmflmidnflfcdepamljef).
+The beta channel for Chrome is available
+[here](https://chrome.google.com/webstore/detail/infinite-scroll-in-tw-bet/memmklnkkhifmflmidnflfcdepamljef).
diff --git a/generateManifest.bash b/generateManifest.bash
index dd7df4e..29839c0 100644
--- a/generateManifest.bash
+++ b/generateManifest.bash
@@ -1,15 +1,17 @@
 #!/bin/bash
-
+#
 # Generates the manifest.json file according to the dependencies passed
 # via CLI arguments
 
-dependencies=( "$@" )
+dependencies=("$@")
 
 rm -f src/manifest.json
 cp templates/manifest.gjson src/manifest.json
 
 for dep in "${dependencies[@]}"; do
-  perl -0777 -pi -e "s/^#if defined\($dep\)\n([^#]*)#endif\n/\$1/gms" src/manifest.json
+  perl -0777 -pi -e "s/^#if defined\($dep\)\n([^#]*)#endif\n/\$1/gms" \
+    src/manifest.json
 done
 
-perl -0777 -pi -e "s/^#if defined\([^\n#]+\)\n[^#]*#endif\n//gms" src/manifest.json
+perl -0777 -pi -e "s/^#if defined\([^\n#]+\)\n[^#]*#endif\n//gms" \
+  src/manifest.json
diff --git a/release.bash b/release.bash
index fb03c6e..e261c37 100644
--- a/release.bash
+++ b/release.bash
@@ -1,8 +1,10 @@
 #!/bin/bash
+#
+# Generate release files (ZIP archives of the extension source code).
 
 # Prints help text
-function usage {
-  cat << END
+function usage() {
+  cat <<END
 
   Usage: $progname [--channel CHANNEL]
 
@@ -17,7 +19,7 @@
 }
 
 # Updates manifest.json field
-function set_manifest_field {
+function set_manifest_field() {
   sed -i -E "s/\"$1\": \"[^\"]*\"/\"$1\": \"$2\"/" src/manifest.json
 }
 
@@ -30,21 +32,30 @@
 
 while true; do
   case "$1" in
-    -h | --help ) usage; exit; ;;
-    -c | --channel ) channel="$2"; shift 2 ;;
-    -b | --browser ) browser="$2"; shift 2 ;;
-    * ) break ;;
+    -h | --help)
+      usage
+      exit
+      ;;
+    -c | --channel)
+      channel="$2"
+      shift 2
+      ;;
+    -b | --browser)
+      browser="$2"
+      shift 2
+      ;;
+    *) break ;;
   esac
 done
 
 if [[ $channel != "stable" && $channel != "beta" ]]; then
-  echo "channel parameter value is incorrect."
+  echo "channel parameter value is incorrect." >&2
   usage
   exit
 fi
 
 if [[ $browser != "chromium" && $browser != "gecko" ]]; then
-  echo "browser parameter value is incorrect."
+  echo "browser parameter value is incorrect." >&2
   usage
   exit
 fi
@@ -53,7 +64,7 @@
 
 # First of all, generate the appropriate manifest.json file for the
 # target browser
-dependencies=( ${browser^^} )
+dependencies=(${browser^^})
 
 bash generateManifest.bash "${dependencies[@]}"
 
@@ -90,7 +101,8 @@
 # Create ZIP file for upload to the Chrome Web Store
 mkdir -p out
 rm -rf out/twpowertools-$version-$browser-$channel.zip
-(cd src && zip -rq ../out/twpowertools-$version-$browser-$channel.zip * -x *.git*)
+(cd src &&
+  zip -rq ../out/twpowertools-$version-$browser-$channel.zip * -x *.git*)
 
 # Clean generated manifest.json file
 rm -f src/manifest.json
diff --git a/src/background.js b/src/background.js
index 315d6d8..3e73282 100644
--- a/src/background.js
+++ b/src/background.js
@@ -3,23 +3,23 @@
 }
 
 const defaultOptions = {
-  "list": true,
-  "thread": true,
-  "threadall": false,
-  "fixedtoolbar": false,
-  "redirect": false,
-  "history": false,
-  "loaddrafts": false,
-  "batchduplicate": false,
-  "escalatethreads": false,
-  "movethreads": false,
-  "increasecontrast": false,
-  "stickysidebarheaders": false
+  'list': true,
+  'thread': true,
+  'threadall': false,
+  'fixedtoolbar': false,
+  'redirect': false,
+  'history': false,
+  'loaddrafts': false,
+  'batchduplicate': false,
+  'escalatethreads': false,
+  'movethreads': false,
+  'increasecontrast': false,
+  'stickysidebarheaders': false,
 };
 
 function cleanUpOptions() {
   chrome.storage.sync.get(null, function(options) {
-    console.log("[cleanUpOptions] Previous options", options);
+    console.log('[cleanUpOptions] Previous options', options);
     var ok = true;
     for (const [opt, value] of Object.entries(defaultOptions)) {
       if (!(opt in options)) {
@@ -28,7 +28,7 @@
       }
     }
 
-    console.log("[cleanUpOptions] New options", options);
+    console.log('[cleanUpOptions] New options', options);
 
     if (!ok) {
       chrome.storage.sync.set(options);
@@ -37,7 +37,7 @@
 }
 
 chrome.runtime.onInstalled.addListener(function(details) {
-  if (details.reason == "install" || details.reason == "update") {
+  if (details.reason == 'install' || details.reason == 'update') {
     cleanUpOptions();
   }
 });
diff --git a/src/console_inject.js b/src/console_inject.js
index c97483b..646beba 100644
--- a/src/console_inject.js
+++ b/src/console_inject.js
@@ -9,35 +9,43 @@
   }
 
   return {
-    "forum": forum_a[1],
-    "thread": thread_a[1]
+    'forum': forum_a[1],
+    'thread': thread_a[1],
   };
 }
 
 function mutationCallback(mutationList, observer) {
   mutationList.forEach((mutation) => {
-    if (mutation.type == "childList") {
-      mutation.addedNodes.forEach(function (node) {
-        if (typeof node.classList !== "undefined") {
-          if (options.thread && node.classList.contains("load-more-bar")) {
-            intersectionObserver.observe(node.querySelector(".load-more-button"));
+    if (mutation.type == 'childList') {
+      mutation.addedNodes.forEach(function(node) {
+        if (typeof node.classList !== 'undefined') {
+          if (options.thread && node.classList.contains('load-more-bar')) {
+            intersectionObserver.observe(
+                node.querySelector('.load-more-button'));
           }
 
-          if (options.threadall && node.classList.contains("load-more-bar")) {
-            intersectionObserver.observe(node.querySelector(".load-all-button"));
+          if (options.threadall && node.classList.contains('load-more-bar')) {
+            intersectionObserver.observe(
+                node.querySelector('.load-all-button'));
           }
 
-          if (options.history && ("parentNode" in node) && node.parentNode !== null && ("tagName" in node.parentNode) && node.parentNode.tagName == "EC-USER") {
-            var nameElement = node.querySelector(".name span");
+          if (options.history && ('parentNode' in node) &&
+              node.parentNode !== null && ('tagName' in node.parentNode) &&
+              node.parentNode.tagName == 'EC-USER') {
+            var nameElement = node.querySelector('.name span');
             if (nameElement !== null) {
               var name = nameElement.innerHTML;
-              var query = encodeURIComponent("(creator:\""+name+"\" | replier:\""+name+"\") -forum:0");
-              var urlpart = encodeURIComponent("query="+query);
-              var link = document.createElement("a");
-              link.setAttribute("href", "https://support.google.com/s/community/search/"+urlpart);
-              link.innerText = chrome.i18n.getMessage("inject_previousposts");
-              node.querySelector(".main-card-content").appendChild(document.createElement("br"));
-              node.querySelector(".main-card-content").appendChild(link);
+              var query = encodeURIComponent(
+                  '(creator:"' + name + '" | replier:"' + name + '") -forum:0');
+              var urlpart = encodeURIComponent('query=' + query);
+              var link = document.createElement('a');
+              link.setAttribute(
+                  'href',
+                  'https://support.google.com/s/community/search/' + urlpart);
+              link.innerText = chrome.i18n.getMessage('inject_previousposts');
+              node.querySelector('.main-card-content')
+                  .appendChild(document.createElement('br'));
+              node.querySelector('.main-card-content').appendChild(link);
             }
           }
         }
@@ -56,40 +64,46 @@
 
 function injectStyles(css) {
   var link = document.createElement('link');
-  link.setAttribute("rel", "stylesheet");
-  link.setAttribute("href", "data:text/css;charset=UTF-8,"+encodeURIComponent(css));
+  link.setAttribute('rel', 'stylesheet');
+  link.setAttribute(
+      'href', 'data:text/css;charset=UTF-8,' + encodeURIComponent(css));
   document.head.appendChild(link);
 }
 
 var observerOptions = {
   childList: true,
   attributes: true,
-  subtree: true
+  subtree: true,
 }
 
-var intersectionOptions = {
-  root: document.querySelector('.scrollable-content'),
-  rootMargin: '0px',
-  threshold: 1.0
-}
+var intersectionOptions =
+    {
+      root: document.querySelector('.scrollable-content'),
+      rootMargin: '0px',
+      threshold: 1.0,
+    }
 
-chrome.storage.sync.get(null, function(items) {
-  options = items;
+    chrome.storage.sync.get(null, function(items) {
+      options = items;
 
-  mutationObserver = new MutationObserver(mutationCallback);
-  mutationObserver.observe(document.querySelector(".scrollable-content"), observerOptions);
+      mutationObserver = new MutationObserver(mutationCallback);
+      mutationObserver.observe(
+          document.querySelector('.scrollable-content'), observerOptions);
 
-  intersectionObserver = new IntersectionObserver(intersectionCallback, intersectionOptions);
+      intersectionObserver =
+          new IntersectionObserver(intersectionCallback, intersectionOptions);
 
-  if (options.fixedtoolbar) {
-    injectStyles("ec-bulk-actions{position: sticky; top: 0; background: white; z-index: 96;}");
-  }
+      if (options.fixedtoolbar) {
+        injectStyles(
+            'ec-bulk-actions{position: sticky; top: 0; background: white; z-index: 96;}');
+      }
 
-  if (options.increasecontrast) {
-    injectStyles(".thread-summary.read{background: #ecedee!important;}");
-  }
+      if (options.increasecontrast) {
+        injectStyles('.thread-summary.read{background: #ecedee!important;}');
+      }
 
-  if (options.stickysidebarheaders) {
-    injectStyles("material-drawer .main-header{background: #fff; position: sticky; top: 0; z-index: 1;}");
-  }
-});
+      if (options.stickysidebarheaders) {
+        injectStyles(
+            'material-drawer .main-header{background: #fff; position: sticky; top: 0; z-index: 1;}');
+      }
+    });
diff --git a/src/console_inject_start.js b/src/console_inject_start.js
index 4b6a7ba..92ad72b 100644
--- a/src/console_inject_start.js
+++ b/src/console_inject_start.js
@@ -1,11 +1,13 @@
 chrome.storage.sync.get(null, function(items) {
   if (items.loaddrafts) {
-    var startup = JSON.parse(document.querySelector("html").getAttribute("data-startup"));
+    var startup =
+        JSON.parse(document.querySelector('html').getAttribute('data-startup'));
 
     if (items.loaddrafts) {
       startup[4][13] = true;
     }
 
-    document.querySelector("html").setAttribute("data-startup", JSON.stringify(startup));
+    document.querySelector('html').setAttribute(
+        'data-startup', JSON.stringify(startup));
   }
 });
diff --git a/src/forum_inject.js b/src/forum_inject.js
index a2209cd..38b56ce 100644
--- a/src/forum_inject.js
+++ b/src/forum_inject.js
@@ -9,13 +9,14 @@
 };
 
 var intersectionOptions = {
-  threshold: 1.0
-}
+  threshold: 1.0,
+};
 
 chrome.storage.sync.get(null, function(items) {
-  var button = document.querySelector(".thread-list-threads__load-more-button");
+  var button = document.querySelector('.thread-list-threads__load-more-button');
   if (items.list && button !== null) {
-    intersectionObserver = new IntersectionObserver(intersectionCallback, intersectionOptions);
+    intersectionObserver =
+        new IntersectionObserver(intersectionCallback, intersectionOptions);
     intersectionObserver.observe(button);
   }
 });
diff --git a/src/options.js b/src/options.js
index 1a321b4..5f965b9 100644
--- a/src/options.js
+++ b/src/options.js
@@ -3,25 +3,25 @@
 }
 
 const defaultOptions = {
-  "list": true,
-  "thread": true,
-  "threadall": false,
-  "fixedtoolbar": false,
-  "redirect": false,
-  "history": false,
-  "loaddrafts": false,
-  "batchduplicate": false,
-  "escalatethreads": false,
-  "movethreads": false,
-  "increasecontrast": false,
-  "stickysidebarheaders": false
+  'list': true,
+  'thread': true,
+  'threadall': false,
+  'fixedtoolbar': false,
+  'redirect': false,
+  'history': false,
+  'loaddrafts': false,
+  'batchduplicate': false,
+  'escalatethreads': false,
+  'movethreads': false,
+  'increasecontrast': false,
+  'stickysidebarheaders': false,
 };
 
 const deprecatedOptions = [
-  "list",
-  "escalatethreads",
-  "movethreads",
-  "batchduplicate"
+  'list',
+  'escalatethreads',
+  'movethreads',
+  'batchduplicate',
 ];
 
 function cleanUpOptions(options) {
@@ -43,9 +43,9 @@
 function save() {
   var options = defaultOptions;
 
-  Object.keys(options).forEach(function (opt) {
+  Object.keys(options).forEach(function(opt) {
     if (deprecatedOptions.includes(opt)) return;
-    options[opt] = document.querySelector("#"+opt).checked || false;
+    options[opt] = document.querySelector('#' + opt).checked || false;
   });
 
   chrome.storage.sync.set(options, function() {
@@ -54,16 +54,21 @@
 }
 
 function i18n() {
-  document.querySelectorAll("[data-i18n]").forEach(el => el.innerHTML = chrome.i18n.getMessage("options_"+el.getAttribute("data-i18n")));
+  document.querySelectorAll('[data-i18n]')
+      .forEach(
+          el => el.innerHTML = chrome.i18n.getMessage(
+              'options_' + el.getAttribute('data-i18n')));
 }
 
 function thread() {
-  if (document.querySelector("#thread").checked && document.querySelector("#threadall").checked) {
-    document.querySelector("#"+(this.id == "thread" ? "threadall" : "thread")).checked = false;
+  if (document.querySelector('#thread').checked &&
+      document.querySelector('#threadall').checked) {
+    document.querySelector('#' + (this.id == 'thread' ? 'threadall' : 'thread'))
+        .checked = false;
   }
 }
 
-window.addEventListener("load", function() {
+window.addEventListener('load', function() {
   i18n();
 
   chrome.storage.sync.get(null, function(items) {
@@ -71,11 +76,13 @@
 
     Object.keys(defaultOptions).forEach(function(opt) {
       if (items[opt] === true && !deprecatedOptions.includes(opt)) {
-        document.querySelector("#"+opt).checked = true;
+        document.querySelector('#' + opt).checked = true;
       }
     });
 
-    ["thread", "threadall"].forEach(el => document.querySelector("#"+el).addEventListener("change", thread));
-    document.querySelector("#save").addEventListener("click", save);
+    ['thread', 'threadall'].forEach(
+        el => document.querySelector('#' + el).addEventListener(
+            'change', thread));
+    document.querySelector('#save').addEventListener('click', save);
   });
 });
diff --git a/src/profile_inject.js b/src/profile_inject.js
index 6cdfc91..a84eba3 100644
--- a/src/profile_inject.js
+++ b/src/profile_inject.js
@@ -1,10 +1,21 @@
 chrome.storage.sync.get(null, function(items) {
-  if (items.history && document.querySelector(".user-profile__user-links") === null) {
-    var nameElement = document.querySelector(".user-profile__user-name");
+  if (items.history &&
+      document.querySelector('.user-profile__user-links') === null) {
+    var nameElement = document.querySelector('.user-profile__user-name');
     if (nameElement !== null) {
       var name = encodeURIComponent(nameElement.innerHTML);
-      var link = document.location.pathname.split("/profile")[0]+"/threads?thread_filter=(creator:%22"+name+"%22+%7C+replier:%22"+name+"%22)";
-      document.querySelector(".user-profile__user-details-container").insertAdjacentHTML('beforeend', '<div class="user-profile__user-links"><div class="user-profile__user-link-title">'+chrome.i18n.getMessage("inject_links")+'</div><ul><li class="user-profile__user-link"><a href="'+link+'" data-stats-id="my-posts-link">'+chrome.i18n.getMessage("inject_previousposts")+'</a></li></ul></div>');
+      var link = document.location.pathname.split('/profile')[0] +
+          '/threads?thread_filter=(creator:%22' + name + '%22+%7C+replier:%22' +
+          name + '%22)';
+      document.querySelector('.user-profile__user-details-container')
+          .insertAdjacentHTML(
+              'beforeend',
+              '<div class="user-profile__user-links"><div class="user-profile__user-link-title">' +
+                  chrome.i18n.getMessage('inject_links') +
+                  '</div><ul><li class="user-profile__user-link"><a href="' +
+                  link + '" data-stats-id="my-posts-link">' +
+                  chrome.i18n.getMessage('inject_previousposts') +
+                  '</a></li></ul></div>');
     }
   }
 });
diff --git a/src/thread_inject.js b/src/thread_inject.js
index c3b484e..b94f405 100644
--- a/src/thread_inject.js
+++ b/src/thread_inject.js
@@ -9,30 +9,30 @@
 };
 
 var intersectionOptions = {
-  threshold: 1.0
-}
+  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")) {
+  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");
+  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");
+        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");
+        document.querySelector('.thread-all-replies__load-all-button');
     if (items.threadall && button !== null) {
       intersectionObserver =
           new IntersectionObserver(intersectionCallback, intersectionOptions);