CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript programming (http://www.codingforums.com/forumdisplay.php?f=2)
-   -   User Scripts NOT WORKING on GOOGLE domains? (http://www.codingforums.com/showthread.php?t=285012)

mlshorter 12-29-2012 10:25 PM

User Scripts NOT WORKING on GOOGLE domains?
 
Hello,

As many of you might know, in modern browsers there is support for "User Scripts". In Opera for example Opera --> Settings --> Preferences --> Advanced --> Content --> JavaScript Options


In other words, you can write your own javascripts, save it locally and add it to sites you open from the web.

What I want is to bypass those click-tracking redirects in the Google search results and found literally tons of scripts on userscripts.org that claim to serve that purpose. However, none of these actually work in Opera browser. After experimenting for about an hour I found that even the most simple scripts don't work on google.com domains!

For example, this simple script brings up the alert box on yahoo.com, facebook.com, digg.com... etc but does not work on google.com

PHP Code:

(function ()  
{  
alert('Testing success!');  
})(); 

So once again, in Opera --> Settings --> Preferences --> Advanced --> Content --> JavaScript Options I set the "User Script" folder and in that folder there there are my .js files working whichever domain I open except google.com

Anybody has an idea about what's going on here or can anybody reproduce and confirm this?

felgall 12-29-2012 10:37 PM

What do you have in the include/exclude commands at the top of the userscript?

mlshorter 12-30-2012 08:09 AM

Nothing, the file contains only the code shown above.Once again, it brings up the alert box EVERYWHERE except on google.com!

mlshorter 12-30-2012 09:36 AM

Ok got it!

In Opera --> Settings --> Preferences --> Advanced --> Content --> Manage Site Preferences I had google.com and few other domains listed though I DID NOT add them there.

Anyway, I removed them all and now I't working!

Thanks!

felgall 12-30-2012 08:05 PM

Quote:

Originally Posted by mlshorter (Post 1303049)
Nothing, the file contains only the code shown above.Once again, it brings up the alert box EVERYWHERE except on google.com!

So you are missing several statements that all userscripts are supposed to have at the top.

One in particular should always be there:

If you want the script to run on all sites you should have:

Code:

// @include      *
or if you don't want it to run on some sites then specify exclude statements for each instead.

The full block of statements that should appear at the top of all userscripts is:

Code:

// ==UserScript==
// @namespace    http://www.example.com
// @author          author's name
// @name            name of the script
// @description    what the script does
// @include          *
// ==/UserScript==

while a userscript will work in some browsers without that code it will not work in all browsers and without the include/exclude statements you have no control over which pages it does/doesn't run on.


All times are GMT +1. The time now is 08:49 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.