Jquery userscript - adwords issue

hip_hop_x

Regular Member
Joined
Aug 27, 2009
Messages
305
Reaction score
65
Hey there,
I was trying to code an userscript for G adwords, the problem is that i can't really detect events that are happening, not to mention that i can't really fetch any of the data...

Notice: This is not the full userscript, jquery was included and works but i can't really parse the page.


I did try to use window.open (instead of ready or window.addEventListener ("load", etc... ) but those doesn't detect the click either.
I also tested to initialize all the code after a timeout of 20 seconds (when ajax was fully loaded), but the same, no results.

Not even this simple alert doesn't work, not really sure how to be able to fetch data. (i did try to replace with classes, same nothing)
Code:
$(document).ready(function(){


	$('button').click(function(){
			alert('click');
	});


});

Any help would really be good.
 
$('button')

Does the target page actually have an html5 button tag or did you pass jQuery a wrong identifier? ;)
 
it has, and i even did try with the buttons class, same result, nothing :(
 
Make a jsfiddle and we 'll be able to help you more.
 
There's really nothing much about this userscript, it's just a simple feature that doesn't work and it's really the first time when a website successfully blocked the main events detection.

Code:
// ==UserScript==
// @name          User-controlled Google Adsense
// @namespace     Website
// @description   Rewrites the URL in adsense iframes to a user-specified value, changing the ads
// @include       https://adwords.google.com/o/Targeting*
// ==/UserScript==

/*
Here will be a copy & paste jquery from jquery download
*/



$(document).ready(function(){
  $('button').click(function(){ 
      alert('click');    
  });
});
 
Did you actually load jQuery before you use it?
 
Yes, and i tested with an alert in $(document).ready to see if everything goes well, and it did.

One of the problems may be the fact that $(document).ready actually loads before the page is fully loaded... and that's really something i don't know how to detect (same happends with window.load)
 
I think I know what 's going on, try this:

Code:
 $(document).ready(function(){
  $('body').on('click', 'button', function(){ 
      alert('click');    
  });
});

If it works, ask me why :)
 
Doesn't work either, not even this other code
Code:
$('body').click(function(){
		alert('x');
	});

Their security really seems to be good and nothing seems to be working :(
 
I just tested my version on Firefox and it works fine :)

You messed up somewhere in your setup. You probably didn't load jQuery.

Here 's the full script, put it properly into Greasemonkey and it works.

Code:
// ==UserScript==
// @name          User-controlled Google Adsense
// @namespace     Website
// @description   Rewrites the URL in adsense iframes to a user-specified value, changing the ads
// @include       https://adwords.google.com/o/Targeting*
// @require   http://code.jquery.com/jquery-1.8.1.min.js
// ==/UserScript==

$(document).ready(function(){
  $('body').on('click', 'button', function(){ 
      alert('click');    
  });
});
 
Darn, indeed jquery wasn't loading or something (the odd is that $(document).ready worked and didn't return any errors for the $)

Thank you big time mate!
 
Back
Top