Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-29-2012, 10:25 PM   PM User | #1
mlshorter
New to the CF scene

 
Join Date: Dec 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
mlshorter is an unknown quantity at this point
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?
mlshorter is offline   Reply With Quote
Old 12-29-2012, 10:37 PM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,468
Thanks: 0
Thanked 499 Times in 491 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
What do you have in the include/exclude commands at the top of the userscript?
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 12-30-2012, 08:09 AM   PM User | #3
mlshorter
New to the CF scene

 
Join Date: Dec 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
mlshorter is an unknown quantity at this point
Nothing, the file contains only the code shown above.Once again, it brings up the alert box EVERYWHERE except on google.com!

Last edited by mlshorter; 12-30-2012 at 08:12 AM..
mlshorter is offline   Reply With Quote
Old 12-30-2012, 09:36 AM   PM User | #4
mlshorter
New to the CF scene

 
Join Date: Dec 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
mlshorter is an unknown quantity at this point
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!
mlshorter is offline   Reply With Quote
Old 12-30-2012, 08:05 PM   PM User | #5
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,468
Thanks: 0
Thanked 499 Times in 491 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Quote:
Originally Posted by mlshorter View Post
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.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Reply

Bookmarks

Tags
google, redirect, search, url clear

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:56 AM.


Advertisement
Log in to turn off these ads.