-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
Conversation
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.
Good to go !!
webextension/scripts/popup.js
Outdated
|
||
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 |
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.
'3' could be a const assigned at the start of the file.
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 found a way to make it work without using it.
Thank you!
webextension/scripts/popup.js
Outdated
} | ||
} | ||
|
||
function useSearchBoxValue() { |
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.
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.)
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.
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.
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.
Good improvements !
I resolved the conflicts and added |
@@ -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')) { |
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.
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 :-)
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.