I already made a post at Superuser Click Here

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 any other search engine 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);

But the script is not working at all. I copied it to tampermonkey , tried it several times no luck.I need some help please.

Thank you in advance.

if someone searches Google or any other search engine

So you want this to work on all browsers, for all search engines? Are you trying to implement this on an intranet or so?

If possible,yes...If not,atleast make it work on youtube,bing and yahoo.

(I'm sorry if I sound rude... English is not my first language)

Thank you for your time.

Wouldn't it be easier to disallow all search engines and route everything through one you control? If you use a Google Custom Search engine, you can do what you want.

My aim is to block torrent and illegal video streaming sites from appearing in search results,And I do not want my family members to notice the tampering.What if they use other search engines like Bing or YouTube? will Google Custom Search engine still be useful for me?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.