I am getting a problem with greasemonkey script (jquery) where I cannot get text from japanese (EUC-JP) websites, instead getting weird symbols.
Here is Script and website http://www.geocities.jp/npp_euc_jp/ to test. I tried to search on google but no answers
The issue is not with window.getSelection()
. The issue is with URL encoding. However, this can be fixed by running the string through encodeURI
.
So, in this code, you'd want to replace this line:
var seltext = getSelectedText();
... with this:
var seltext = encodeURI(getSelectedText());
This will then make sure the values getting piped into the attr()
are properly encoded before sent to Google.