From d624484254a5eb56f81d743731155919a9804cd8 Mon Sep 17 00:00:00 2001 From: Josh B Date: Mon, 3 Feb 2020 17:56:54 +1000 Subject: [PATCH] Change switch-case indentation --- js/content-script.js | 128 +++++++++++++++++++++---------------------- js/options.js | 24 ++++---- 2 files changed, 76 insertions(+), 76 deletions(-) diff --git a/js/content-script.js b/js/content-script.js index 1f37305..f3ec160 100644 --- a/js/content-script.js +++ b/js/content-script.js @@ -55,20 +55,20 @@ function findImageURL(container, version) { var image = null; switch (version) { - case VERSIONS.FEB18: - image = container.querySelector('img[src]#irc_mi, img[alt^="Image result"][src]:not([src^="https://encrypted-tbn"]).irc_mut, img[src].irc_mi'); - break; - case VERSIONS.JUL19: - var iframe = container.querySelector('iframe.irc_ifr'); - if (!iframe) - return findImageURL(container, VERSIONS.FEB18); - image = iframe.contentDocument.querySelector('img#irc_mi'); - break; - case VERSIONS.OCT19: - image = container.querySelector('img[src].n3VNCb'); - if (image.src in images) { - return images[image.src]; - } + case VERSIONS.FEB18: + image = container.querySelector('img[src]#irc_mi, img[alt^="Image result"][src]:not([src^="https://encrypted-tbn"]).irc_mut, img[src].irc_mi'); + break; + case VERSIONS.JUL19: + var iframe = container.querySelector('iframe.irc_ifr'); + if (!iframe) + return findImageURL(container, VERSIONS.FEB18); + image = iframe.contentDocument.querySelector('img#irc_mi'); + break; + case VERSIONS.OCT19: + image = container.querySelector('img[src].n3VNCb'); + if (image.src in images) { + return images[image.src]; + } } // Override url for images using base64 embeds @@ -119,15 +119,15 @@ function addViewImageButton(container, imageURL, version) { // get the visit buttonm var visitButton; switch (version) { - case VERSIONS.FEB18: - visitButton = container.querySelector('td > a.irc_vpl[href]').parentElement; - break; - case VERSIONS.JUL19: - visitButton = container.querySelector('a.irc_hol[href]'); - break; - case VERSIONS.OCT19: - visitButton = container.querySelector('.ZsbmCf[href]'); - break; + case VERSIONS.FEB18: + visitButton = container.querySelector('td > a.irc_vpl[href]').parentElement; + break; + case VERSIONS.JUL19: + visitButton = container.querySelector('a.irc_hol[href]'); + break; + case VERSIONS.OCT19: + visitButton = container.querySelector('.ZsbmCf[href]'); + break; } // Create the view image button @@ -137,11 +137,11 @@ function addViewImageButton(container, imageURL, version) { // Set the view image button url var viewImageLink; switch (version) { - case VERSIONS.FEB18: - viewImageLink = viewImageButton.querySelector('a'); - break; - default: - viewImageLink = viewImageButton; + case VERSIONS.FEB18: + viewImageLink = viewImageButton.querySelector('a'); + break; + default: + viewImageLink = viewImageButton; } viewImageLink.href = imageURL; @@ -160,15 +160,15 @@ function addViewImageButton(container, imageURL, version) { // Set the view image button text var viewImageButtonText; switch (version) { - case VERSIONS.FEB18: - viewImageButtonText = viewImageButton.querySelector('.Tl8XHc'); - break; - case VERSIONS.JUL19: - viewImageButtonText = viewImageButton.querySelector('.irc_ho'); - break; - case VERSIONS.OCT19: - viewImageButtonText = viewImageButton.querySelector('.pM4Snf'); - break; + case VERSIONS.FEB18: + viewImageButtonText = viewImageButton.querySelector('.Tl8XHc'); + break; + case VERSIONS.JUL19: + viewImageButtonText = viewImageButton.querySelector('.irc_ho'); + break; + case VERSIONS.OCT19: + viewImageButtonText = viewImageButton.querySelector('.pM4Snf'); + break; } @@ -181,15 +181,15 @@ function addViewImageButton(container, imageURL, version) { // Remove globe icon if not wanted if (!options['show-globe-icon']) { switch (version) { - case VERSIONS.FEB18: - viewImageButton.querySelector('.RL3J9c').remove(); - break; - case VERSIONS.JUL19: - viewImageButton.querySelector('.aDEWOd').remove(); - break; - case VERSIONS.OCT19: - viewImageButton.querySelector('.XeEBj.AJkoub').remove(); - break; + case VERSIONS.FEB18: + viewImageButton.querySelector('.RL3J9c').remove(); + break; + case VERSIONS.JUL19: + viewImageButton.querySelector('.aDEWOd').remove(); + break; + case VERSIONS.OCT19: + viewImageButton.querySelector('.XeEBj.AJkoub').remove(); + break; } } @@ -203,15 +203,15 @@ function addSearchImageButton(container, imageURL, version) { var link; switch (version) { - case VERSIONS.FEB18: - link = container.querySelector('.irc_dsh > a.irc_hol'); - break; - case VERSIONS.JUL19: - link = container.querySelector('.irc_ft > a.irc_help'); - break; - case VERSIONS.OCT19: - link = container.querySelector('.PvkmDc'); - break; + case VERSIONS.FEB18: + link = container.querySelector('.irc_dsh > a.irc_hol'); + break; + case VERSIONS.JUL19: + link = container.querySelector('.irc_ft > a.irc_help'); + break; + case VERSIONS.OCT19: + link = container.querySelector('.PvkmDc'); + break; } // Create the search by image button @@ -221,15 +221,15 @@ function addSearchImageButton(container, imageURL, version) { // Set the more sizes button text var searchImageButtonText; switch (version) { - case VERSIONS.FEB18: - searchImageButtonText = container.querySelector('.irc_ho'); - break; - case VERSIONS.JUL19: - searchImageButtonText = searchImageButton.querySelector('span'); - break; - case VERSIONS.OCT19: - searchImageButtonText = searchImageButton; - break; + case VERSIONS.FEB18: + searchImageButtonText = container.querySelector('.irc_ho'); + break; + case VERSIONS.JUL19: + searchImageButtonText = searchImageButton.querySelector('span'); + break; + case VERSIONS.OCT19: + searchImageButtonText = searchImageButton; + break; } if (options['manually-set-button-text']) { diff --git a/js/options.js b/js/options.js index 3f0798f..caf6c99 100644 --- a/js/options.js +++ b/js/options.js @@ -46,12 +46,12 @@ const show = function (options) { var element = document.getElementById(key); if (element) { switch (typeof (options[key])) { - case ('boolean'): - element.checked = options[key]; - break; - case ('string'): - element.value = options[key]; - break; + case ('boolean'): + element.checked = options[key]; + break; + case ('string'): + element.value = options[key]; + break; } } } @@ -78,12 +78,12 @@ chrome.storage.sync.get('defaultOptions', function (storage) { // On change, save document.addEventListener('change', event => { switch (event.target.type) { - case ('checkbox'): - options[event.target.id] = event.target.checked; - break; - case ('text'): - options[event.target.id] = event.target.value; - break; + case ('checkbox'): + options[event.target.id] = event.target.checked; + break; + case ('text'): + options[event.target.id] = event.target.value; + break; } save(options);