Greasemonkey userscript to hide Google results by domain
-
- 2StarLounger
- Posts: 148
- Joined: 26 Dec 2010, 18:17
Greasemonkey userscript to hide Google results by domain
Edit: There are updated versions of this attachment down the thread. Latest is v0.83 in Post 41873.
In the exceedingly popular thread Add-on to exclude domains from right-click?, I hypothesized a Greasemoney userscript that would hide selected hits in a search results page. I've created a version 0.1 of such a userscript. If you are a Greasemonkey user, why not give it a try?
Some general notes:
(1) Pale-colored buttons reading XX should appear next to the page title in your results. Click this button to add that domain to the blacklist. On the next reload, those hits should be suppressed as described in #2.
(2) Results for blacklisted domains are replaced with a button that lets you view the result if you want to. This is a one-time viewing; the domain still will be suppressed on the next page load.
(3) If your blacklist becomes messed up, you can edit or clear it in about:config (there is no other UI for managing the list).
(4) bigresource.com is blacklisted by default, but after you add one of your own, you can edit that out if you wish.
Although not getting unwanted hits in the first place is more efficient, this tool works on any Google results page regardless of how you got there. At least until they change it again.
In the exceedingly popular thread Add-on to exclude domains from right-click?, I hypothesized a Greasemoney userscript that would hide selected hits in a search results page. I've created a version 0.1 of such a userscript. If you are a Greasemonkey user, why not give it a try?
Some general notes:
(1) Pale-colored buttons reading XX should appear next to the page title in your results. Click this button to add that domain to the blacklist. On the next reload, those hits should be suppressed as described in #2.
(2) Results for blacklisted domains are replaced with a button that lets you view the result if you want to. This is a one-time viewing; the domain still will be suppressed on the next page load.
(3) If your blacklist becomes messed up, you can edit or clear it in about:config (there is no other UI for managing the list).
(4) bigresource.com is blacklisted by default, but after you add one of your own, you can edit that out if you wish.
Although not getting unwanted hits in the first place is more efficient, this tool works on any Google results page regardless of how you got there. At least until they change it again.
You do not have the required permissions to view the files attached to this post.
Last edited by jscher2000 on 05 Feb 2011, 17:22, edited 3 times in total.
-
- Administrator
- Posts: 12857
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Greasemonkey userscript to hide Google results by domain
I tried installing this, but cannot see any pale colored buttons.
Greasemonkey said that it had installed the script, but I don't know how to check. What should I be searching for under about:config?
Any suggestions of what I might have done wrong?
Edited to add
I have definitely managed to install the script...
Greasemonkey said that it had installed the script, but I don't know how to check. What should I be searching for under about:config?
Any suggestions of what I might have done wrong?
Edited to add
I have definitely managed to install the script...
You do not have the required permissions to view the files attached to this post.
StuartR
-
- 2StarLounger
- Posts: 148
- Joined: 26 Dec 2010, 18:17
Re: Greasemonkey userscript to hide Google results by domain
Stuart, thanks for trying it.
By any chance is your default Google page a .co.uk page? In that case, please edit the URL in the Included Pages box to the correct URL (or feel free to add it as a second URL). I think there must be a way to add that into the script file, but the header section was auto-generated so I don't know the syntax.
If you are searching on google.com, then hmmm, do you see any script errors in the Error Console (Tools menu)? Click Clear to get rid of all the old errors, then run the search again and see if there are any problems.
By any chance is your default Google page a .co.uk page? In that case, please edit the URL in the Included Pages box to the correct URL (or feel free to add it as a second URL). I think there must be a way to add that into the script file, but the header section was auto-generated so I don't know the syntax.
If you are searching on google.com, then hmmm, do you see any script errors in the Error Console (Tools menu)? Click Clear to get rid of all the old errors, then run the search again and see if there are any problems.
-
- Administrator
- Posts: 12857
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Greasemonkey userscript to hide Google results by domain
Jefferson,
I added http://www.google.co.uk/search*" onclick="window.open(this.href);return false; to the included pages, cleared the error console and tried again. The error console now shows this...
I added http://www.google.co.uk/search*" onclick="window.open(this.href);return false; to the included pages, cleared the error console and tried again. The error console now shows this...
You do not have the required permissions to view the files attached to this post.
StuartR
-
- 2StarLounger
- Posts: 148
- Joined: 26 Dec 2010, 18:17
Re: Greasemonkey userscript to hide Google results by domain
I'm at a loss. Either something is blocking the script or you're getting a different page structure than I get... Can you email me the rendered page source for a sample search? Select all, right-click, View Selection Source, then paste into a blank text document for mailing.StuartR wrote:I added http://www.google.co.uk/search*" onclick="window.open(this.href);return false; to the included pages, cleared the error console and tried again. The error console now shows this...
(Also, at the top of the console, click the red X Error button to filter for script errors.)
-
- 2StarLounger
- Posts: 148
- Joined: 26 Dec 2010, 18:17
Re: Greasemonkey userscript to hide Google results by domain
Okay, I see the problem. When you use Instant search, the page does not reload, so the script does not run again. I somehow need to hook the script into the relevant events for Instant search....
{Day turns to night...}
Well, that was a deep dive! :D
{Day turns to night...}
Well, that was a deep dive! :D
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 12857
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Greasemonkey userscript to hide Google results by domain
This version installed OK, and has two entries for google.co.uk, but it still behaves the same.
You do not have the required permissions to view the files attached to this post.
StuartR
-
- GoldLounger
- Posts: 3081
- Joined: 24 Jan 2010, 19:07
Re: Greasemonkey userscript to hide Google results by domain
Jefferson,
I didn't post earlier but; you have another user here; just adding cheers, as you look at that.
I looked at the first one (I've not used Greasemonkey earlier; yep I know, not the kind of beta tester one would want ), and as it looked as in Stuart's first screen shot, I understood that I had to add something, so added the google.se URL under included, similar to the above, but got no change in the results.
But now.
Woo hoo; your second works (though it wrote over my google.se ). I didn't bother to add it again for a test; since I've a UK bookmark, and just tried it. But, if I enable JavaScript for google.co.uk (it wasn't in NoScript), it doesn't work (checked back and forth, enabled disabled in new tabs); I don't know perhaps I've missed something. Perhaps it is this with JavaScripts for Google.co.uk and "Instant search" as you say. (BTW Instant search or real time, whatever (I don't like it or need it that much) isn't enabled in the .se I think. But as I said, my short test on v0.2 only included the .uk.)
I didn't post earlier but; you have another user here; just adding cheers, as you look at that.
I looked at the first one (I've not used Greasemonkey earlier; yep I know, not the kind of beta tester one would want ), and as it looked as in Stuart's first screen shot, I understood that I had to add something, so added the google.se URL under included, similar to the above, but got no change in the results.
But now.
Woo hoo; your second works (though it wrote over my google.se ). I didn't bother to add it again for a test; since I've a UK bookmark, and just tried it. But, if I enable JavaScript for google.co.uk (it wasn't in NoScript), it doesn't work (checked back and forth, enabled disabled in new tabs); I don't know perhaps I've missed something. Perhaps it is this with JavaScripts for Google.co.uk and "Instant search" as you say. (BTW Instant search or real time, whatever (I don't like it or need it that much) isn't enabled in the .se I think. But as I said, my short test on v0.2 only included the .uk.)
You do not have the required permissions to view the files attached to this post.
Byelingual When you speak two languages but start losing vocabulary in both of them.
-
- Administrator
- Posts: 12857
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Greasemonkey userscript to hide Google results by domain
Argus,
I get the same behaviour as you, if I disable google.co.uk in NoScript then I can see the XX links.
I get the same behaviour as you, if I disable google.co.uk in NoScript then I can see the XX links.
StuartR
-
- GoldLounger
- Posts: 3081
- Joined: 24 Jan 2010, 19:07
Re: Greasemonkey userscript to hide Google results by domain
Jefferson,
Addendum:
It works directly on the .se with scripts enabled; as I mentioned earlier there is no real-time search there yet, perhaps the difference. So, something with their real-time tinkering, me think.
(Gee, why do we need real-time search? Just because something is possible, doesn't mean we have to implement it, build it, sell it. The .se has the previous version of "search help", some sort of auto complete. OK, can be to some help, or fun for those interested in what other people have searched, but I guess there are other tools for that. So every second letter, or so, I type the status bar flicker and away goes another batch of bytes into the tubes; just how many scrambled words would that be per day? "wnidos 7", no, "WIdows 7", argh ...; "indows 7", now slowly "Windows 7", yes! Now Enter! )
Addendum:
It works directly on the .se with scripts enabled; as I mentioned earlier there is no real-time search there yet, perhaps the difference. So, something with their real-time tinkering, me think.
(Gee, why do we need real-time search? Just because something is possible, doesn't mean we have to implement it, build it, sell it. The .se has the previous version of "search help", some sort of auto complete. OK, can be to some help, or fun for those interested in what other people have searched, but I guess there are other tools for that. So every second letter, or so, I type the status bar flicker and away goes another batch of bytes into the tubes; just how many scrambled words would that be per day? "wnidos 7", no, "WIdows 7", argh ...; "indows 7", now slowly "Windows 7", yes! Now Enter! )
Byelingual When you speak two languages but start losing vocabulary in both of them.
-
- 2StarLounger
- Posts: 148
- Joined: 26 Dec 2010, 18:17
Re: Greasemonkey userscript to hide Google results by domain
NoScript disables instant search, so that is effective but doesn't really count as a win.
I should have realized that Google is a very complex application... I noticed that sometimes Google presents a page without a name, i.e., it could be /search?, /webhp?, or /#, which I hadn't noticed before. I think that appears after logging in or logging out. I almost always use Google logged out...
So I edited the domains again (for all http://www.google.com" onclick="window.open(this.href);return false; / http://www.google.co.uk" onclick="window.open(this.href);return false; / http://www.google.se" onclick="window.open(this.href);return false;).
I don't know whether I've managed to test all the possibilities, because I never set up an iGoogle home page, but hopefully this covers it?
I should have realized that Google is a very complex application... I noticed that sometimes Google presents a page without a name, i.e., it could be /search?, /webhp?, or /#, which I hadn't noticed before. I think that appears after logging in or logging out. I almost always use Google logged out...
So I edited the domains again (for all http://www.google.com" onclick="window.open(this.href);return false; / http://www.google.co.uk" onclick="window.open(this.href);return false; / http://www.google.se" onclick="window.open(this.href);return false;).
I don't know whether I've managed to test all the possibilities, because I never set up an iGoogle home page, but hopefully this covers it?
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 12857
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Greasemonkey userscript to hide Google results by domain
THANK YOU
This version works well, even with google.co.uk enabled in NoScript.
I do hope it was a good learning experience and not just frustrating.
This version works well, even with google.co.uk enabled in NoScript.
I do hope it was a good learning experience and not just frustrating.
StuartR
-
- GoldLounger
- Posts: 3081
- Joined: 24 Jan 2010, 19:07
Re: Greasemonkey userscript to hide Google results by domain
All OK, so far for on co.uk.
By the way; the blocked sites; is it only the:
that needs to be edited if removing any?
I noticed that there is a checkbox for completely removal, if uninstalling; and it worked when changed versions earlier. Blocked sites were not blocked. (As a true developer you should now point my question to Greasemonkey and that I should read their help file. ) Thanks for adding .se.
By the way; the blocked sites; is it only the:
Code: Select all
greasemonkey.scriptvals.http://jeffersonscher.com//Google Hit Hider.hideyhosts
I noticed that there is a checkbox for completely removal, if uninstalling; and it worked when changed versions earlier. Blocked sites were not blocked. (As a true developer you should now point my question to Greasemonkey and that I should read their help file. ) Thanks for adding .se.
You do not have the required permissions to view the files attached to this post.
Byelingual When you speak two languages but start losing vocabulary in both of them.
-
- Administrator
- Posts: 12857
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Greasemonkey userscript to hide Google results by domain
Argus,
According to the original post
According to the original post
(3) If your blacklist becomes messed up, you can edit or clear it in about:config (there is no other UI for managing the list).
StuartR
-
- GoldLounger
- Posts: 3081
- Joined: 24 Jan 2010, 19:07
Re: Greasemonkey userscript to hide Google results by domain
Yep, I had read that; and I did filter for something I knew; a name on a blocked site and got a few hits, but only one for Greasemonkey, so I guess that answers it. But still, I'm new to Greasemonkey and this, so I thought I better ask.
So one can say that we have one setting for individual, and associated preferences for all blocked (including the userscript).
So one can say that we have one setting for individual, and associated preferences for all blocked (including the userscript).
Byelingual When you speak two languages but start losing vocabulary in both of them.
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Greasemonkey userscript to hide Google results by domain
Can I ask for a brief description of how 'Greasemonkey' is able to tap into/modify a site please? I'm intrigued.
Google instant search is a bit of a pain. On the whole I think I'd rather do without it..
Google instant search is a bit of a pain. On the whole I think I'd rather do without it..
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- 2StarLounger
- Posts: 148
- Joined: 26 Dec 2010, 18:17
Re: Greasemonkey userscript to hide Google results by domain
Yes, I learned way more about GreaseMonkey (and of course Google search results) than I knew before. I'll try not to do evil with the new knowledge.StuartR wrote:I do hope it was a good learning experience and not just frustrating.
Yes, apparently each Firefox preference can hold megabytes of data, so there was no point in making lots of separate ones. As you can see, it's just a string with a pipe character between each domain (and one at the beginning and end). It wouldn't be terribly hard to create a UI for this list, but since an additional button would need to be inserted into each Google results page, it would wipe away yet another tiny slice of life away for each search.Argus wrote:By the way; the blocked sites; is it only the:that needs to be edited if removing any?Code: Select all
greasemonkey.scriptvals.http://jeffersonscher.com//Google Hit Hider.hideyhosts
Firefox extensions can do pretty much anything... more specifically, your code runs when the page has finished loading. (Whether that's a DOM load or complete load of all images, etc., I haven't double-checked.) Documentation on GreaseMonkey is a bit weak. The old tutorial we all used many years ago is no longer updated, and the wiki is hard to navigate. O'Reilly's free online content is useful, but time-consuming to navigate. But, here it is:agibsonsw wrote:Can I ask for a brief description of how 'Greasemonkey' is able to tap into/modify a site please? I'm intrigued.
Official Site: Greasespot product info, GreaseSpot community wiki
Official GM userscript archive: Userscripts.org: Power-ups for your browser *
Old Intro book (online or PDF): Dive Into Greasemonkey
O'Reilly Commons wiki: Greasemonkey Hacks
* I probably should contribute this script if it proves stable.
-
- 2StarLounger
- Posts: 148
- Joined: 26 Dec 2010, 18:17
Re: Greasemonkey userscript to hide Google results by domain
I should have known that I was not the only person to ever write a Greasemonkey userscript for this. In fact, there have been many efforts over the years. These are some I found in a search, but not surprisingly, there are about a zillion scripts for Google sites:
(Based on comments on these scripts, I think it probably should be the user's preference whether a button is available for suppressed results. No one approach seems to please everyone.)
- Google Domain Blocker for Greasemonkey last updated 12/20/2010. Works well on regular search, has a UI to view the blacklist. Seems to have problems with Instant Search (e.g., doesn't run on second page of results?). There's no option to view suppressed results (just a little text annotation that the result was suppressed).
- Noise Reduction for Google & Bing for Greasemonkey last updated 8/24/2010. OMG, the UI is fantastic, with beautiful buttons and nice overlays rather than pop-up dialogs. Seems to have problems with Instant Search. No option to view suppressed results (they are just gone).
- Google Filter for Greasemonkey last update 10/25/2009 (didn't try)
- Google Results Filter for Greasemonkey last updated 10/17/2009 (didn't try)
- Google Search Filter Plus for Greasemonkey last updated 1/19/2009 (didn't try)
- Google Search Filter for Greasemonkey last updated 3/25/2008 (didn't try)
(Based on comments on these scripts, I think it probably should be the user's preference whether a button is available for suppressed results. No one approach seems to please everyone.)
-
- GoldLounger
- Posts: 3081
- Joined: 24 Jan 2010, 19:07
Re: Greasemonkey userscript to hide Google results by domain
I haven't looked at those yet; I'm happy with your userscript, and I think I didn't, so I'll do it now: thank you!
I think you are right; if one think about it, Google ... yes, there must be a "zillion" different attempts to do something with their search results.
I think you are right; if one think about it, Google ... yes, there must be a "zillion" different attempts to do something with their search results.
Byelingual When you speak two languages but start losing vocabulary in both of them.
-
- 2StarLounger
- Posts: 148
- Joined: 26 Dec 2010, 18:17
Re: Greasemonkey userscript to hide Google results by domain
Okay, here is an enhanced version. A few things to note:
This is pretty functional now. It would be nice to get a full 10 useful results, rather than getting 8 or 6 or even fewer, but... my wizardry level falls short of that objective.
Edit: Sometimes after unblocking the second of two hidden hits in a row, the first hidden result disappears. A refresh restores the missing item. Must be a bug, but I'm unable to track it down tonight.
- There is an unblock button for each blocked hit to make it easier to change your mind (or play around).
- There is a button to completely hide hits from blocked domains. (No undo for that yet, you will need to use about:config to switch that back. Filter on hidey and you'll see the preference.)
- The button appearance is more low-key and unobtrusive.
This is pretty functional now. It would be nice to get a full 10 useful results, rather than getting 8 or 6 or even fewer, but... my wizardry level falls short of that objective.
Edit: Sometimes after unblocking the second of two hidden hits in a row, the first hidden result disappears. A refresh restores the missing item. Must be a bug, but I'm unable to track it down tonight.
You do not have the required permissions to view the files attached to this post.