Greasy Fork is available in English.

Обсуждения » Хотелки

Google Search syntax replacement

Deleted user 128
§
Создано:
Отредактировано:
Google Search syntax replacement

Hi,

I'm searching for a script which would replace #q= with search?q= when performing a Google Search from https://encrypted.google.com, that is from the home page.

Example : at this time I have a Google Encrypted search syntax made available when performing Google Search from Firefox's search bar which will handle "manhattan" to bring me to Google with :
https://encrypted.google.com/search?q=manhattan

Now, if I search for "manhattan" from Google's home page https://encrypted.google.com, the search leads to :
https://encrypted.google.com/#q=manhattan

Not a problem as such, except that I use an autopagerize add-on called AutoPagerizeTweaked which doesn't handle #q= correctly but seems to be expecting search?q=

So, I'd really appreciate it if you could get me the few lines which would replace #q= with search?q= when result is https://encrypted.google.com/#q=

I have two barriers : not being a coder and English not being my mother-tongue-- Thanks
Hello AnchorsAweigh,
I'd be curious to know why this happens to you and I can't live-test your issue as in all cases g00g will auto-redirect me to an URL containing the search?q= in it.

So maybe a simple redirect might solve your problem:
// ==UserScript==
// @name           Search # replace
// @description    Replace fragment identifier with standart search requester.
// @namespace      Search_#_replace
// @version        0.1 - 21.03.2016
// @author          Vivre
// @include        https://encrypted.google.com/*
// @grant       none
// ==/UserScript==


if (location.href.match(/encrypted\.google\.com\/#q/)) {

	location.href = location.href.replace(/com\/#q/, 'com/search?q');

}; 

// end
Note: you could use this 3-liner-snippet in any script that runs on any page @include * if you'd like to add it manually to an existing script.
If you install this mini-script on it's own you might want to alter the @header-values to your own taste before installation. Tip: the @name is what later shows up in your Greasemonkey menu.

good luck ~ Vivre
Deleted user 128
§
Создано:
Hello Vivre and thanks for your help!

1- Your code runs fine (of course!) - Nevertheless I have to reload the page due to the way Google operates its "immediate" results (no G cookie hence no settings).

2- As I mentioned above, the Google (Encrypted) search engine for Firefox delivers a https://encrypted.google.com/search?q=[SEARCH] but when I perform the search from either www.google.fr (google.com redirects to google.fr as we know and France is here, everywhere .... :) I mean I'm in France!) either from encrypted.google.com, the results page opens with https://encrypted.google.com/#q=[SEARCH]

You mention, Vivre, that you never experience this, but I don't either when/if I've set Google Search parameters to NOT show search results as I type (When should we show you results as you type? -> Never show instant results). Since I no longer keep Google cookies (not blocked but erased after closing a Google page with a Firefox add-on called 'Self-Destructing Cookies') Google operates on its default option to show results as I type... this seems to be the culprit, I'm speaking from plain experience since I lack the theories (autodidact's misery!).

Finally, all this is because
I don't keep G cookies => default 10 results per page
AND I wish infinite scrolling, hence AutoPagerizeTweaked Firefox add-on
AND this add-on doesn't handle #q= as well as search?q (sometimes it does after page reload, sometimes not, does code have its mood?!)

So, Vivre : thanks again. I'm learning the hard way and I appreciate 1- your concern and 2- your code which works : Double ACE :)
§
Создано:
Отредактировано:
Hi AnchorsAweigh ~ you're very well~come :smile:

Me too - I don't keep cookies and don't use g00g if I don't have to and prefer to search via startpage.com who allow to create a bookmark containing your favored preferences. This way I can get 100 results on each page straight away.

Still I love helping to overcome annoyances from g00g :wink:

Ok - I'm not sure about how you arrive at encrypted.google.com when you started the search in www.google.anywhere - I couldn't find a link or setting that would redirect me to encrypted.google. But that might not be so important at the moment.

Also I don't get these pushed "immediate" results at all, likely because my browser is too old - or it's a feature for windows only (I can't tell).
But I found two smaller scripts on both search-start-pages that might be responsible for a) fiddeling around with the search-parameter and b) checking some http-request-modalities(*).

