ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE. Software > FARR Plugins and Aliases

FarSubScript : GoogleSearch


I needed a way to do money/unit conversions in FARR and since I usually use Google Search for that i thought I'd make a script to call GoogleSearch inside FARR.

Here's the script
--- Code: Javascript ---plugins["GoogleSearch"] ={        version: "1.0",        lastChange: new Date(fso.GetFile(currentDirectory+"\\fsubscript.js").DateLastModified).toDateString(),        displayName: "GoogleSearch",        directory: currentDirectory,        icon: currentDirectory + "\\favicon.ico",        aliasstr: "gs",        description: "Search using Google (usefull for online conversions)"}; (function (){        var js = plugins["GoogleSearch"];        var loaded = false;        var match = false;        var match2 = false;        var loadurl = ""; = function search(querykey, explicit, queryraw, querynokeyword,modifierstring,triggermethod)        {                if(!explicit) return;                 idletime = 0;                // first : match when a space is at the end of the string                match = queryraw.match(new RegExp("^"+js.aliasstr+" (.+)  $"));                // second : match when the user presses enter                match2= queryraw.match(new RegExp("^"+js.aliasstr+" (.+)$"));                 if((match && match[1])||                  (triggermethod && match2 && match2[1]))                {                        loaded = true;                        // formated HTML must be like this :                        // string                        // Example :$ in euro                        if (match)                                loadurl = ""+match[1];                        else if (match2)                                loadurl = ""+match2[1];                        else                                loadurl = "";                        htmlViewURL(loadurl);                        showPleaseWait("Loading..");                }                else                {                        showHTML("<b>GoogleSearch</b>\                                <br>Search using the power of the Google Search service\                                <br><br>\                                <br>Syntax : <b>"+js.aliasstr+" search string</b>\                                <br>(either press ENTER or twice SPACE at the end of the search string)\                                <br><br>You can use the special search options of google\                                <br><br>Example: <b><br>"+js.aliasstr+" 10$ in euro</b>\                                <br>this will show you how much 10$ are in euros\                                <br><br>\                                <br>For a complete set of supported values look at\                                <br><a href=></a>\                        ");                }        };        js.setStrValue = function onSetStrValue(varname,value)        {                if(varname == "EmbeddedWb.DocumentComplete")                {                        var pl = pluginInCharge();                        if(pl == "GoogleSearch" && loaded)                        {                                loaded = false;                                // hide the "Chrome browser" advertisment                                execSafeJS("\//                                      document.getElementById('gt-bbar').style.display='none';\n\                                ");                                hidePleaseWait();                        }                }        }}());

Usage :
gs search string<space><space>
gs search string<enter>

Note : since i usually search for things that contains spaces i made the script to autosearch only when i enter 2 consecutive spaces (otherwise when entering "10$ in euro" it would autosearch after the 10$ and also after in)

There are still some bugs in it, the most notable ones are :
- cannot open the search results in the browser that you set in FARR (the alternate browser setting), the workaround is to copy the link's address and paste it in FARR and press enter (that will open the browser)

Note : this script requires FarSubScript, make sure you have it installed and working in FARR.

Install :
extract the content of the archive into a subfolder under the Scripts folder of FARR (for example : plugins\GoogleSearch) and either write "goreload" in FARR (this will reload all plugins) or restart FARR.

If anybody wants to improve the script feel free to do so.

Thanks for sharing this!!  :Thmbsup:


[0] Message Index

Go to full version