WordPress.org

Ready to get started?Download WordPress

Forums

Google AdSense Anti Click-Fraud Plugin
[resolved] JS Issues in check.js and hideads.js (16 posts)

  1. Hoovilation
    Member
    Posted 1 year ago #

    I found what seems to be a few issues in the JS for this plugin.

    check.js

    var options = jq.extend(jq.cfmonitor.options, options);

    If any other plugin (and there are others like ShareThis) use the same options variable name then they will conflict with this one. Why not just update and use the jq.cfmonitor.options that is already defined?

    hideads.js

    var customclass = clientcfmonitor.customclass

    Missing semicolon

    jQuery(document).ready(function(){
    // check if ad is disabled or hidden
                if (disablead === 'true'){
                jQuery("." + customclass).remove();
                event.preventDefault();
                }else{
                jQuery("." + customclass).remove();
                event.preventDefault();
                }
    
    });

    If disablead is false the ad is still being removed. Notice the logic within the if and else are the same.

    http://wordpress.org/plugins/adsense-click-fraud-monitoring/

  2. mgrmn
    Member
    Posted 1 year ago #

    add event to function(), or copy below code

    jQuery.noConflict();
    jQuery(document).ready(function(event){
    // check if ad is disabled or hidden
                if (disablead === 'true'){
                jQuery("." + customclass).remove();
                event.preventDefault();
                }else{
                jQuery("." + customclass).remove();
                event.preventDefault();
                }
    
    });
  3. Rene Hermenau
    Member
    Plugin Author

    Posted 1 year ago #

    Hi mgrmm,

    thanks for your help. The code is outdated and not longer used any more. In the next version it will be deleted by me.

    Cheers,
    René

  4. Rene Hermenau
    Member
    Plugin Author

    Posted 1 year ago #

    @Hoovilation,

    i fixed it and now only use the jq.cfmonitor.options which is already defined.
    Excellent tip by the way:)

    The new one will be up in half an hour. I appreciate it if you wanna test it.

  5. Rene Hermenau
    Member
    Plugin Author

    Posted 1 year ago #

    @mgrmn:

    i modified the script a bit:

    jQuery.noConflict();
    jQuery(document).ready(function(){
    // check if ad is disabled by excessive clicking or hidden by admin option
    if (disablead === 'true'){
    jQuery("." + customclass).remove();
    event.preventDefault();
    }else{
    jQuery("." + customclass).remove();
    event.preventDefault();
    }
    });

  6. Hoovilation
    Member
    Posted 1 year ago #

    Hello ReneHermi,

    I applied the plugin update and yes that did the trick and corrected the issue :)

    I haven't looked through the plugin code so maybe this already exists, but have you considered creating some method that can be executed server side to check if ads should be displayed for the user? This could be useful to drop in templates if it will return true/false based on the Click Fraud settings and user information.

    Thanks!

  7. Rene Hermenau
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Hoovilation,

    i am not sure what you mean with "drop in templates". Can you explain that for a specific case?

    A server side check is also integrated, so even when user do not use javascript they will be blocked with the next visit. (Obviously, does not make much sense as AdSense is not working without JS)

  8. Hoovilation
    Member
    Posted 1 year ago #

    Hello ReneHermi,

    So let us say that in one of my template files like the header I am outputting an ad. Before I do that I would rather perform a check on the user to see if they pass all the criteria in the Click Fraud settings like:

    if (clickfraud_user_can_see_ads()) {
      echo 'ad code';
    }

    Currently this is all handled client side by the inclusion of the hideads_min.js. I suppose I can add a method myself that performs the same checks you have in cfenqueue_plugin_scripts but I just wanted to see if maybe this already exists or is something you were planning on adding. I hope that is more clear.

  9. Rene Hermenau
    Member
    Plugin Author

    Posted 1 year ago #

    Mhh i understand, but most of the logic is already in the php class.

    You can use the following code to see if a IP is already blocked or not:

    include_once 'class.cfmonitor.php';
    $clickmonitor = new clickfraudmonitor();

    $clicks = $clickmonitor->isblockedcount

    if $clicks <= get_option('cfmonitor_click_threshold'){
    your function here
    }

  10. Hoovilation
    Member
    Posted 1 year ago #

    Sounds good I should be able to handle that. I do have another question for you though. In cfenqueue_plugin_scripts why is the cfmonitor.css enqueued? It seems like this css is only needed for the Administration settings page where it is already added. The css also has some generic things like .title with !important attributes that overrides the css we have on our site.

    And on a side note the "Block my IP" currently only supports one IP address. I'm thinking of adding the ability to allow for multiple via a comma separated list. Is this something you would like to push into your code base? I could submit a SVN patch.

  11. Rene Hermenau
    Member
    Plugin Author

    Posted 1 year ago #

    You´re right. Thats not correct i modify the code and fix it. (That happens when i am working on different projects at the same time:))
    Good to have your here.

    When you make new function i like to push it into the code base. Nice idea! Of course i will credit you in the source.

  12. Rene Hermenau
    Member
    Plugin Author

    Posted 1 year ago #

    Fixed. The css is only active in the admin panel of the script.

  13. Hoovilation
    Member
    Posted 1 year ago #

    Excellent, I have the patch to support multiple ips in the "Block my IP" option, how can I submit this to you?

  14. Rene Hermenau
    Member
    Plugin Author

    Posted 1 year ago #

    Great, you are fast. Do you wanna send the changes it via email to admin at x-simulator.de?

  15. Hoovilation
    Member
    Posted 1 year ago #

    Sent, thanks again for the quick updates.

  16. Rene Hermenau
    Member
    Plugin Author

    Posted 1 year ago #

    Build in v. 1.6. Its working great!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags