Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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?

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,627
    Thanks
    0
    Thanked 648 Times in 638 Posts
    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/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,627
    Thanks
    0
    Thanked 648 Times in 638 Posts
    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/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •