?
Solved

Greasemonkey Script Stopped Working - Any ideas why?

Posted on 2009-07-10
14
Medium Priority
?
355 Views
Last Modified: 2012-05-07
There's a very handy script that filters the google results to only show results with stars from the stumbleupon community. This script was great for finding the best results fastest. Unfortunalty it stopped working I'm pretty sure when google change how it referenced some of their own page elements. This script has been abandoned by it's author and I have no idea how to fix it. If any can have a look I'd really appreciate it.

Thanks.
http://userscripts.org/scripts/show/26533
// StumbleStars For Google
// version 0.1 alpha
// 2008-05-13
// Copyright (c) 2008, Jason Whitener
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
 
// ==UserScript==
// @name          StumbleStars For Google
// @namespace     http://jasonwhitener.com
// @description   Script to remove anything not marked by a Stumble Star
// @include       http://www.google.com/*
// @include       http://*.google.com/*
// ==/UserScript==
 
tablehits = document.evaluate(
    "//table[@class='t bt']",
    document,
    null,
    XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
    null);
		for (var i = 0; i < tablehits.snapshotLength; i++) {
    thistablehit = tablehits.snapshotItem(i);
    	
			thistablehit.innerHTML = '<input id="btnFilter" type="submit" class="inputbutton" value="See Stumble Stars" onclick="filterit()" />';
			}
			
function filterit() {
allDivgs = document.evaluate(
    "//div[@class='g']",
    document,
    null,
    XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
    null);
for (var i = 0; i < allDivgs.snapshotLength; i++) {
    thisDivg = allDivgs.snapshotItem(i);
    	
				var myRegExp = /star.png/;
				var string1 = thisDivg.innerHTML;
				var matchPos1 = string1.search(myRegExp);
				
				if(matchPos1 != -1)
					 temp = 'temp';
				else
					thisDivg.innerHTML = '';
 
}
 
}
document.getElementById('btnFilter').addEventListener("click", filterit, true);

Open in new window

0
Comment
Question by:FuelUrMind
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
14 Comments
 
LVL 27

Expert Comment

by:BigRat
ID: 24823294
It looks as if the css class has changed. Can you give me a Google search term which produces the results you want, and I'll try and establish what has changed.
0
 

Author Comment

by:FuelUrMind
ID: 24824601
The script doesn't work with any query's anymore, but used to work with all searches.However, the button to filter the results still shows up on google images though.
example-search.png
0
 
LVL 18

Expert Comment

by:Pawel Witkowski
ID: 24876514
can you provide a sample page that we can see those stars in search result? I dont see those "stars" in google search so its hard to create / update  script for that :)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:FuelUrMind
ID: 24876524
As in the html of the page?
0
 
LVL 18

Expert Comment

by:Pawel Witkowski
ID: 24876546
well... anything.. I trying to help but I never see that star on google search... maybe a URL ? or search case example ?
0
 

Author Comment

by:FuelUrMind
ID: 24876566
I've attached a screenshot. If you'd like to generate them yourself you need to install the stumbleupon toolbar. I can send you the html but I don't know if that help without the server side code.

Thanks
7-17-2009-1-04-29-AM.png
0
 
LVL 18

Expert Comment

by:Pawel Witkowski
ID: 24876594
ok I get it - now I can see what I can do for you :)
0
 
LVL 18

Expert Comment

by:Pawel Witkowski
ID: 24876825
line 31:

change from:

"//div[@class='g']",


to



"//li[@class='g w0']",





Works for me, at least for now ;)
0
 

Author Comment

by:FuelUrMind
ID: 24877159
hm I tried editing and still nothing. Here's the updated script just in case I did something wrong:


// StumbleStars For Google
// version 0.1 alpha
// 2008-05-13
// Copyright (c) 2008, Jason Whitener
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
 
// ==UserScript==
// @name          StumbleStars For Google
// @namespace     http://jasonwhitener.com
// @description   Script to remove anything not marked by a Stumble Star
// @include       http://www.google.com/*
// @include       http://*.google.com/*
// ==/UserScript==
 
tablehits = document.evaluate(
    "//table[@class='t bt']",
    document,
    null,
    XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
    null);
                for (var i = 0; i < tablehits.snapshotLength; i++) {
    thistablehit = tablehits.snapshotItem(i);
        
                        thistablehit.innerHTML = '<input id="btnFilter" type="submit" class="inputbutton" value="See Stumble Stars" onclick="filterit()" />';
                        }
                        
function filterit() {
allDivgs = document.evaluate(
    "//li[@class='g w0']",
    document,
    null,
    XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
    null);
for (var i = 0; i < allDivgs.snapshotLength; i++) {
    thisDivg = allDivgs.snapshotItem(i);
        
                                var myRegExp = /star.png/;
                                var string1 = thisDivg.innerHTML;
                                var matchPos1 = string1.search(myRegExp);
                                
                                if(matchPos1 != -1)
                                         temp = 'temp';
                                else
                                        thisDivg.innerHTML = '';
 
}
 
}
document.getElementById('btnFilter').addEventListener("click", filterit, true);

Open in new window

0
 
LVL 18

Expert Comment

by:Pawel Witkowski
ID: 24877167
its probably because google use diffrent classes on your version... then try maybe this:


    "//li",

in the same line instead of

    "//li[@class='g w0']",
0
 

Author Comment

by:FuelUrMind
ID: 24880659
I really wish I could say it's working but it's still not. I uploaded a sample html page (to display it just change the extension to html) so you can see what the css classes are for me. Thank you so much for your help on this.
search.txt
0
 
LVL 18

Accepted Solution

by:
Pawel Witkowski earned 2000 total points
ID: 24892941
Sorry for long response I had a free time with my wife :)

I rewrited almost all code, and test it using new greasemonkey so it works for now (i hope for you also). It does work only on search results, because I did not see any responses on images tab. If you find them give me a search response. Cheers
// StumbleStars For Google
// version 0.1 alpha
// 2008-05-13
// Copyright (c) 2008, Jason Whitener
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
 
// ==UserScript==
// @name          StumbleStars For Google
// @namespace     http://jasonwhitener.com
// @description   Script to remove anything not marked by a Stumble Star
// @include       http://www.google.com/*
// @include       http://*.google.com/*
// ==/UserScript==
 
 
	filter_it = function() {
	allDivgs = document.evaluate(
		"//li",
		document,
		null,
		XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
		null);
	for (var i = 0; i < allDivgs.snapshotLength; i++) {
		thisDivg = allDivgs.snapshotItem(i);
			
		var myRegExp = /star.png/;
		var string1 = thisDivg.innerHTML;
		var matchPos1 = string1.search(myRegExp);
		
		if(matchPos1 != -1)
				 temp = 'temp';
		else
				thisDivg.innerHTML = '';
	 
	}
	return false;
}
 
var script = document.createElement('script'); 
script.innerHTML= "filter_it="+ filter_it.toSource();
script.type="text/javascript";
document.body.appendChild(script);
 
var forms=document.getElementsByTagName('form');
for (var i = 0; i < forms.length; i++) {
	var el = forms[i].appendChild(document.createElement('div'));
	el.innerHTML = '<button onclick="filter_it();return false">See Stumble Stars</button>';
}

Open in new window

0
 

Author Closing Comment

by:FuelUrMind
ID: 31601977
Holy crap I freaking love you man! Works perfectly and no it's not supposed to do anything on Google images. You are a god.
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question