Skip to content
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

Use search box value for extension features #607

Merged
merged 12 commits into from
Jul 15, 2020
Merged

Use search box value for extension features #607

merged 12 commits into from
Jul 15, 2020

Conversation

tikhsuP
Copy link
Collaborator

@tikhsuP tikhsuP commented Jul 9, 2020

  • When the Search Box isn't empty, use that domain as the URL to act on instead of the web browser's address bar.

  • Also Hide the WB Count and Archived Resources ('R' icon and blue buttons), if these exist.

@tikhsuP tikhsuP linked an issue Jul 9, 2020 that may be closed by this pull request
6 tasks
Copy link
Collaborator

@anishsarangi anishsarangi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go !!

@tikhsuP tikhsuP marked this pull request as draft July 9, 2020 18:53

function homepage() {
openByWindowSetting('https://web.archive.org/')
}

function save_now() {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
let url = tabs[0].url
let url = searchValue.length >= 3 ? searchValue : tabs[0].url
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'3' could be a const assigned at the start of the file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a way to make it work without using it.
Thank you!

@tikhsuP tikhsuP marked this pull request as ready for review July 10, 2020 12:28
}
}

function useSearchBoxValue() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better if you can make this work by passing searchValue in to the function, rather than referencing it as a global. I think you can also change the code to avoid the recursive call to useSearchBoxValue() by moving the call to makeValidURL() to the front of the function (which should also return the valid URL instead of modifying a global.)

Copy link
Collaborator Author

@tikhsuP tikhsuP Jul 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I misinterpreted the line above and moved the call to useSearchBoxValue() to makeValidURL().

Now I have moved the call to makeValidURL() to the desired place.

Copy link
Collaborator

@anishsarangi anishsarangi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good improvements !

@tikhsuP
Copy link
Collaborator Author

tikhsuP commented Jul 13, 2020

I resolved the conflicts and added get_clean_url() for search box value (searchValue). Thank you!

@cgorringe cgorringe mentioned this pull request Jul 14, 2020
6 tasks
@tikhsuP tikhsuP marked this pull request as draft July 14, 2020 19:19
@@ -176,7 +176,7 @@ function remove_wbm(url) {

// Function to clean the URL if the user is on 'web.archive.org'
function get_clean_url(url) {
if (url.includes('web.archive.org')) {
if (url && url.includes('web.archive.org')) {
Copy link
Collaborator Author

@tikhsuP tikhsuP Jul 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding url && to the if-condition statement. I tried get_clean_url(makeValidURL(event.target.innerHTML)) earlier but was getting Cannot read property 'includes' of null, in case when null was returned :-)

@tikhsuP tikhsuP marked this pull request as ready for review July 15, 2020 03:55
@tikhsuP tikhsuP merged commit b3223d6 into master Jul 15, 2020
@tikhsuP tikhsuP deleted the search-box-url branch July 15, 2020 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI/UX Suggested Improvements
3 participants