Friday, January 4, 2013 6:16:12 AM
Under [Hotclick Popup Menu], [Link Selection Popup Menu],
[Edit Widget Popup Menu], you can add this code to have
a 'search Google in new page' option in the right click menu
(if you don't want to use modifier keys for that: Ctrl +Shift)
This is the usual code:
Item, Search in New Tab=Copy & New Page & Go to page, "http://www.google.com/search?q=%c&num=%i&sourceid=opera" & Minimize page
The problem is that non-standard characters in the search query are not preserved (e.g. ą,ę,ż,ü)
This JavaScript code can be used to go around the problem (it simulates Ctrl + Shift + click).
Search Google.pl in a new background tab with support for international characters
Item, Search Google.pl="Enable javascript, , , ,"Search Web" & Delay, 10 & Go to page,"javascript:(function(){var sel=window.getSelection().getRangeAt(0);var url= 'http://www.google.pl/search?num=50&hl=pl&lr=lang_pl&as_qdr=all&tbs=lr%3Alang_1pl&q='+ encodeURI(sel) +'&btnG=Szukaj'; var a = document.createElement('a');a.href = url;var evt = document.createEvent('MouseEvents'); evt.initMouseEvent('click', true, true, window,0, 0, 0, 0, 0,true, false, true, false, 0, null);a.dispatchEvent(evt);})()"
Search Google News in a new background tab with support for international characters
Item, Search Google News="Enable javascript, , , ,"Search Web" & Delay, 10 & Go to page,"javascript:(function(){var sel=window.getSelection().getRangeAt(0);var url= 'http://www.google.com/search?hl=en&gl=us&tbm=nws&q='+encodeURI(sel); var a = document.createElement('a');a.href = url;var evt = document.createEvent('MouseEvents'); evt.initMouseEvent('click', true, true, window,0, 0, 0, 0, 0,true, false, true, false, 0, null);a.dispatchEvent(evt);})()"
Another way to use the code is to make a User JS with different searches as functions and call them in the context menu.
User JS:
Search_Google= function(){ var sel=window.getSelection().getRangeAt(0); var url='http://www.google.com/search?q='+ encodeURI(sel) +'&num=%i'; var a = document.createElement("a"); a.href = url; var evt = document.createEvent("MouseEvents"); evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, true, false, //ctrlKey, altKey, shiftKey, metaKey 0, null); a.dispatchEvent(evt); } Search_Google_pl=function(){ var sel=window.getSelection().getRangeAt(0); var url= 'http://www.google.pl/search?num=50&hl=pl&lr=lang_pl&as_qdr=all&tbs=lr%3Alang_1pl&q='+ encodeURI(sel) +'&btnG=Szukaj'; var a = document.createElement("a"); a.href = url; var evt = document.createEvent("MouseEvents"); evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, true, false, 0, null); a.dispatchEvent(evt); } Search_News=function(){ var sel=window.getSelection().getRangeAt(0); var url='http://www.google.com/search?hl=en&gl=us&tbm=nws&q='+encodeURI(sel) ; var a = document.createElement("a"); a.href = url; var evt = document.createEvent("MouseEvents"); evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, true, false, 0, null); a.dispatchEvent(evt); } Search_YouTube=function(){ var sel=window.getSelection().getRangeAt(0); var url= 'http://www.youtube.com/results?search_query=' + encodeURI(sel) ; 'http://www.youtube.com/results?search_type=&search_query=%s&aq=f' var a = document.createElement("a"); a.href = url; var evt = document.createEvent("MouseEvents"); evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, true, false, 0, null); a.dispatchEvent(evt); } Search_DailyMotion=function(){ var sel=window.getSelection().getRangeAt(0); var url= 'http://www.dailymotion.com/us/search/' + encodeURI(sel) //+'/1?af=1' //this part for most recent search var a = document.createElement("a"); a.href = url; var evt = document.createEvent("MouseEvents"); evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, true, false, 0, null); a.dispatchEvent(evt); }
Functions called in context menu:
Item, Search in New Tab="Go to page,"javascript:Search_Google()" , , ,"Search Web"" or Item, Search in New Tab=Enable javascript, , , ,"Search Web" & Delay, 10 & Go to page,"javascript:Search_Google()" Item, Search Google.pl=Enable javascript, , , ,"Search Web" & Delay, 10 & Go to page,"javascript:Search_Google_pl()" Item, Search News=Enable javascript, , , ,"Search Web" & Delay, 10 & Go to page,"javascript:Search_News()" Item, Search YouTube=Enable javascript, , , ,"Search Web" & Delay, 10 & Go to page,"javascript:Search_YouTube()" Item, Search DailyMotion=Enable javascript, , , ,"Search Web" & Delay, 10 & Go to page,"javascript:DailyMotion()"
No comments:
Post a Comment