Page 1 of 1

modifying GoogleSearch to make results inaccurate

Posted: Mon Aug 25, 2014 5:10 pm
by jarid3421
I already made a post at Superuser http://superuser.com/questions/800325/h ... -look-dumb

I will summerize here:

[1] http://i.stack.imgur.com/ZN60B.jpg

My point is i do not want to see torrent sites in the search results,so if someone searches Google or YouTube this phrase(-torrent-download-watch) should be automatically and invisibly added.

[2] http://i.stack.imgur.com/4mUSt.jpg

And one of the answers was this userscript written by krowe:
// ==UserScript==
// @name Tamper with Google Results
// @namespace http://superuser.com/users/145045/krowe
// @version 0.1
// @description This just modifies google results to exclude certain things.
// @match http://*.google.com
// @match https://*.google.com
// @copyright 2014+, KRowe
// ==/UserScript==


function GM_main () {
window.onload = function () {
var targ = window.location;
if(targ && targ.href && targ.href.match('https?:\/\/www.google.com/.+#q=.+') && targ.href.search("/+-torrent/+-watch/+-download")==-1) {
targ.href = targ.href +"+-torrent+-watch+-download";
}
};
}

//-- This is a standard-ish utility function:
function addJS_Node(text, s_URL, funcToRun, runOnLoad) {
var D=document, scriptNode = D.createElement('script');
if(runOnLoad) scriptNode.addEventListener("load", runOnLoad, false);
scriptNode.type = "text/javascript";
if(text) scriptNode.textContent = text;
if(s_URL) scriptNode.src = s_URL;
if(funcToRun) scriptNode.textContent = '(' + funcToRun.toString() + ')()';
var targ = D.getElementsByTagName('head')[0] || D.body || D.documentElement;
targ.appendChild(scriptNode);
}

addJS_Node (null, null, GM_main);


Please tell me if there is any room for improvment .

Thank you in advance.

Re: modifying GoogleSearch to make results inaccurate

Posted: Mon Aug 25, 2014 8:42 pm
by requinix
If the point is to stop seeing results for things you don't want to see, I use Personal Blocklist in Chrome. Five minutes of searching and blocking later, you should have pretty much all the sites you don't care for hidden.
Or you can modify the default search URL and/or set up a shortcut (or whatever it may be called) in your browser. In Chrome the default search URL is

Code: Select all

{google:baseURL}search?q=%s&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:bookmarkBarPinned}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}{google:omniboxStartMarginParameter}ie={inputEncoding}
Make a new "search engine" with a particular keyword, like "safe", then that as the search URL modified to include the -stuff, and you can do "safe [TAB] terms" to get the special search.

Or are you looking for a clever, programmatic solution?

Re: modifying GoogleSearch to make results inaccurate

Posted: Tue Aug 26, 2014 11:01 am
by jarid3421
My aim is to block torrent sites from google search results.I don't want others(family members) to notice the tampering.

Comment advice taken from superuser.com
I'd imagine that getting the URL to show the original results would be easy to do if you replace the page content with a frame and instead of the redirect you just load the new page into the frame. Getting the search box to work right is going to be a little more tricky but in the end is also very doable. The trick is going to be to use CSS to hide it then make another textbox to be seen. Then you'l just need to add a few event handlers to sync the real search box with your fake search box.
Now I have some questions in my mind.

1.Can I change the look and style of the Google Custom Search Engine to look like normal google main pagehttps://www.google.co.uk/?gws_rd=ssl

2.User stylesheet support removed in Chrome 33. I used it to hide Tampermonkey extension,Is there a way around this?

3.

Code: Select all

{google:baseURL}search?q=%s&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:bookmarkBarPinned}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}{google:omniboxStartMarginParameter}ie={inputEncoding}
Can you please explain a bit more, like can it hide "-torrent" from the search text box
oblivion css.jpg
4.If you are familiar with MITM porxy like Fiddler,How can I remove the links from google search
fiddler whose line.jpg
Sorry for the long text.

Re: modifying GoogleSearch to make results inaccurate

Posted: Tue Aug 26, 2014 1:24 pm
by requinix
It's easily noticed but it sounds like you need filtering software instead. Continuing on your current route will only help for very specific uses and will be easy to get around; filtering software generally uses anti-tampering protection, is more flexible, and is certainly more reliable.
jarid3421 wrote:My aim is to block torrent sites from google search results.I don't want others(family members) to notice the tampering.
1. This all relies on using one particular browser. If anyone switched to, say, IE or Firefox then they would bypass your restrictions.
2. Unless you do something very sophisticated, it will be obvious that there's something wrong because won't be 10 results on each page.
3. There's nothing to stop someone from just going to a torrent site directly and searching there.
jarid3421 wrote:1.Can I change the look and style of the Google Custom Search Engine to look like normal google main page https://www.google.co.uk/?gws_rd=ssl
If you were to use the API (which I believe is still available) instead, yes, because you'd get to/have to output the entire HTML yourself.
Otherwise you'd need something in-browser to modify the page on the fly.
jarid3421 wrote:2.User stylesheet support removed in Chrome 33. I used it to hide Tampermonkey extension,Is there a way around this?
Not that I know of. That's a special page so extensions don't even work there.
jarid3421 wrote:3.Can you please explain a bit more, like can it hide "-torrent" from the search text box
It would not do that. I mentioned it because it sounded like you were asking for a way to hide results you didn't want from particular searches, like if you wanted to search for "game of thrones" without having to wade through all the torrent listings and such.
jarid3421 wrote:4.If you are familiar with MITM porxy like Fiddler,How can I remove the links from google search
Fiddler is oriented towards software debugging, not filtering. I'm not familiar enough with it to tell you how to do that but I assume it would involve either regular expressions or DOM functions to find and remove the particular bits of HTML you didn't want. Which would be difficult to get right.

Re: modifying GoogleSearch to make results inaccurate

Posted: Sat Aug 30, 2014 12:23 am
by jarid3421
Can you please take a look at this http://imgur.com/JdKLgkR,gbRUpjS,P9dV4Za#0

Now,how to write a script from the above example? help needed please!