ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > Living Room

Looking for alternative script to search site

<< < (2/4) > >>

4wd:
Did try to replace Google.com with Qwant.com and it doesn't work.-dantheman (March 29, 2021, 02:10 PM)
--- End quote ---

Qwant doesn't use the search keyword:


--- Code: Javascript ---javascript:q=%22%22+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);if(!q)q=prompt(%22Search%20terms%20[leave%20selection%20and%20box%20blank%20to%20list%20all%20pages]%20...%22).replace(/\s\+/g,%22%252B%22);if(q!=null)location=%22http://www.qwant.com/?q=%22+q.replace(/\s+/g,%22+%22)+%22+site:%22+location.hostname;void(0);
Neither does DDG:


--- Code: Javascript ---javascript:q=%22%22+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);if(!q)q=prompt(%22Search%20terms%20[leave%20selection%20and%20box%20blank%20to%20list%20all%20pages]%20...%22).replace(/\s\+/g,%22%252B%22);if(q!=null)location=%22http://duckduckgo.com/?q=%22+q.replace(/\s+/g,%22+%22)+%22+site:%22+location.hostname;void(0);
Startpage different again:


--- Code: Javascript ---javascript:q=%22%22+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);if(!q)q=prompt(%22Search%20terms%20[leave%20selection%20and%20box%20blank%20to%20list%20all%20pages]%20...%22).replace(/\s\+/g,%22%252B%22);if(q!=null)location=%22http://startpage.com/sp/search?q=%22+q.replace(/\s+/g,%22+%22)+%22+site:%22+location.hostname;void(0);
Presearch:


--- Code: Javascript ---javascript:q=%22%22+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);if(!q)q=prompt(%22Search%20terms%20[leave%20selection%20and%20box%20blank%20to%20list%20all%20pages]%20...%22).replace(/\s\+/g,%22%252B%22);if(q!=null)location=%22http://engine.presearch.org/search?q=%22+q.replace(/\s+/g,%22+%22)+%22+site:%22+location.hostname;void(0);
Just input the search into an engine and use the relevant part of the URL:

https://engine.presearch.org/search?q=thought+site%3Adonationcoder.com
--- End quote ---

dantheman:
@4wd - would it be too much to illustrate Presearch as example?  :-[

Re-read your post at least 4 times...

Wish i was a coder!

The little html i learned years ago, is long gone.

4wd:
Let's start with a site search on Donationcoder for mouser in Google, you'd enter:

--- Code: Text ---mouser site:donationcoder.com
After hitting Enter the URL becomes:

--- Code: Text ---https://www.google.com/search?q=mouser+site%3Adonationcoder.com
Same search on Presearch gives a URL of:

--- Code: Text ---https://engine.presearch.org/search?q=mouser+site%3Adonationcoder.com
Your original bookmarklet, (which is what a bookmark consisting of JavaScript is generally called):

--- Code: Javascript ---javascript:q=%22%22+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);if(!q)q=prompt(%22Search%20terms%20[leave%20selection%20and%20box%20blank%20to%20list%20all%20pages]%20...%22).replace(/\s\+/g,%22%252B%22);if(q!=null)location=%22http://www.google.com/search?q=%22+q.replace(/\s+/g,%22+%22)+%22+site:%22+location.hostname;void(0);
Within it is the same format site search URL as for Google above, (%22 is HTML escaped ASCII for quote, " - ignored for the purposes of simplified explanation):

--- Code: Text ---http://www.google.com/search?q=%22+q.replace(/\s+/g,%22+%22)+%22+site:%22+location.hostnameYou have code replacement for your entered search term:

--- Code: Text ---q.replace(/\s+/g,%22+%22)ie. mouser
And addition of the current site URL:

--- Code: Text ---location.hostnameie. donationcoder.com

The format of the search terms is basically identical between Google and Presearch, shown above in the individuals URLs, this bit:

--- Code: Text ---q=mouser+site%3Adonationcoder.com
The only difference is the base URL:

--- Code: Text ---https://www.google.com/search?Versus:

--- Code: Text ---https://engine.presearch.org/search?
So it becomes a simple text replacement to switch from Google to Presearch, the same applies to the other search engines listed above, so the bookmarklet becomes:


--- Code: Javascript ---javascript:q=%22%22+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);if(!q)q=prompt(%22Search%20terms%20[leave%20selection%20and%20box%20blank%20to%20list%20all%20pages]%20...%22).replace(/\s\+/g,%22%252B%22);if(q!=null)location=%22http://engine.presearch.org/search?q=%22+q.replace(/\s+/g,%22+%22)+%22+site:%22+location.hostname;void(0);
So no coding required, just observation ;)

BTW, haven't bothered explaining the rest of the JavaScript involved because:

* it's not really relevant to the original query and,
* I'd have to read up to understand it also :P

wraith808:
@4wd - would it be too much to illustrate Presearch as example?  :-[

Re-read your post at least 4 times...

Wish i was a coder!

The little html i learned years ago, is long gone.
-dantheman (March 29, 2021, 07:19 PM)
--- End quote ---

Basically, after you do a search on the platform, look at the format of the search terms. They should tell you how to format your url in your script. That's what @4wd is illustrating.

dantheman:
So basically, if Presearch is selected, then this is the part i would use
%22http://engine.presearch.org/search?q=%22+q.replace(/\s+/g,%22+%22)
to replace Google's?

Did use 4wd's last script and it isn't responding.

(btw - thanks for the sweat out brushing up on the coding language 4wd!
Illustration is much appreciated too and hope other newbies will find it helpful).

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version