allanburleson/duckduckgo-redirect

Add support for Bing searches originating from Visual Studio

Closed this issue ยท 7 comments

In their infinite wisdom, Microsoft chose to not offer search engine selection for IntelliSense compile error codes, e. g. CS0006, but instead hard-code the request as https://bingdev.cloudapp.net/BingUrl.svc/Get?selectedText=Metadata file '[absolute path which might contain sensitive information]' could not be found&mainLanguage=C#&requestId=[a GUID, probably for internal analytics]&errorCode=CS0006

Because of the initially different hostname, the DDG redirector doesn't catch it - my PR #8 aims to mitigate that a bit.

Perhaps, if @allanburleson is willing to guide me, I can further enhance the PR to include the mainLanguage parameter, i. e. insert it at the start of the DDG search query, enabling DDG to search for C# CS0006 instead of only CS0006.

Additionally, this could be even further enhanced by including everything from the selectedText value except the sensitive part between the apostrophes.

In f4b81a5 I added support for multiple parameters. I wish I could figure out a way to intercept the search after it redirects to Bing but before it starts loading. If I add a listener to the event onCommitted it works perfectly, echoing the Bing-interpreted query, but Bing begins to load for a split second before the final redirect occurs. If selectedText is really important, there may still be a nice way to do it (without implementing a special case) that I'm missing.

It might be better for you to just use something like https://github.com/einaregilsson/Redirector. Haven't tried it.

Thanks for f4b81a5, @allanburleson - perfect solution for multiple parameters! ๐Ÿ‘๐Ÿป๐Ÿ‘๐Ÿป

Regarding the selectedText parameter, it's not that important since errorCode, especially when combined with mainLanguage, already helps getting DDG to show relevant results.

However, adding it to the DDG query would improve results, but it would require the not-so-liked special case as the value between the apostrophes (including themselves) must be stripped for privacy purposes.
Maybe implement a "generalized special case" (๐Ÿ˜…), i. e. a general method for stripping certain parts from a source URL & to be used for specific search providers? ๐Ÿค”

@Eagle3386 See 7f83989. I switched APIs to webRequest so the extension can intercept all requests, not just user-initiated ones. Now for VS error searches it redirects after the original search is parsed into a Bing search. If your goal is to prevent phoning home to Microsoft this isn't ideal, but if you're using VS in the first place I assume that isn't a worry.

@allanburleson Thanks for the switch & implementation!

Yes & no regarding Microsoft - I do โค๏ธ C# more than most other languages, but that "phoning home" thing is the first on every piece hard- & software from any manufacturer that I insist on turning it off.
That said, I'd accept to get redirected from Bing to DGG after bingdev.cloudapp.net parsed selectedText's contents, if only your extension would strip off the contents between the apostrophes. Would you mind adding that (back) in, because since you intercept the WebRequest now, it's possible, isn't it?

Sorry for the wait.
In that case I think it makes more sense to just use the errorCode and mainLanguage parameters. I restored that in f31199b. I'm guessing (without having used VS) that selectedText does not always contain a file path like that so it doesn't make sense to account for that very specific case at the risk of affecting others.
I think I can close this now.

Sorry for the wait.

That's not worth mentioning, it's all good. ๐Ÿ˜‰

In that case I think it makes more sense to just use the errorCode and mainLanguage parameters. I restored that in f31199b. I'm guessing (without having used VS) that selectedText does not always contain a file path like that so it doesn't make sense to account for that very specific case at the risk of affecting others.

Being an almost daily VS user, I can assure you, selectedText will always use '-pairs around data I'd like to see removed for privacy reasons - which is why I highly suggest to include that parameter's value, but exclude anything between any '-pair.

I think I can close this now.

I'd love to see the aforementioned changes implemented, but respect if you choose to go a different path anyway.