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/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;}');
+ }
+ });