diff --git a/src/main.js b/src/main.js
index afc1a142..c117a161 100644
--- a/src/main.js
+++ b/src/main.js
@@ -468,6 +468,15 @@ class WebSearchNavigator {
this.register(getOpt('toggleSort'), () =>
this.searchEngine.changeTools(null),
);
+ this.register(getOpt('showImagesLarge'), () =>
+ this.searchEngine.changeImageSize('l'),
+ );
+ this.register(getOpt('showImagesMedium'), () =>
+ this.searchEngine.changeImageSize('e'),
+ );
+ this.register(getOpt('showImagesIcon'), () =>
+ this.searchEngine.changeImageSize('i'),
+ );
}
register(shortcuts, callback, element = document, global = false) {
diff --git a/src/options.js b/src/options.js
index a52f87f0..efd7b1ce 100644
--- a/src/options.js
+++ b/src/options.js
@@ -110,6 +110,9 @@ const DEFAULT_KEYBINDINGS = {
navigateShowYear: ['z y'],
toggleSort: ['z s'],
toggleVerbatimSearch: ['z v'],
+ showImagesLarge: ['z l'],
+ showImagesMedium: ['z e'],
+ showImagesIcon: ['z i'],
};
const DEFAULT_OPTIONS = {
diff --git a/src/options_page.html b/src/options_page.html
index f02bf348..8e8cf4f9 100644
--- a/src/options_page.html
+++ b/src/options_page.html
@@ -136,6 +136,18 @@
Keybindings
+
+
+
+
+
+
+
+
+
+
+
+
Google and Startpage
diff --git a/src/options_page.js b/src/options_page.js
index e17a5f89..e9ac53b7 100644
--- a/src/options_page.js
+++ b/src/options_page.js
@@ -97,6 +97,9 @@ const KEYBINDING_TO_DIV = {
navigateShowYear: 'navigate-show-year',
toggleSort: 'toggle-sort',
toggleVerbatimSearch: 'toggle-verbatim-search',
+ showImagesLarge: 'show-images-large',
+ showImagesMedium: 'show-images-medium',
+ showImagesIcon: 'show-images-icon',
};
/**
diff --git a/src/search_engines.js b/src/search_engines.js
index f4ba8d6e..a01a828d 100644
--- a/src/search_engines.js
+++ b/src/search_engines.js
@@ -461,6 +461,77 @@ class GoogleSearch {
}
return false;
}
+
+ changeImageSize(size) {
+ const sizeOptions = {
+ LARGE: {value: 0, name: 'Large', code: 'l'},
+ MEDIUM: {value: 1, name: 'Medium', code: 'e'},
+ ICON: {value: 2, name: 'Icon', code: 'i'},
+ };
+ const openTool = document.querySelector(
+ '[class="PNyWAd ZXJQ7c"][jsname="I4bIT"]');
+ if (openTool != null) {
+ openTool.click();
+ }
+ const openSizeDropDown = document.querySelector(
+ '[aria-label="Size"]');
+ if (openSizeDropDown != null) {
+ openSizeDropDown.click();
+ }
+ const dropDownWithSize = document.querySelector(
+ '[class="xFo9P r9PaP Fmo8N"][jsname="wLFV5d"]');
+ const getButton = (selector) => {
+ let button;
+ if (document.querySelector(selector) != null) {
+ button = document.querySelector(selector);
+ } else {
+ button = null;
+ }
+ return button;
+ };
+ const setImageSize = (dropDownWithSize, buttonSelector) => {
+ let button = getButton(buttonSelector);
+ if (dropDownWithSize == null && button != null) {
+ button.click();
+ } else if (dropDownWithSize != null && button == null) {
+ dropDownWithSize.click();
+ button = getButton(buttonSelector);
+ button.click();
+ } else if (dropDownWithSize != null && button != null) {
+ button.click();
+ }
+ };
+ switch (size) {
+ case sizeOptions.LARGE.code:
+ if (dropDownWithSize != null &&
+ dropDownWithSize.getAttribute('aria-label') ==
+ sizeOptions.LARGE.name) {
+ } else {
+ setImageSize(dropDownWithSize,
+ '[class="MfLWbb"][aria-label="Large"]');
+ }
+ break;
+ case sizeOptions.MEDIUM.code:
+ if (dropDownWithSize != null &&
+ dropDownWithSize.getAttribute('aria-label') ==
+ sizeOptions.MEDIUM.name) {
+ } else {
+ setImageSize(dropDownWithSize,
+ '[class="MfLWbb"][aria-label="Medium"]');
+ }
+ break;
+ case sizeOptions.ICON.code:
+ if (dropDownWithSize != null &&
+ dropDownWithSize.getAttribute('aria-label') ==
+ sizeOptions.ICON.name) {
+ } else {
+ setImageSize(dropDownWithSize, '[class="MfLWbb"][aria-label="Icon"]');
+ }
+ break;
+ default:
+ break;
+ }
+ }
}
class StartPage {