I've enhanced my script to remove these two inner scripts. Please have a try if it makes a difference for you:
// ==UserScript==
// @name           Search # replace
// @description    Replace fragment identifier with standart search requester.
// @namespace      Search_#_replace
// @version        0.2 - 21.03.2016
// @author          Vivre
// @include        https://encrypted.google.com/*
// @grant       none
// ==/UserScript==


if (location.href.match(/encrypted\.google\.com\/#q/)) {

	location.href = location.href.replace(/com\/#q/, 'com/search?q');

}; 


var scripty;
scripty = document.getElementsByTagName('script');
	if (!scripty) { return; }

	for (var i = 0; i < scripty.length; i++) {
		if  (scripty[i].innerHTML.match("window.google.vel") || scripty[i].innerHTML.match("typeof XMLHttpRequest") ) {  
	//	alert(scripty[i].innerHTML)
		scripty[i].innerHTML = "rien ne vas plus :-P"
		}
	}


// end
Note: at the moment this script will only apply to encrypted.google.com. If it works out we'll adjust the @include later on.


(*)I have the impression that these "immediate" results only occure on the empty initial search-start-page and not when there are already final results. Is that right?

In that case you could try to use an alterativ start on the whole. My suggestion would be to add two bookmarks that open these search-pages with a given search-term so that you're already on a result-page with the correct URL-setting: eg: https://www.google.com/search?q=what and https://encrypted.google.com/search?q=what .

Oh - and before I forget ~ yes codes do have their moods ... and especially when they are working asynchon - each on its own time :mrgreen:

greets from everywhere.de
Deleted user 128
§
Создано:
Отредактировано:
Good morning, Vivre,

I've tested your second script 'Search # replace' 0.2 - 21.03.2016 but it doesn't change anything compared to version 0.1 : #q= is correctly modified to search?q= but only after reloading the page.

As always, result page is https://encrypted.google.com/#q=[SEARCH] if I search from my Google Encrypted Firefox installed search engine BUT https://encrypted.google.com/#q=[SEARCH] if I search from https://encrypted.google.com/ page.

Three points here :

1- How do I arrive at encrypted.google.com when I started the search in www.google.anywhere ?
Misunderstanding. Search from www.google.anywhere opens results in www.google.anywhere and encrypted.google.com only opens results in encrypted.google.com, but in all situations a search performed from a Google Search homepage (www.google.anywhere or encrypted.google.com) will open the Results page as I type my query WITH 'instant results' = ON (default) to https://*.google.*/#q=[SEARCH] but not if I search with https://encrypted.google.com/search?q=[SEARCH] or https://www.google.[anywhere]/search?q=[SEARCH] ...

One can test directly from the urlbar :
(a) https://encrypted.google.com/search?q=TEST
(b) https://encrypted.google.com/#q=TEST

Both work, be it encrypted.google or www.google : in fact, encrypted. or www. is secondary. The point is the query's syntax.
My search from Firefox Google Encrypted performs (a) but the search from Google itself performs (b)

2- You couldn't find a link or setting that would redirect me to encrypted.google
I found mine among those proposed for Firefox at http://mycroftproject.com/search-engines.html?name=google+encrypted
I cannot remember which of the engines provided I had added to my own Firefox search engines list but here I must bring this precision :
The engine I had chosen had as search syntax (b) and not (a) and I remember having edited this to have the (a) syntax, for the very same reason motivating this post here! BTW editing a Firefox's search engine is no longer possible starting Firefox 45 ...

3- You have the impression that these "immediate" results only occur on the empty initial search-start-page and not when there are already final results. Is that right? do you ask.

3.1- If I'm on a Google Search result page with https://encrypted.google.com/search?q=TEST and then search for 'fortune' from Google's searchbar on that page :
With your script I get : https://encrypted.google.com/search?q=TEST#q=fortune
Without your script I get : https://encrypted.google.com/search?q=TEST#q=fortune

3.2- If I'm on a Google Search result page with https://encrypted.google.com/#q=TEST and then search for 'fortune' from Google's searchbar on that page :
With your script I get : https://encrypted.google.com/search?q=TEST#q=fortune
Without your script I get : https://encrypted.google.com/#q=fortune

Odd isn't it? Complicated.
Vivre, your script is fine (be it version 0.1 or 0.2) and digging for more is not in my intentions (I'll never be trully rich!) so above is for your information and relates my own experience with Firefox 45.0.1 64-BIT on Windows 7SP1 64-BIT
If you wish to investigate further on I'll be happy to provide any required related information but this is of your concern only. As far as i'm concerned I'm slipping (if I ever never had) with all this. Thanks again :)

P.S. : Guten Tag Deutschland, Guten Tag everywher.de, "Homepage leicht gemacht'!
Bon soir AnchorsAweigh,

Thanks for your in-depth response :smile: ~ it's a rare find on the internet and much apreciated.
Also the link to the search-engine list was interesting to review and nice to have for thr future.

Now today I again tried to figure out various hacks to get an effectiv influence on the search-input to change the current behaviour. ... I had several good laughs, learned a bit more on jasascript ... but had to give it up at a certain point, because I can't test it under similar conditions to yours.

I also thought about to maybe replace that search-input field by an independent one. But before taking such a step I returned to one of my first ideas regading settings and search-parameters. If these search-engines can turn of that instant search it must be available somehow.

Yeah - I found something

It is still possible to apply your own settings to the URL directly and one of the parameter turns off that instant search behavior: complete=0
Here are some links for you to test:

A-1 - https://encrypted.google.com/search?safe=off&biw=1&bih=1&pws=0&hl=en&complete=0&npfr=1&nirf=1&newwindow=1
A-2 - https://www.google.com/search?safe=off&biw=1&bih=1&pws=0&hl=en&complete=0&npfr=1&nirf=1&newwindow=1

B-1 - https://encrypted.google.com/search?complete=0
B-2 - https://www.google.com/search?complete=0

Note: it's not even nessccary to have a search-term in these links and there is no need to have multiple parameters, if it is only for the one setting to disable that instant feature.
Still - the collection of various parameters prevents g00g from applying their unreadable long preference numberings.

I had found two scripts that deal with the parameters and there you can have a look which ones exist for to 'bake' your own URL.

Google Clean Links - http://userscripts-mirror.org/scripts/review/177454
Google Search Better Privacy - https://greasyfork.org/scripts/1146/code

If these links work out for you, you could use them as bookmarks or we'll redesign the little script in a way that you'd be auto-redirected to your favored URLs in case you'd arrive at encrypted.google or google.anywhere.

Oh my ~ what a searching-excursion

Meilleurs souvenirs ~ Vivre
Deleted user 128
§
Создано:
Отредактировано:
Bonsoir Vivre (better than Sagan's "Bonjour tristesse"!),

First, many thanks for your commitment, beyond only scripting help.

I've been working on my issue as well and arrived in the same neighborhoods as you : disabling Google's instant feature via complete=0 together with several other parameters.

Sometimes the working scheme can be a problematic built upon a basis which later on appears to have been misleading. This allows the development of the encountered problems tied to that basis, the problems may be true though the basis wrong. I'm afraid this is what happened to me.

Basis 1 - Google Search may be called by either /search?q=[SEARCH] or by /#q=TEST[SEARCH] : true
Basis 2 - The add-on AutoPagerizeTweaked required (worked better with) /search?q=[SEARCH] ... : FALSE

What I mean, Vivre, is that i'm afraid I've encountered a real problem but that I've assumed a wrong cause.

Google can indeed be called by two "syntaxes" but that itself is a problem for no one.
On another hand ... I've realized that
- my add-on did run fine with /#q=TEST[SEARCH]
- the true problem for the add-on (infinite scrolling) is when the page has been called from encrypted.google or google.com and not from elsewhere. Why? It's all in an inline script Google runs when the query is performed from it's home page. I've tested by disabling that inline script (via another add-on called uBlock Origin) and AutoPagerizeTweaked scrolled the result page normally (infinite).

In fact it appears that I've started a storm in a glass of water. My purpose was to have /search?q=[SEARCH] replace /#q=[SEARCH] BECAUSE OF A WRONG REASON (mea culpa!) -> this post -> your very kind and wise commitment to finding a way to operate this replacement ...when in fact there is no need.

I admit feeling embarrassed comes in right after feeling sorry to have taken on your time. Sometimes situations get into tunneling leading to assuming wrongly the cause : that's what happened to me.

From there on I returned to http://mycroftproject.com/search-engines.html?name=google+encrypted and installed the original version of the one I had edited in order to get Google search via /search?q=[SEARCH] : Google Encrypted (encrypted.google.com) by Dark_Ronius.

Google Search from Firefox search list is called as https://encrypted.google.com/#q=[Search] : AutoPagerizeTweaked is OK
Google Search from Google homepage is called as https://encrypted.google.com/#q=[Search] : AutoPagerizeTweaked is NOT OK until I reload the page - Reload the page works instantly if cookies blocked for Google, otherwise requires erasing Google.com cookie => I've blocked cookies permission for google.com

Now : some may wonder, why such a fuss when it is so easier to allow cookie for google.com, make it a permanent cookie and fill it with 'no instant' and 100 results per page (>10 means no instant anyway) ?

The answer is : I agree and I'd do it, I did it that way and if I've abandoned that idea it is less for privacy reasons than because of this :
to have Google search keep my settings I must allow permanent cookie for google.com even when searching with encrypted.google.com (encrypted.google.com only cookie is not enough, Google wants google.com). But because I need Google cookie only for my search settings I don't want google.com for other Google services (docs.google.com, sites.google.com, support.google.com etc.) therefor I have to explicitly block cookie permissions for all other Google services putting their cookie which is kept since google.com is authorized ... OUF!

Did you manage to read all of my literature without a coffee break, Vivre?!
Thanks again. If my problem had remained then your solution, both script and latest urls would have been perfectly adequate.

"Vivre" by the way is a very nice pseudonym. I first thought you were French (you could be though you mentioned Germany but you've made a slight mistake with "Bon soir" when it's in one word in French unless it is intentionally poetically oriented, which remains possible as well!).

Vielen Danke, Vivre! merci à vous, thanks again, and maybe we'll get to meet on another thrilling code adventure, who knows?!
Happy midnight~greeting <:-)=

Hehe ~ yes I could read all through your literature fine while holding fast to my coffee without breaking it

I'm really glad for you that you could hunt down the reasons for the troublesome situation and found an agreement to solve it.
Having been beta-testing for some years I'm very aware about the numless unthinkable interdependencies that can be ~ so don't worry for swirling water. I too take benefit from this tour.

Thank you for your spirited words and tuning in into poetics. And I'm really delighted to hear you like my pseudonym as I always fear a bit, it could be kind of strange to french native speakers. The longer I'm useing it the more I like it.

So ~ now that the anchor's aweigh, I wish you successful deep diving into an infinite scrolling of finds until you'll reach the end of the internet.

and until our next adventure ~ V~ Live long and prosper!
Deleted user 128
§
Создано:
Bonjour Vivre,

There's a reason, a cause to all effects, knowing it exists is both a stimuli and an abomination sometimes!
V indeed, Churchill & Beethoven united :)

I'm wishing you, to us all, a symphony of thoughts. "Cogito ergo sum" :)

'Till next, thanking you again, sincerely, viva la Vida!

Ответить

Войдите, чтобы ответить.