Solved

Greasemonkey Script Stopped Working - Any ideas why?

Posted on 2009-07-10
14
341 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
  • 6
  • 6
14 Comments
 
LVL 27

Expert Comment

by:BigRat
Comment Utility
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
Comment Utility
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:wilq32
Comment Utility
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
 

Author Comment

by:FuelUrMind
Comment Utility
As in the html of the page?
0
 
LVL 18

Expert Comment

by:wilq32
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 18

Expert Comment

by:wilq32
Comment Utility
ok I get it - now I can see what I can do for you :)
0
 
LVL 18

Expert Comment

by:wilq32
Comment Utility
line 31:

change from:

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


to



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





Works for me, at least for now ;)
0
 

Author Comment

by:FuelUrMind
Comment Utility
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:wilq32
Comment Utility
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
Comment Utility
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:
wilq32 earned 500 total points
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now