Help on simple (?) script idea for Google search without HTTPS

in Script development
Subscribe to Help on simple (?) script idea for Google search without HTTPS 8 posts, 3 voices



PJones User
FirefoxWindows

How do I set-up a script that will disable HTTPS in Google searches?

There are two forms of "secure search" that Google uses, "SSL Search" (https://google.com) and the newer "Encrypted Search" (https://encrypted.google.com). Google now forces "Encrypted Search" redirects for all searches if you are signed-in to Gmail or other Google service. The new Firefox 14 also forces HTTPS for Google searches in the address bar and the search bar, whether you are signed-in or not.

It could be something as simple as just examining every Google search string URL the browser sends out and replacing instances of "HTTPS" with "HTTP," and replace instances of "https://encrypted.google.com" with "http://www.google.com" -- right? It would be nice if it could tell the difference between a manually-typed address vs one that was sent automatically from evoking the search box or other process, that way it would NOT modify URLs that were typed in by the user. (But that is a refinement; I am interested really in how to set-up the basic script to alter forced HTTPS Google searches to normal HTTP ones. I can always enable/disable the script from the Scriptish menu icon in the status bar as needed.)

"Why?"
I need to disable this feature on occasion, as it makes my satellite ISP EXTREMELY slow. (I live in a rural area where satellite or dial-up are the only ISP options.) Every Google search now takes *minutes* instead of the usual couple of *seconds* and, in any event, causes the search request to time-out 80% of the time for me! Unacceptable. Any in-depth research takes 10 times longer for me than it used to. Also, just speaking personally, I'm not concerned about my search terms being intercepted by a 3rd party (Google freely gives your search terms out to their advertisers anyway) and would appreciate the OPTION of secure search, the way "incognito mode" is an option instead of a requirement. I realize that for most people secure search is a very welcome feature. But it is often unworkable for some of us living outside the (current) periphery of broadband coverage.

I am using Scriptish 0.1.7 with Firefox 14 (Win7).

Sorry for the noobie questions!

 
mike cupcake Scriptwright
FirefoxWindows

A quick search brings up this script to force HTTPS on Google:
http://userscripts.org/scripts/review/85813

maybe switchng the code around to force HTTP instead would work for you?

 
PJones User
FirefoxWindows

Thanks for that!

I modified the script you linked to, just switched the terms to be replaced and included the https versions of the google URLs in the commented section at the top.

This appears to work, though in an odd and roundabout way. Firefox will first load a search using https://www.google.com, but then, right as the SSL page is finishing loading, the script kicks in and changes the URL to http://www.google.com and reloads the page without SSL. I guess that means the script is successfully replacing the URL, but too late to matter, since it takes so long to load the SSL page before it reloads the non-SSL version.

Is there another "place" besides location.href to look for and replace the "HTTPS" in the string that is being sent out? Or is there a way to intercept and alter the URL before the browser sends it out?

Thanks!

 
mike cupcake Scriptwright
FirefoxMacintosh

Ah yes, Greasemonkey scripts by default will run once the page is loaded. You can put @run-at document-start in the metadata block to change this.
http://wiki.greasespot.net/Metadata_Block#.40ru...

Alternatively, Firefox's search keywords may help you out - for instance I changed the default g keyword to search google.co.uk instead of .com. With this you should be able to make Firefox load a HTTP URL in the first place:
http://kb.mozillazine.org/Using_keyword_searches

 
PJones User
FirefoxWindows

Thanks again! I added @run-at document-start to the metadata block, and this causes the re-loading to happen faster, but it doesn't stop Firefox from trying to pull up https://google.com at first (and taking it's time getting there over SSL), either from the search box or the location bar.

Is there a setting to make the script always active, regardless of the current page? Can add @include *.* or something similar? Then I only need to make the replacement more specific than just replacing all HTTPS with HTTP, since I only want this for Google searches.

The current code is location.href = location.href.replace(/https\:/, 'http:');

But that will get every domain if the script is always active. How about this?
location.href = location.href.replace(/https\:\/\/([A-Za-z0-9\-\.]+\.)?google\.[\w-.]+/i, /http\:\/\/$1google.com$')

Can I use a regexp as the replacement (as above), or does that have to be text? Like 'http://www.google.com' instead?

 
mike cupcake Scriptwright
FirefoxMacintosh

Aha, no you can't make it happen any faster with a userscript then. Making Firefox load HTTP in the first place is the way to go, are the search keywords any help? Or look into the 'manage search engines' config on the search box?

 
Jefferson Scher Scriptwright
FirefoxWindows

Seems easier to search logged out, unless you really want to track your history, and hack the address bar search preference in Firefox 14 if you prefer to search from the address bar.

 
PJones User
FirefoxWindows

Thanks for all the input, I really appreciate it!

Turns out that it's much simpler to edit the Google search plug-in that comes with Firefox. When using the search box or location bar, FF sends on the URLs listed in the search plug-in file before a user script can load, even with the @run-at document-start param set.

It is located in [%ProgramFiles%|%ProgramFiles(x86)%]\Mozilla Firefox\searchplugins\google.xml. I simply edited all the instances of "https:" to "http:" (there were only five) and saved the file. Then I went to Tools > Options > Advanced Tab > Update Tab > and unchecked "Automatically Update: Search Engines" at the bottom.

For Firefox users, this is also an easy way to enable SSL Google searches by default if using a version prior to 14. FF also comes with search plug-ins for Amazon, Bing, eBay, Twitter, Wikipedia, and Yahoo in the same directory, so one could edit the default URLs for those engines as well.