-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add option for image size #221
Conversation
src/search_engines.js
Outdated
// Expend dropdown and select the size again. | ||
switch (size) { | ||
case 'l': | ||
if (dropDownWithSize.innerHTML == 'Large') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will checking 'Large'
works in other languages?
src/search_engines.js
Outdated
if (dropDownWithSize.innerHTML == 'Large') { | ||
break; | ||
} else { | ||
dropDownWithSize.click(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below you are calling dropDownWithSize.click()
but dropDownWithSize
may be undefined?
@@ -444,6 +444,79 @@ class GoogleSearch { | |||
} | |||
return false; | |||
} | |||
|
|||
changeImageSize(size) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to use as input to the function something more descriptive than 'i', 'l', 'e'
. Javascript doesn't have enums but you can simulate them: https://stackoverflow.com/q/287903/1014208
src/search_engines.js
Outdated
// Expend dropdown and select the size again. | ||
switch (size) { | ||
case 'l': | ||
if (dropDownWithSize.innerHTML == 'Large') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below you are calling dropDownWithSize.innerHTML but dropDownWithSize may be undefined?
src/search_engines.js
Outdated
'[class="MfLWbb"][aria-label="Icon"]'); | ||
const dropDownWithSize = document.querySelector( | ||
'[class="xFo9P r9PaP Fmo8N"][jsname="wLFV5d"]'); | ||
if (large != null && medium != null && icon != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems possible to simplify the two switch statements. Not sure about the best way to do it, but maybe something like:
switch(size) {
case LARGE:
if (dropDownWithSize != null) {
if (dropDownWithSize.innerHTML == 'Large') {
return;
}
if (large == null) {
dropDownWithSize.click();
// large = ...
}
}
if (large != null) {
large.click();
}
// ...
}
Now basically some of the code in the case can be extracted out to a function, say something like:
const setImageSize = (dropDownWithSize, getButton) => {
let button = getButton();
if (dropDownWithSize != null && button == null) {
dropDownWithSize.click();
button = getButton();
}
if (button != null) {
button.click();
}
};
// ...
switch(size) {
case LARGE:
if (dropDownWithSize != null && dropDownWithSize.innerHTML == 'Large') {
return;
}
setImageSize(dropDownWithSize, () => {
// return document...;
});
break;
// ...
}
Merge: pull the latest changes from upstream
@yuanLeeMidori no pressure, but just making sure you know I'm waiting for changes I requested in earlier comments |
@infokiller Hi, thank you for the reminder. Sorry for keeping you wait. If you want, you can close this PR, and I'll send a new one with that meets these requirements once I get time to work on it. Thank you! |
Don't worry, there's no pressure. I just wanted to make sure you're not waiting for me :) |
@infokiller Hi! Sorry for keeping you wait. I've made some changes based on your requests. Please let me know if there is anything I can improve. Thank you so much. |
@yuanLeeMidori thanks a lot for these changes and your contribution! from a quick look it looks good, but I'll want to test it a bit on my computer. I'm a bit busy in the next few days, so I'll probably get to it in a week or so. |
@infokiller No worries! Take your time. Thank you for giving me the chance and help me to improve my code. |
Thanks a lot @yuanLeeMidori it looks great! I just merged it |
@infokiller Thank you for the waiting and reviewing, I'm very grateful. Thank you for giving me the chance :) |
Hi, I add the feature to check different image sizes with keyboard shortcuts. This PR is for solving the issue #91.
While the user switch to the image tab,
z l
change the search result to only large size;z e
change the search result to only medium size; (z m
has been taken by filtering by past month)z i
change the search result to only icon size.Take your time to review my code and please let me know if there is anything I can improve. Thank you!