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

💡Smart-Highlight💡: Highlight keywords from top.document.URL #11

Open
dnknn opened this issue Apr 14, 2022 · 0 comments
Open

💡Smart-Highlight💡: Highlight keywords from top.document.URL #11

dnknn opened this issue Apr 14, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@dnknn
Copy link

dnknn commented Apr 14, 2022

PLEASE NOTE: This will be a brand new feature, different from the current highlighting logic.

  • Have you ever thought of such a scene where keywords are automatically highlighted?:
    Users do not need to set specific keywords.
    Instead, it extracts URL-specific matching rules as highlighted keywords.
    Please see this screenshot demo

Obviously, this is also a very practical scenario requirement!!! And it's easy to do 🙂😁❗❣

📝 Implementation plan/draft:

  • Added a new option to the current UI interface: match keywords on URLs.
    1️⃣ add UI: ⬜/✅ URL-keyword matcher ( title='tooltip: Extract keywords from URL' )
    2️⃣ The user fills in the keyword/regular to match the URL
    3️⃣ In other words, the logic at this time will extract the rule from the URL to become the keyword of the current logic.
    4️⃣ Below is a simple code demonstration:
For example:
https://community.bitwarden.com/search?q=password

Then we want to automatically highlight the keyword rules after search?q= on the domain URL, That is, we want to automatically highlight the keyword password from the URL.

	const _URL_ = decodeURIComponent(top.location.href); // top.document.URL
	const URL_Keyword = _URL_.match(`q=(.+)`)?.[1];
// or 👇
	const URL_Keyword = _URL_.split(`q=`)[1];
// or 👇
	const URL_Keyword = _URL_.replace(/.+search\?q=(.+)/i ,`$1`);

if (URL_Keyword )	{
	Keywords for the current version = URL_Keyword; // 😁
}

At this point, we can all get the keyword of the password rule on the URL.
That is to say, extract a fixed string of URL or a non-fixed string of regular rules to automatically generate a keyword.
Finally, according to the current logic to highlight the keyword password


Of course, the above is the extraction of URL keywords at the code level,
Instead of extracting URL rules from the user UI, I think it should be a regular find/replace method.

  • what page to apply to ?
    It is still the current version, exactly the same. Then the difference is: ↴

When the user click 👇 to Check/Enable, 2 input boxes will appear:

  • URL-keyword matcher
    Find : fill in .+search\?q=(.+)
    replace : fill in $1

The resulting $1 will be highlighted as a keyword similar to the current version.

// DOM demo
	const Find_str = document.getElementById(`find`).value;
	const replace_str = document.getElementById(`replace`).value;
	const URL_Keyword = _URL_.replace(Find_str, replace_str);

In short, there should be many ways to easily implement it, and the above are all examples/demo purposes. I think you should be able to understand this function.

There are many search result pages of websites that list a lot of irrelevant items. If there is this function, it can automatically highlight the precise keywords carried by the URL.
So, I think this new feature will be very useful and hope to be adopted.
Because it is easy to implement, it is only necessary to add a logic to obtain keywords from URLs in the current version.

@dnknn dnknn added the enhancement New feature or request label Apr 14, 2022
@dnknn dnknn changed the title 💡: Highlight the keywords of the URL in the address bar 💡: Highlight keywords from the URL in the address bar. Apr 14, 2022
@dnknn dnknn changed the title 💡: Highlight keywords from the URL in the address bar. 💡Smart-Highlight💡: Highlight keywords from top.document.URL Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant